From: Chris Marusich <cmmarusich@gmail.com>
To: 26382@debbugs.gnu.org
Cc: Chris Marusich <cmmarusich@gmail.com>
Subject: bug#26382: [PATCH 2/3] monads, doc: Improve mwhen and munless documentation.
Date: Thu, 6 Apr 2017 02:28:35 -0700 [thread overview]
Message-ID: <20170406092836.24766-2-cmmarusich@gmail.com> (raw)
In-Reply-To: <20170406092836.24766-1-cmmarusich@gmail.com>
* doc/guix.texi ((guix) The Store Monad) <mwhen, munless>: Document them.
* guix/monads.scm (mwhen, munless): Clarify their intended use.
---
doc/guix.texi | 14 ++++++++++++++
guix/monads.scm | 12 ++++++++----
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index aa779e38e..a1aae8f6c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4027,6 +4027,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
diff --git a/guix/monads.scm b/guix/monads.scm
index 6933f7f15..fe3d5d78f 100644
--- a/guix/monads.scm
+++ b/guix/monads.scm
@@ -204,8 +204,10 @@ the last one."
(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 @@ CONDITION is false, return *unspecified* in the current monad."
(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*)
--
2.12.0
next prev parent reply other threads:[~2017-04-06 9:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 9:15 bug#26382: [PATCH 0/3] Improve documentation for monads Chris Marusich
2017-04-06 9:28 ` bug#26382: [PATCH 1/3] monads: Use intent-revealing parameter names Chris Marusich
2017-04-06 9:28 ` Chris Marusich [this message]
2017-04-08 12:31 ` bug#26382: [PATCH 2/3] monads, doc: Improve mwhen and munless documentation Ludovic Courtès
2017-04-06 9:28 ` bug#26382: [PATCH 3/3] monads: Improve mlet, mlet*, and mbegin documentation Chris Marusich
2017-04-08 12:36 ` Ludovic Courtès
2017-04-08 12:30 ` bug#26382: [PATCH 1/3] monads: Use intent-revealing parameter names Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170406092836.24766-2-cmmarusich@gmail.com \
--to=cmmarusich@gmail.com \
--cc=26382@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.