guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

38/66: doc: Fix dangling references in the 'sh-symlink' monad example.


From: Manolis Fragkiskos Ragkousis
Subject: 38/66: doc: Fix dangling references in the 'sh-symlink' monad example.
Date: Thu, 21 May 2015 12:52:01 +0000

phant0mas pushed a commit to branch wip-hurd
in repository guix.

commit e6f7b207ef72ee98b1dabe653b9a7798da9ba1b2
Author: Ludovic Court├Ęs <address@hidden>
Date:   Mon May 4 15:05:13 2015 +0200

    doc: Fix dangling references in the 'sh-symlink' monad example.
    
    Reported by Christopher A. Webber <address@hidden>.
    
    * doc/guix.texi (The Store Monad): Reintroduce 'mlet' in 'sh-symlink'
      example.  Move the simplified version below.  Explain that the 'store'
      parameter is threaded.
---
 doc/guix.texi |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index dea1415..d9db408 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -2346,21 +2346,34 @@ Consider this ``normal'' procedure:
                                   `(symlink ,sh %output))))
 @end example
 
-Using @code{(guix monads)}, it may be rewritten as a monadic function:
+Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
+as a monadic function:
 
address@hidden FIXME: Find a better example, one that uses 'mlet'.
 @example
 (define (sh-symlink)
   ;; Same, but return a monadic value.
-  (gexp->derivation "sh"
-                    #~(symlink (string-append #$bash "/bin/bash") #$output)))
+  (mlet %store-monad ((drv (package->derivation bash)))
+    (gexp->derivation "sh"
+                      #~(symlink (string-append #$drv "/bin/bash")
+                                 #$output))))
 @end example
 
-There are two things to note in the second version: the @code{store}
-parameter is now implicit, and the monadic value returned by
address@hidden wrapper around @code{package-derivation} and
address@hidden>output-path}---is @dfn{bound} using @code{mlet}
-instead of plain @code{let}.
+There several things to note in the second version: the @code{store}
+parameter is now implicit and is ``threaded'' in the calls to the
address@hidden>derivation} and @code{gexp->derivation} monadic
+procedures, and the monadic value returned by @code{package->derivation}
+is @dfn{bound} using @code{mlet} instead of plain @code{let}.
+
+As it turns out, the call to @code{package->derivation} can even be
+omitted since it will take place implicitly, as we will see later
+(@pxref{G-Expressions}):
+
address@hidden
+(define (sh-symlink)
+  (gexp->derivation "sh"
+                    #~(symlink (string-append #$bash "/bin/bash")
+                               #$output)))
address@hidden example
 
 Calling the monadic @code{sh-symlink} has no effect.  To get the desired
 effect, one must use @code{run-with-store}:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]