From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cw3k0-0001IY-CJ for guix-patches@gnu.org; Thu, 06 Apr 2017 05:30:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cw3jv-00020o-Fb for guix-patches@gnu.org; Thu, 06 Apr 2017 05:30:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36274) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cw3jv-00020g-Bl for guix-patches@gnu.org; Thu, 06 Apr 2017 05:30:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cw3jv-00063c-5u for guix-patches@gnu.org; Thu, 06 Apr 2017 05:30:03 -0400 Subject: bug#26382: [PATCH 2/3] monads, doc: Improve mwhen and munless documentation. Resent-Message-ID: From: Chris Marusich Date: Thu, 6 Apr 2017 02:28:35 -0700 Message-Id: <20170406092836.24766-2-cmmarusich@gmail.com> In-Reply-To: <20170406092836.24766-1-cmmarusich@gmail.com> References: <20170406091546.24107-1-cmmarusich@gmail.com> <20170406092836.24766-1-cmmarusich@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 26382@debbugs.gnu.org Cc: Chris Marusich * doc/guix.texi ((guix) The Store Monad) : 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