Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ bin
*~
*.\#*
*\#*\#
.idea
/project/project/target/
/project/target/
/js/
/jvm/target/
project/project/
target/
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See http://about.travis-ci.org/docs/user/build-configuration/
# use Docker-based container (instead of OpenVZ)
sudo: false

cache:
directories:
- $HOME/.m2/repository
- $HOME/.sbt
- $HOME/.ivy2

before_cache:
# Cleanup the cached directories to avoid unnecessary cache updates
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
- find $HOME/.sbt -name "*.lock" -print -delete

language: scala
jdk:
- oraclejdk8
scala:
- 2.10.6
- 2.11.8
- 2.12.1
notifications:
email: false
# webhooks:
# urls:
# on_success: always # options: [always|never|change] default: always
# on_failure: always # options: [always|never|change] default: always
# on_start: false # default: false
script:
- sbt ++$TRAVIS_SCALA_VERSION clean coverage test miniKanrenJVM/tut coverageReport &&
sbt coverageAggregate
after_success:
- sbt coveralls
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ AUTHORS
=======

Michel Alexandre Salim <[email protected]>
Gabor Bakos
26 changes: 0 additions & 26 deletions Makefile

This file was deleted.

32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
A Scala port of [miniKanren](http://minikanren.org/)
====================================================

[![Build Status](https://travis-ci.org/aborg0/minikanren-scala.svg?branch=sbt)](https://travis-ci.org/aborg0/minikanren-scala)
[![Coverage Status](https://coveralls.io/repos/github/aborg0/minikanren-scala/badge.svg?branch=sbt)](https://coveralls.io/github/aborg0/minikanren-scala?branch=sbt)

Based on https://github.com/michel-slm/minikanren-scala

Please check the documentation in [docs/presentation.rst](docs/presentation) for details.

Using REPL with SBT:

> miniKanrenJVM/console

...

scala> time(run(1, x)(solve_puzzle(x)))
res0: (Long, Any) = (10044,List(List(9567, 1085, 10652)))

Interpretation of the result: took `10044` milliseconds to solve the problem, a result is

SEND 9567
+MORE +1085
----- -----
MONEY 10652

Another example (palindromes with six-digit numbers that are the product of two three-digit numbers), this time with `maprun` as it is much faster:

time(maprun(1, x)(palprod_o(x)))
100001
101101
res1: (Long, Any) = (40837,List((1,(1,(1,(0,(0,(1,(1,(1,(1,(1,(0,(0,(0,(1,List()))))))))))))))))
90 changes: 90 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
enablePlugins(ScalaJSPlugin)

name := "Scala MiniKanren root project"
crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1")
scalaVersion in ThisBuild := "2.12.1" // or any other Scala version >= 2.10.2 for Scala.js

// This is an application with a main method
scalaJSUseMainModuleInitializer := true

lazy val root = project.in(file(".")).
aggregate(miniKanrenJS, miniKanrenJVM).
settings(
publish := {},
publishLocal := {}
)

lazy val miniKanren = crossProject.in(file(".")).
settings(
name := "Scala MiniKanren",
version := "0.1-SNAPSHOT",
libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.13.4" % "test",

scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-unchecked",
"-feature",
//"-language:implicitConversions",
//"-language:postfixOps",
//"-language:higherKinds",
//"-language:reflectiveCalls",
"-Xlint",
// "-Xfatal-warnings",
//"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
)

).jvmSettings(
coverageEnabled := true,
initialCommands := """
|import info.hircus.kanren.MiniKanren._
|import info.hircus.kanren.Prelude._
|import info.hircus.kanren.MKMath._
|import info.hircus.kanren.examples.PalProd._
|import info.hircus.kanren.examples.SendMoreMoney._
|
|var x = make_var('x)
|var y = make_var('y)
|var z = make_var('z)
|
|def time(block: => Any) = {
| val start = System currentTimeMillis ()
| val res = block
| val stop = System currentTimeMillis ()
| ((stop-start), res)
|}
|
|def ntimes(n: Int, block: => Any) = {
| // folding a list of Longs is cumbersome
| def adder(x:Long,y:Long) = x+y
| val zero : Long = 0
|
| // compute only once!
| val res = (for (i <- 0 until n) yield (time(block) _1)).toList
| println("Elapsed times: " + res)
| println("Avg: " + (res.foldLeft(zero)(adder) / n))
|}
|""".stripMargin,
tutSettings
).jsSettings(
coverageEnabled := false
)

lazy val miniKanrenJVM = miniKanren.jvm

lazy val miniKanrenJS = miniKanren.js

//tutSettings

//tutSourceDirectory := baseDirectory.value / "shared" / "src" / "main" / "tut"

LaikaPlugin.defaults

inConfig(LaikaKeys.Laika)(Seq(
// sourceDirectories := Seq(baseDirectory.value / "docs"),
LaikaKeys.encoding := "UTF-8"
))
6 changes: 0 additions & 6 deletions check.sh

This file was deleted.

2 changes: 0 additions & 2 deletions docs/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions docs/Makefile

This file was deleted.

Loading