mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
monads: Allow resolution of a monad's bind/return at expansion time.
* guix/monads.scm (<monad>): Turn in a raw SRFI-9 record type.
(define-monad): New macro.
(with-monad): Add a case for when MONAD is a macro.
(identity-return, identity-bind, store-return, store-bind): Inline.
(%identity-monad, %store-monad): Use 'define-monad'.
* tests/monads.scm ("monad?"): New test.
This commit is contained in:
@@ -48,6 +48,11 @@
|
||||
|
||||
(test-begin "monads")
|
||||
|
||||
(test-assert "monad?"
|
||||
(and (every monad? %monads)
|
||||
(every (compose procedure? monad-bind) %monads)
|
||||
(every (compose procedure? monad-return) %monads)))
|
||||
|
||||
;; The 3 "monad laws": <http://www.haskell.org/haskellwiki/Monad_laws>.
|
||||
|
||||
(test-assert "left identity"
|
||||
|
||||
Reference in New Issue
Block a user