Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Created July 19, 2011 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frenchy64/1091495 to your computer and use it in GitHub Desktop.
Save frenchy64/1091495 to your computer and use it in GitHub Desktop.
(ns logic-introduction.core
(:refer-clojure :exclude [inc reify ==])
(:use [clojure.core.logic minikanren prelude nonrel match disequality]))
(defn geto [key env value]
(matche [env]
([[[key :- value] . _]])
([[_ . ?rest]] (geto key ?rest value))))
(defn typedo [context exp resulttype]
(conde
((geto exp context resulttype))
((matche [context exp resulttype]
([_ [:apply ?fun ?arg] _]
(exist [argtype]
(!= ?fun ?arg)
(typedo context ?arg argtype)
(typedo context ?fun [argtype :> resulttype])))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment