Skip to content

Commit

Permalink
Upgrade to Elm 0.18 and move repository
Browse files Browse the repository at this point in the history
A salted-earth approach to package resolution woes.

Package version is reset to v1.0.0 to indulge elm-package.
  • Loading branch information
tapeinosyne committed Nov 21, 2016
1 parent 60ea4ae commit cf2156e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions elm-package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.1",
"version": "1.0.0",
"summary": "A minimal functional core for relational programming",
"repository": "https://github.com/tapeinosyne/elm-microkanren.git",
"license": "BSD3",
Expand All @@ -11,7 +11,7 @@
"MicroKanren.Operators"
],
"dependencies": {
"elm-lang/core": "4.0.0 <= v < 5.0.0"
"elm-lang/core": "5.0.0 <= v < 6.0.0"
},
"elm-version": "0.17.0 <= v < 0.18.0"
}
"elm-version": "0.18.0 <= v < 0.19.0"
}
20 changes: 10 additions & 10 deletions src/MicroKanren.elm
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,23 @@ potentially extending it.
- `LVal` values unify when they are equivalent under Elm's native `(==)`.
`s` is returned unchanged.
- Pairs unify when their terms unify pairwise.
- Finally, an `LVar` variable and an `LVal` value unify under an extended substitution `s'`,
- Finally, an `LVar` variable and an `LVal` value unify under an extended substitution `s1`,
where they form a new binding.
If unification fails, `Nothing` is returned.
-}
unify : Term a -> Term a -> Substitution a -> Maybe (Substitution a)
unify u v s =
let u' = walk u s
v' = walk v s
let u1 = walk u s
v1 = walk v s
in
case (u', v') of
case (u1, v1) of
(LVar n, LVar m) -> if n == m then Just s else Nothing
(LVal x, LVal y) -> if x == y then Just s else Nothing
(LVar n, _) -> Just (extend n v' s)
(_, LVar m) -> Just (extend m u' s)
(LVar n, _) -> Just (extend n v1 s)
(_, LVar m) -> Just (extend m u1 s)
(Pair x y, Pair x1 y1) -> case unify x x1 s of
Just s' -> unify y y1 s'
Just s1 -> unify y y1 s1
Nothing -> Nothing
_ -> Nothing

Expand Down Expand Up @@ -153,7 +153,7 @@ bind s g =
identical : Term a -> Term a -> Goal a
identical u v =
\sc -> case unify u v sc.s of
Just s' -> unit { sc | s = s' }
Just s1 -> unit { sc | s = s1 }
Nothing -> mzero

{-| Create a goal which introduces a new logic variable for use by another goal. -}
Expand All @@ -167,12 +167,12 @@ callFresh f =
Effectively a binary disjunction of goals. -}
disjoin : Goal a -> Goal a -> Goal a
disjoin g1 g2 =
\sc -> g1 sc `mplus` g2 sc
\sc -> mplus (g1 sc) (g2 sc)

{-| Create a goal which succeeds if the second goal is achievable within the stream
generated by the first goal.
Effectively a binary conjunction of goals. -}
conjoin : Goal a -> Goal a -> Goal a
conjoin g1 g2 =
\sc -> g1 sc `bind` g2
\sc -> bind (g1 sc) g2

0 comments on commit cf2156e

Please sign in to comment.