mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 13:49:23 -05:00
monads: Fix 'liftN' fallback case.
Reported by Andy Wingo <wingo@igalia.com>. * guix/monads.scm (define-lift) <fallback case>: Add missing #'. Remove extra formal parameter. * tests/monads.scm ("lift"): Add test with 'lift1' as a procedure.
This commit is contained in:
parent
3b6eddb2b2
commit
dbbc248aee
2 changed files with 7 additions and 5 deletions
|
@ -239,10 +239,10 @@ (define-syntax liftn
|
|||
(identifier? #'id)
|
||||
;; Slow path: Return a closure-returning procedure (we don't
|
||||
;; guarantee (eq? LIFTN LIFTN), but that's fine.)
|
||||
(lambda (liftn proc monad)
|
||||
(lambda (args ...)
|
||||
(with-monad monad
|
||||
(return (proc args ...))))))))))))
|
||||
#'(lambda (proc monad)
|
||||
(lambda (args ...)
|
||||
(with-monad monad
|
||||
(return (proc args ...))))))))))))
|
||||
|
||||
(define-lift lift0 ())
|
||||
(define-lift lift1 (a))
|
||||
|
|
|
@ -95,10 +95,12 @@ (define (g x)
|
|||
|
||||
(test-assert "lift"
|
||||
(every (lambda (monad run)
|
||||
(let ((f (lift1 1+ monad)))
|
||||
(let ((f (lift1 1+ monad))
|
||||
(g (apply lift1 1+ (list monad))))
|
||||
(with-monad monad
|
||||
(let ((number (random 777)))
|
||||
(= (run (>>= (return number) f))
|
||||
(run (>>= (return number) g))
|
||||
(1+ number))))))
|
||||
%monads
|
||||
%monad-run))
|
||||
|
|
Loading…
Reference in a new issue