[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}:
- 19/66: gnu: acpica: Update to 20150410., (continued)
- 19/66: gnu: acpica: Update to 20150410., Manolis Fragkiskos Ragkousis, 2015/05/21
- 25/66: gnu: Add libe-book., Manolis Fragkiskos Ragkousis, 2015/05/21
- 23/66: gnu: rename (gnu packages socat) to (gnu packages networking)., Manolis Fragkiskos Ragkousis, 2015/05/21
- 26/66: doc: Replace reference to profile.sh with sh-symlink, Manolis Fragkiskos Ragkousis, 2015/05/21
- 27/66: gnu: Add totem-pl-parser., Manolis Fragkiskos Ragkousis, 2015/05/21
- 28/66: guix package: Move profile cleaning out of 'search-path-environment-variables'., Manolis Fragkiskos Ragkousis, 2015/05/21
- 29/66: guix package: Introduce 'evaluate-search-paths'., Manolis Fragkiskos Ragkousis, 2015/05/21
- 30/66: gnu: gcc-5.1: Add specific libvtv patch., Manolis Fragkiskos Ragkousis, 2015/05/21
- 24/66: gnu: Add zeromq., Manolis Fragkiskos Ragkousis, 2015/05/21
- 32/66: gnu: samtools: Install libbam.a library., Manolis Fragkiskos Ragkousis, 2015/05/21
- 38/66: doc: Fix dangling references in the 'sh-symlink' monad example.,
Manolis Fragkiskos Ragkousis <=
- 37/66: doc: Suggest 'groupadd --system'., Manolis Fragkiskos Ragkousis, 2015/05/21
- 34/66: gnu: Add taskwarrior., Manolis Fragkiskos Ragkousis, 2015/05/21
- 39/66: gnu: Add python-sympy., Manolis Fragkiskos Ragkousis, 2015/05/21
- 35/66: gnu: bamtools: Set rpath via LDFLAGS., Manolis Fragkiskos Ragkousis, 2015/05/21
- 33/66: gnu: Add samtools-0.1.19., Manolis Fragkiskos Ragkousis, 2015/05/21
- 31/66: gnu: samtools: Remove patch-makefile-curses phase., Manolis Fragkiskos Ragkousis, 2015/05/21
- 36/66: doc: Clarify installation from the binary tarball., Manolis Fragkiskos Ragkousis, 2015/05/21
- 43/66: substitute: Increase TTL from 24h to 36h., Manolis Fragkiskos Ragkousis, 2015/05/21
- 40/66: gnu: curl: Update to 7.42.1., Manolis Fragkiskos Ragkousis, 2015/05/21
- 44/66: gnu: Add markdown., Manolis Fragkiskos Ragkousis, 2015/05/21