Use 'mlambda' instead of 'memoize'.

* gnu/packages.scm (find-newest-available-packages): Use 'mlambda'
instead of (memoize (lambda ...) ...).
* gnu/packages/bootstrap.scm (package-with-bootstrap-guile): Likewise.
* guix/build-system/gnu.scm (package-with-explicit-inputs)[rewritten-input]:
Likewise.
* guix/build-system/python.scm (package-with-explicit-python)[transform]:
Likewise.
* guix/derivations.scm (derivation->string): Likewise.
* guix/gnu-maintenance.scm (gnu-package?): Likewise.
* guix/modules.scm (module-file-dependencies): Likewise.
* guix/scripts/graph.scm (standard-package-set): Likewise.
* guix/scripts/lint.scm (official-gnu-packages*): Likewise.
* guix/store.scm (store-regexp*): Likewise.
* guix/utils.scm (location): Likewise.
This commit is contained in:
Ludovic Courtès 2017-01-28 17:09:34 +01:00
parent f9704f179a
commit 55b2d92145
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
11 changed files with 204 additions and 216 deletions

View file

@ -87,49 +87,48 @@ pre-defined variants."
;; Memoize the transformations. Failing to do that, we would build a huge
;; object graph with lots of duplicates, which in turns prevents us from
;; benefiting from memoization in 'package-derivation'.
(memoize ;FIXME: use 'eq?'
(lambda (p)
(let* ((rewrite-if-package
(lambda (content)
;; CONTENT may be a file name, in which case it is returned,
;; or a package, which is rewritten with the new PYTHON and
;; NEW-PREFIX.
(if (package? content)
(transform content)
content)))
(rewrite
(match-lambda
((name content . rest)
(append (list name (rewrite-if-package content)) rest)))))
(mlambda (p) ;XXX: use 'eq?'
(let* ((rewrite-if-package
(lambda (content)
;; CONTENT may be a file name, in which case it is returned,
;; or a package, which is rewritten with the new PYTHON and
;; NEW-PREFIX.
(if (package? content)
(transform content)
content)))
(rewrite
(match-lambda
((name content . rest)
(append (list name (rewrite-if-package content)) rest)))))
(cond
;; If VARIANT-PROPERTY is present, use that.
((and variant-property
(assoc-ref (package-properties p) variant-property))
=> force)
(cond
;; If VARIANT-PROPERTY is present, use that.
((and variant-property
(assoc-ref (package-properties p) variant-property))
=> force)
;; Otherwise build the new package object graph.
((eq? (package-build-system p) python-build-system)
(package
(inherit p)
(location (package-location p))
(name (let ((name (package-name p)))
(string-append new-prefix
(if (string-prefix? old-prefix name)
(substring name
(string-length old-prefix))
name))))
(arguments
(let ((python (if (promise? python)
(force python)
python)))
(ensure-keyword-arguments (package-arguments p)
`(#:python ,python))))
(inputs (map rewrite (package-inputs p)))
(propagated-inputs (map rewrite (package-propagated-inputs p)))
(native-inputs (map rewrite (package-native-inputs p)))))
(else
p))))))
;; Otherwise build the new package object graph.
((eq? (package-build-system p) python-build-system)
(package
(inherit p)
(location (package-location p))
(name (let ((name (package-name p)))
(string-append new-prefix
(if (string-prefix? old-prefix name)
(substring name
(string-length old-prefix))
name))))
(arguments
(let ((python (if (promise? python)
(force python)
python)))
(ensure-keyword-arguments (package-arguments p)
`(#:python ,python))))
(inputs (map rewrite (package-inputs p)))
(propagated-inputs (map rewrite (package-propagated-inputs p)))
(native-inputs (map rewrite (package-native-inputs p)))))
(else
p)))))
transform)