Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Donham committed May 3, 2011
1 parent 077db11 commit ba9621f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _code/scala-logic/Bridge.scala
@@ -1,4 +1,4 @@
class Bridge(val Logic: Logic) { class Bridge[L <: Logic](val Logic: L) {
import Logic._ import Logic._


object Person extends Enumeration { object Person extends Enumeration {
Expand Down
28 changes: 28 additions & 0 deletions _posts/2011-04-06-logic-programming-in-scala.markdown
Expand Up @@ -510,3 +510,31 @@ scala> run[List[b.State]](LogicList, b, b.search, 2)
run[List[b.State]](LogicList, b, b.search, 2) run[List[b.State]](LogicList, b, b.search, 2)
^ ^
{% endhighlight %} {% 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.
5 changes: 4 additions & 1 deletion _posts/2011-04-29-logic-programming-in-scala-2.markdown
Expand Up @@ -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 `a` was generated (which succeeds with the next available alternative
from `f(a)`). 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 rather than a choice of alternatives: we succeed immediately with the
returned value. returned value.


Expand Down Expand Up @@ -566,5 +566,8 @@ scala> run(nat, 100000)
^C ^C
{% endhighlight %} {% 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, Next time we'll thread state through this backtracking logic monad,
and use it to implement unification. and use it to implement unification.

0 comments on commit ba9621f

Please sign in to comment.