Skip to content
Hy on Adderall - a miniKanren implementation in Hy
Branch: master
Clone or download
algernon Merge pull request #15 from brandonwillard/fix-conspair-iter
Fix results of __iter__ for ConsPair
Latest commit a94ab60 Oct 11, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
adderall Moved `cons` code into `ConsPair.__new__` Oct 5, 2018
bin bin/adderall.hy: Update to Hy master syntax too Oct 5, 2015
tests Fix results of __iter__ for ConsPair Oct 4, 2018
.gitignore Fix package module loading in Python Sep 26, 2018
.travis.yml Use nose to run benchmarks Sep 26, 2018
GPL Switch license from GPLv3+ to LGPLv3+ Jan 19, 2014
LGPL
NEWS Start adding 2.0.0 NEWS Jun 25, 2015
README.md Update example in README Aug 5, 2018
requirements.txt Update to run on latest Hy master Oct 5, 2015
setup.py Enforce Python >= 3.4 in setup.py Oct 1, 2018

README.md

Adderall

Build Status Downloads Version

This library contains an implementation of miniKanren in Hy. It is a naive implementation, speed isn't the primary concern.

Example

(import [adderall.dsl [*]])
(require adderall.dsl)

(run* [q] (condᵉ [( q 'tea)]
                 [( q 'coffee) succeed]))
;; => ['tea 'coffee]

(run* [q] (condᵉ [( q 'tea)]
                 [( q 'coffee) fail]))
;; => ['tea]

(import [getpass [getuser]])

(deftag h [_] "#hy")
(defn lovesᵒ [u v] ( v #h y))
(run* [who what] (lovesᵒ who what)
                 ( who (getuser))
                 ( what #h y))
;; => [['algernon' '#hy']]

More examples can be found in the test suite, and in particular, the tests adapted from The Reasoned Schemer.

Adderall also comes with a set of extra functions, which are there mostly to show the power of the system, or for fun:

(import [adderall.dsl [*]]
        [adderall.extra.zebra [*]])
(require adderall.dsl)
(require adderall.extra.zebra)

(run* [water-drinker horse-owner] (zebraᵖ water-drinker horse-owner))
;; => [['norvegian 'japanese]]

For a practical use, see Hydiomatic, a static analyser and code transformer built upon Adderall, or wynck, a tool to reason about your window layout.

License

All the code is licensed under the GNU Lesser General Public License (v3+).

You can’t perform that action at this time.