[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/04: store: Add 'store-lower'.
From: |
Ludovic Courtès |
Subject: |
03/04: store: Add 'store-lower'. |
Date: |
Wed, 14 Jan 2015 13:46:04 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit 023d9892c0411adb523e6bc8337be3e7e94e606f
Author: Ludovic Courtès <address@hidden>
Date: Wed Jan 14 14:25:58 2015 +0100
store: Add 'store-lower'.
* guix/store.scm (store-lower): New procedure.
* tests/store.scm ("store-lower"): New test.
---
guix/store.scm | 7 +++++++
tests/store.scm | 8 +++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/guix/store.scm b/guix/store.scm
index d3e9462..82ed94b 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -99,6 +99,7 @@
store-bind
store-return
store-lift
+ store-lower
run-with-store
%guile-for-build
text-file
@@ -881,6 +882,12 @@ in the store monad."
(procedure-property proc 'documentation))
result)
+(define (store-lower proc)
+ "Lower PROC, a monadic procedure in %STORE-MONAD, to a \"normal\" procedure
+taking the store as its first argument."
+ (lambda (store . args)
+ (run-with-store store (apply proc args))))
+
;;
;; Store monad operators.
;;
diff --git a/tests/store.scm b/tests/store.scm
index cb5370d..f43fcb1 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <address@hidden>
+;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -595,6 +595,12 @@ Deriver: ~a~%"
(null? (valid-derivers %store file))
(null? (referrers %store file))))))
+(test-equal "store-lower"
+ "Lowered."
+ (let* ((add (store-lower text-file))
+ (file (add %store "foo" "Lowered.")))
+ (call-with-input-file file get-string-all)))
+
(test-end "store")