Re: Vocabulary for finding libraries
Lassi Kortela 26 Oct 2022 21:40 UTC
> (at srfi
> (union (at 1
> (union (library "srfi/1.sld")
> (at lists (library "srfi/1/lists.sld"))))
> (at 13
> (union (library "srfi/13.sld")
> (at strings (library "srfi/13/strings.sld"))))))
;; Adding an alias-relative facility:
(at srfi
(union (at 1
(union (library "srfi/1.sld")
(at lists (alias-relative ..))))
(at :1
(alias-relative 1))
(at 13
(union (library "srfi/13.sld")
(at strings (alias-relative ..))))
(at :13
(alias-relative 13))))
;; Or mixing high and low level stuff:
(at srfi
(union (using-convention ".sld" (directory "/path/to/srfi"))
(at 1 (at lists (alias-relative ..)))
(at 13 (at strings (alias-relative ..)))))
;; It's an open question how much of the pure subset of Scheme to
;; import into the DSL if you want to express more complex rules:
(at srfi
(union (using-convention ".sld" (directory "/path/to/srfi"))
(union-map (lambda (number name)
`(at ,number (at ,name (alias-relative ..))))
'(1 13)
'(lists strings))))
;; Note that directly nested unions are flattened:
;;
;; (union (union a b) c) = (union a b c)
;; For deployment, you could skip the filesystem and ship an entire
;; set of libraries using just the DSL:
(at srfi
(union
(at 219
(union
(library-contents
(define-library (srfi 219)
(export define)
(import (rename (scheme base) (define native-define)))
(begin (define-syntax define
(syntax-rules ()
((define ((head . outer-args) . args) . body)
(define (head . outer-args) (lambda args .
body)))
((define head . body)
(native-define head . body)))))))
(at define (alias-relative ..))))
(at 236
(union
(library-contents
(define-library (srfi 236)
(export independently)
(import (scheme base))
(begin
(define-syntax independently
(syntax-rules ()
((independently expr ...)
(independently-aux (expr ...)))))
(define-syntax independently-aux
(syntax-rules ()
((independently-aux () (expr tmp) ...)
(let ((tmp (begin expr #f)) ...) (values)))
((independently-aux (expr . exprs) . binds)
(independently-aux exprs (expr tmp) . binds)))))))
(at independently (alias-relative ..))))))