[plt-scheme] question from a newbie regarding the import of a library

From: Jon Loldrup (loldrup at gmail.com)
Date: Sun Apr 5 03:23:25 EDT 2009

Well it sure does evaluate successfully now, and testing the first 4
expressions on page 4 in "The Reasoned Schemer" makes them all return the
same value as the ones in that book. Only thing is, the book doesn't mention
the definitions of fail and succeed (only that they are longs for #u and
#s), so I'm not sure whether this solution is some crude hack or the
official way to do it.

Now this code:

#lang scheme
(require (planet dfriedman/miniKanren:1:1/minikanren))
(define succeed (== #t #t))
(define fail (== #t #f))
(run #f (q) fail)
(run #f (q) (== #t q))
(run #f (q) fail (== #t q))
(run #f (q) succeed (== #t q))

returns this:

()
(#t)
()
(#t)


Jon Loldrup


2009/4/5 Ben Goetter <goetter at mazama.net>

> Jon Loldrup wrote:
>
>>
>> [...] the third line was taken from the file mktests.scm <
>> http://kanren.cvs.sourceforge.net/viewvc/kanren/kanren/mini/mktests.scm?revision=1.6&view=markup>
>> which I think is designed to test a minikanren implementation.
>>
> That file tests the particular version of minikanren currently on
> Sourceforge, which is not the same as the version on PLaneT.  You cannot
> necessarily mix and match the two.  Still, (run #f (q) fail) seems like a
> reasonable command to issue... isn't that out of the book?
>
> Inspecting minikanren.ss reveals that, indeed, it doesn't export any
> "fail."  The mk.scm on Sourceforge includes the following two definitions
>
> (define succeed (lambdag@ (s) (unit s)))
> (define fail (lambdag@ (s) (mzero)))
>
> which you can't issue yourself, because the version on PLaneT exports
> neither lambdag@ nor mzero.  Try instead
>
> #lang scheme
> (require (planet dfriedman/miniKanren:1:1/minikanren))
> (define succeed (== #t #t))
> (define fail (== #t #f))
> (run #f (q) fail)
>
> That seems to fail correctly.  I don't have my copy of TRS at hand, so I
> can't opine further.
>
> Hope that helps,
> Ben
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090405/34b78124/attachment.html>

Posted on the users mailing list.