6.3.90.900
kw-make-struct
(require kw-make-struct) | package: kw-make-struct |
source code: https://github.com/AlexKnauth/kw-make-struct
syntax
(make/kw struct-id field ...)
(make/kw struct-id field-pat ...)
field = expr | field-keyword expr field-pat = pat | field-keyword pat
like make from unstable/struct, except allowing keywords.
make/kw is also defined as a match expander.
Examples:
> (require kw-make-struct racket/match)
> (struct foo (a b c) #:transparent)
> (make/kw foo 'a 'b 'c) (foo 'a 'b 'c)
> (make/kw foo #:a 'a #:b 'b #:c 'c) (foo 'a 'b 'c)
> (make/kw foo #:a 'a 'b 'c) (foo 'a 'b 'c)
> (make/kw foo #:c 'c 'a #:b 'b) (foo 'a 'b 'c)
> (match (foo 'a 'b 'c) [(make/kw foo #:a a #:b b #:c c) (list a b c)]) '(a b c)