Skip to content

Latest commit

 

History

History
124 lines (96 loc) · 4.25 KB

nimikanren.org

File metadata and controls

124 lines (96 loc) · 4.25 KB

nimiKanren

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>

I’m pretty proud of the name.

I stumbled across Dr. Will Byrd’s work with relational logic programming this morning (17 February 2015). Fueled by sleep deprivation, caffeine, and dissatisfaction with my life, I have decided to learn miniKanren, DSLs, and Nim all in one go. The result will (hopefully) be an implementation of miniKanren, as described in Dr. Byrd’s dissertation on the subject, in Nim. First I have to finish reading (and understanding) said dissertation. Pieces of an implementation will be added to this file and the associated repository.

Package for Nimble.

The intent of the project is for it to be a library, so we have to construct a .nimble file to specify said library.

The only part of the [Package] section that changes is the version number.

[Package]
name         = "nimikanren"
version      = "0.3.0"
author       = "Jacob MacDonald"
description  = "Use miniKanren relational programming in Nim."
license      = "Unlicense"
installFiles = "nimikanren.nim"

The dependencies should not have to change that much. Just to be safe, nimiKanren depends on the development version of Nim, which I use.

[Deps]
Requires: "nim >= 0.10.3"

Represent logic variables.

miniKanren’s logic variables are simple, so they can be represented in Nim with a very simple type.

type
  LogicVar* = tuple
    name: string
suite "Represent logic variables.":
  test "Create a new LogicVar.":
    let x: LogicVar = (name: "x")
    check x.name == "x"
  test "Compare LogicVars.":
    let x1: LogicVar = (name: "x")
    let x2: LogicVar = (name: "x")
    let y1: LogicVar = (name: "y")
    check x1 == x2
    check x1 != y1

Tangle source code.

src/nimikanren.nimble

<<nimikanren.nimble-package>>

<<nimikanren.nimble-deps>>

nimikanren.nim

<<nimikanren.nim-LogicVar>>

Run unit tests.

As you may have noticed, each code snippet above has an accompanying bit of unit test. This section puts these tests in files so they can be run. To run all tests, just nim c -r tests/all.

In case the package has not been installed globally, make sure the test files know where to find the code they want to test.

path = "$projectPath/../src"
import unittest
import nimikanren

<<test-LogicVar>>