Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken with Guile Scheme 2.0.7 #2

Open
zilti opened this issue Aug 14, 2013 · 6 comments
Open

Broken with Guile Scheme 2.0.7 #2

zilti opened this issue Aug 14, 2013 · 6 comments

Comments

@zilti
Copy link

zilti commented Aug 14, 2013

Output from REPL:

scheme@(guile-user) [1]> (load "projects/logic/mk.scm")
scheme@(guile-user) [1]> (define f# fail)
scheme@(guile-user) [1]> (define s# succeed)
scheme@(guile-user) [1]> (run* (q) (== 1 q))
/home/zilti/projects/logic/mk.scm:216:2: In procedure subsume:
/home/zilti/projects/logic/mk.scm:216:2: In procedure module-lookup: Unbound variable: remp

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [2]> ,bt
In /home/zilti/projects/logic/mk.scm:
     69:7  4 (take #f #<procedure 2669f20 at <current input>:15:0 ()>)
In current input:
     15:0  3 (#<procedure 2669f20 at <current input>:15:0 ()>)
In /home/zilti/projects/logic/mk.scm:
   252:11  2 (#<procedure 2657ac0 at /home/zilti/projects/logic/mk.scm:247:4 (S+)> ((#(q) . 1)))
    305:6  1 (#<procedure 2668600 at /home/zilti/projects/logic/mk.scm:304:4 (A)> ())
    216:2  0 (subsume () ())
@webyrd
Copy link
Collaborator

webyrd commented Aug 15, 2013

Hi! Looks like remp isn't built into Guile.

(remp even? '(1 2 3 4 5)) => (1 3 5)

If you add this defn, do you get any other errors?

(define remp
(lambda (p ls)
(cond
((null? ls) '())
((p (car ls)) (remp p (cdr ls)))
(else (cons (car ls) (remp p (cdr ls)))))))

Thanks.

--Will

@drcz
Copy link

drcz commented Jan 25, 2014

Hi!
It seems that guile2.0 lacks remp, exists and call-with-string-output-port, and sort takes arguments in opposite order -- appending the following [re]definitions to mk should do the job:

(define (remp p ls)
(cond ((null? ls) '())
((p (car ls)) (remp p (cdr ls)))
(else (cons (car ls) (remp p (cdr ls))))))

(define (exists p ls)
(cond ((null? ls) #f)
((p (car ls)) #t)
(else (exists p (cdr ls)))))

(define sorter (lambda (ls) (sort ls lex<=?)))

(define datum->string
(lambda (x)
(with-output-to-string (lambda () (display x)))))

Cheers,
d.

@enn
Copy link

enn commented Aug 23, 2014

This is still broken in chicken scheme.

The fix provided works as long as you delete the original sorter (which uses those args backwards).

@webyrd
Copy link
Collaborator

webyrd commented Aug 24, 2014

Hmm. The version of Vicare Scheme I'm using doesn't even define 'sort', although the code works if 'sort' is defined to be 'list-sort'.

I wonder if implementation-specific preludes are a better way to handle these incompatibilities, as was done with earlier versions of full Kanren. Any thoughts?

@RubyTuesdayDONO
Copy link

+1 for preludes if they can reliably adapt miniKanren to specific implementations … so many fun things to do with guile!

@RubyTuesdayDONO
Copy link

better yet: can miniKanren somehow generate the translations needed to implement it for a given scheme engine, provided abstract definitions of the external functions it requires? for example, "i need a procedure remp such that (equal? (remp 'b '(a b c)) '(a c))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants