shen-minikanren
shen-minikanren copied to clipboard
An embedding of miniKanren in Shen.
#+TITLE: shen-minikanren #+AUTHOR: Mark Thom #+EMAIL: [email protected]
- A Shen implementation of miniKanren #+ATTR_HTML: align=center
shen-minikanren is a [[http://www.shenlanguage.org][Shen]] implementation of [[http://minikanren.org][miniKanren]], an embedded DSL for logic programming. It was adapted with Will Byrd's Scheme [[http://github.com/miniKanren/TheReasonedSchemer/][sources]], which follow the definition of miniKanren given in the appendix of The Reasoned Schemer.
shen-minikanren integrates seamlessly into Shen's type system. This form (example 1.54 in The Reasoned Schemer) type checks as:
#+BEGIN_SRC shen (60+) (run* R (fresh (X Y) (conde ((=== split X) (=== pea Y)) ((=== navy X) (=== bean Y)) (else mk-fail)) (=== [X Y] R))) [[split pea] [navy bean]] : (list (walkable symbol)) #+END_SRC
The files that make up the implementation should be loaded into a Shen REPL in this order:
- macros.shen (with tc -)
- types.shen (with tc +)
- minikanren.shen (with tc +)
- prelude.shen (with tc +)
Examples are given in tests.shen and prelude.shen, all of which come from The Reasoned Schemer and Will Byrd's sources.