mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 15:36:20 -05:00
monads, doc: Improve mwhen and munless documentation.
* doc/guix.texi (The Store Monad) <mwhen, munless>: Document them. * guix/monads.scm (mwhen, munless): Clarify their intended use. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
d922c8e4b7
commit
60a9fcb137
2 changed files with 22 additions and 4 deletions
|
@ -4054,6 +4054,20 @@ monadic expressions are ignored. In that sense, it is analogous to
|
|||
@code{begin}, but applied to monadic expressions.
|
||||
@end deffn
|
||||
|
||||
@deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
|
||||
When @var{condition} is true, evaluate the sequence of monadic
|
||||
expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
|
||||
@var{condition} is false, return @code{*unspecified*} in the current
|
||||
monad. Every expression in the sequence must be a monadic expression.
|
||||
@end deffn
|
||||
|
||||
@deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
|
||||
When @var{condition} is false, evaluate the sequence of monadic
|
||||
expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
|
||||
@var{condition} is true, return @code{*unspecified*} in the current
|
||||
monad. Every expression in the sequence must be a monadic expression.
|
||||
@end deffn
|
||||
|
||||
@cindex state monad
|
||||
The @code{(guix monads)} module provides the @dfn{state monad}, which
|
||||
allows an additional value---the state---to be @emph{threaded} through
|
||||
|
|
|
@ -204,8 +204,10 @@ (define-syntax mbegin
|
|||
|
||||
(define-syntax mwhen
|
||||
(syntax-rules ()
|
||||
"When CONDITION is true, evaluate MEXP0..MEXP* as in an 'mbegin'. When
|
||||
CONDITION is false, return *unspecified* in the current monad."
|
||||
"When CONDITION is true, evaluate the sequence of monadic expressions
|
||||
MEXP0..MEXP* as in an 'mbegin'. When CONDITION is false, return *unspecified*
|
||||
in the current monad. Every expression in the sequence must be a monadic
|
||||
expression."
|
||||
((_ condition mexp0 mexp* ...)
|
||||
(if condition
|
||||
(mbegin %current-monad
|
||||
|
@ -214,8 +216,10 @@ (define-syntax mwhen
|
|||
|
||||
(define-syntax munless
|
||||
(syntax-rules ()
|
||||
"When CONDITION is false, evaluate MEXP0..MEXP* as in an 'mbegin'. When
|
||||
CONDITION is true, return *unspecified* in the current monad."
|
||||
"When CONDITION is false, evaluate the sequence of monadic expressions
|
||||
MEXP0..MEXP* as in an 'mbegin'. When CONDITION is true, return *unspecified*
|
||||
in the current monad. Every expression in the sequence must be a monadic
|
||||
expression."
|
||||
((_ condition mexp0 mexp* ...)
|
||||
(if condition
|
||||
(return *unspecified*)
|
||||
|
|
Loading…
Reference in a new issue