[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/08: monads: Micro-optimize 'foldm'.
From: |
David Craven |
Subject: |
04/08: monads: Micro-optimize 'foldm'. |
Date: |
Fri, 6 Jan 2017 11:16:03 +0000 (UTC) |
dvc pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit a15357c743c7384cc18685d79acdb65db4f57c53
Author: Ludovic Courtès <address@hidden>
Date: Sat Apr 4 17:58:41 2015 +0200
monads: Micro-optimize 'foldm'.
* guix/monads.scm (foldm): Hoist 'monad-bind' and 'monad-return' calls
outside of the loop. Use explicit >>= instead of 'mlet*', and
explicit return instead of 'with-monad' + 'return'.
---
guix/monads.scm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/guix/monads.scm b/guix/monads.scm
index 0b0ad23..8a0f974 100644
--- a/guix/monads.scm
+++ b/guix/monads.scm
@@ -266,7 +266,9 @@ MONAD---i.e., return a monadic function in MONAD."
(foldm %state-monad (lift2 cons %state-monad) '() '(a b c))
=> '(c b a) ;monadic
"
- (with-monad monad
+ ;; Hoist access to MONAD's 'bind' and 'return' fields outside of the loop.
+ (let ((>>= (monad-bind monad))
+ (return (monad-return monad)))
(let loop ((lst lst)
(result init))
(match lst
- branch wip-build-systems-gexp created (now 58fee7f), David Craven, 2017/01/06
- 03/08: gexp: Micro-optimize sexp serialization., David Craven, 2017/01/06
- 05/08: tests: Add 'test-assertm' to (guix tests)., David Craven, 2017/01/06
- 01/08: gnu: bootstrap: Move 'use-modules' forms to the beginning of build expressions., David Craven, 2017/01/06
- 04/08: monads: Micro-optimize 'foldm'.,
David Craven <=
- 06/08: packages: Turn 'bag->derivation' into a monadic procedure., David Craven, 2017/01/06
- 08/08: DRAFT gexp: Handle list conversion to <gexp-input> in the expanded code., David Craven, 2017/01/06
- 07/08: store: Add a functional object cache and use it in 'lower-object'., David Craven, 2017/01/06
- 02/08: build-system: Rewrite using gexps., David Craven, 2017/01/06