Skip to content
Browse files

fixes

  • Loading branch information...
1 parent 077db11 commit ba9621fc48ff84e01d9f70d076cc912b8185729d @jaked committed May 2, 2011
View
2 _code/scala-logic/Bridge.scala
@@ -1,4 +1,4 @@
-class Bridge(val Logic: Logic) {
+class Bridge[L <: Logic](val Logic: L) {
import Logic._
object Person extends Enumeration {
View
28 _posts/2011-04-06-logic-programming-in-scala.markdown
@@ -510,3 +510,31 @@ scala> run[List[b.State]](LogicList, b, b.search, 2)
run[List[b.State]](LogicList, b, b.search, 2)
^
{% endhighlight %}
+
+*Addendum addendum*
+
+Some further advice from Jorge Ortiz: the specific type of `Logic`
+(not just `Logic.type`) can be exposed outside `Bridge` either through
+polymorphism:
+
+{% highlight scala %}
+class Bridge[L <: Logic](val Logic: L) {
+ ...
+}
+
+val b = new Bridge(LogicList)
+{% endhighlight %}
+
+or by defining an abstract value (this works the same if `Bridge` is a
+trait):
+
+{% highlight scala %}
+abstract class Bridge {
+ val Logic: Logic
+ ...
+}
+
+val b = new Bridge { val Logic = LogicList }
+{% endhighlight %}
+
+So we can compose uses of `T` but it remains abstract.
View
5 _posts/2011-04-29-logic-programming-in-scala-2.markdown
@@ -145,7 +145,7 @@ from the `bind`), and the failure continuation in force at the point
`a` was generated (which succeeds with the next available alternative
from `f(a)`).
-For `map` things are simpler, since `f(a)` returns a single value
+For `apply` things are simpler, since `f(a)` returns a single value
rather than a choice of alternatives: we succeed immediately with the
returned value.
@@ -566,5 +566,8 @@ scala> run(nat, 100000)
^C
{% endhighlight %}
+See the complete code
+[here](https://github.com/jaked/ambassadortothecomputers.blogspot.com/tree/master/_code/scala-logic).
+
Next time we'll thread state through this backtracking logic monad,
and use it to implement unification.

0 comments on commit ba9621f

Please sign in to comment.
Something went wrong with that request. Please try again.