34 Racket Module Operations
(require denxi/racket-module) | package: denxi |
procedure
(list/syntax? v) → boolean?
v : any/c
value
procedure
v : any/c
procedure
(racket-module-code? modlang v) → boolean?
modlang : symbol? v : any/c
procedure
(get-racket-module-body expected-lang code) → (or/c #f code/c)
expected-lang : (or/c #f symbol?) code : racket-module-variant/c
The return type value mirrors that of the input value type. That is, (list? code) implies (list? (get-racket-module-body #f code)).
procedure
(make-racket-module-datum [ #:id id] lang top-level) → list? id : symbol? = 'anon lang : symbol? top-level : list?
procedure
(coerce-datum code) → list?
code : code/c
procedure
(read-racket-module expected-reader-lang expected-module-lang variant) → (subprogram/c syntax?) expected-reader-lang : symbol? expected-module-lang : symbol? variant : racket-module-input-variant/c
If variant is an input port, read-racket-module will attempt to read code directly from variant.
If variant is a path, string, or byte string, then the behavior is equivalent to applying read-racket-module to an input port for the file, string content, or byte content respectively.
If variant is a list, then the behavior is equivalent to applying read-racket-module to an input port for (~s variant).
34.1 Stripping and Dressing
To strip a Racket module in code/c form is to convert it to a bare module. To dress the module is to do the reverse. Stripping and dressing are not inverse operations, because stripping does not preserve lexical and location information.
In the context of Denxi, programs are restricted to a small, fixed grammar and are subject to meaningful module-level overrides. This makes source location information meaningless in some cases, but lexical information remains constant. Denxi uses bare modules when only the content matters for code transformations.
struct
(struct bare-racket-module (name lang code) #:transparent) name : symbol? lang : symbol? code : list?
Each instance holds parts of a Racket module code without lexical information, source location information, or an implicit form for a module body such as #%plain-module-begin.
procedure
(strip module-datum) → bare-racket-module?
module-datum : code/c
> (equal? (strip #'(module anon racket/base (#%module-begin (define a 1) (provide a)))) (bare-racket-module 'anon 'racket/base '((define a 1) (provide a))))
procedure
stripped : bare-racket-module?
(make-racket-module-datum #:id (bare-racket-module-name stripped) (bare-racket-module-lang stripped) (bare-racket-module-code stripped))
34.2 Fetching Racket Modules in Package Definition
procedure
(keep-standalone-racket-module [ #:compile-with compile-with] name) → subprogram? compile-with : (or/c #f path-string?) = "raco" name : string?
If compile-with is not #f, it is used as the first argument to run for selecting a raco executable. Once the module is available, it is immediately compiled using the make subcommand.