diff --git a/guix/store.scm b/guix/store.scm index d3e94625a7e0cd24eef17d6266ebfe31fd8d2092..82ed94bbc10cea9e1d5247c43c4ee975a6e8db91 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -99,6 +99,7 @@ (define-module (guix store) store-bind store-return store-lift + store-lower run-with-store %guile-for-build text-file @@ -881,6 +882,12 @@ (define result (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 cb5370d5ccad7c8af08b642c7929511c70015e6b..f43fcb14d00917f9b4d753939a389a5adcebc1b8 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 <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -595,6 +595,12 @@ (define (same? x y) (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")