[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/07: monads: Micro-optimize 'foldm'.
From: |
Ludovic Courtès |
Subject: |
04/07: monads: Micro-optimize 'foldm'. |
Date: |
Fri, 20 Nov 2015 22:39:01 +0000 |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 5f297a0569b0b482c7d2d075544a06e02e0db668
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 files changed, 3 insertions(+), 1 deletions(-)
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 4c2ade2), Ludovic Courtès, 2015/11/20
- 01/07: gnu: bootstrap: Move 'use-modules' forms to the beginning of build expressions., Ludovic Courtès, 2015/11/20
- 03/07: gexp: Micro-optimize sexp serialization., Ludovic Courtès, 2015/11/20
- 04/07: monads: Micro-optimize 'foldm'.,
Ludovic Courtès <=
- 05/07: tests: Add 'test-assertm' to (guix tests)., Ludovic Courtès, 2015/11/20
- 06/07: packages: Turn 'bag->derivation' into a monadic procedure., Ludovic Courtès, 2015/11/20
- 07/07: store: Add a functional object cache and use it in 'lower-object'., Ludovic Courtès, 2015/11/20
- 02/07: build-system: Rewrite using gexps., Ludovic Courtès, 2015/11/20