use the struct-update package instead of alexis/util/struct (#277)
This commit is contained in:
parent
9600e57fee
commit
7274791b7d
5
info.rkt
5
info.rkt
|
@ -14,8 +14,9 @@
|
||||||
"unstable-list-lib"
|
"unstable-list-lib"
|
||||||
"unstable-contract-lib"
|
"unstable-contract-lib"
|
||||||
"fancy-app"
|
"fancy-app"
|
||||||
"alexis-util"
|
"syntax-classes-lib"
|
||||||
"sweet-exp"
|
"struct-update-lib"
|
||||||
|
"sweet-exp-lib"
|
||||||
"kw-make-struct"
|
"kw-make-struct"
|
||||||
"reprovide-lang"
|
"reprovide-lang"
|
||||||
"scribble-lib"))
|
"scribble-lib"))
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
(require racket/local
|
(require racket/local
|
||||||
syntax/parse/define
|
syntax/parse/define
|
||||||
alexis/util/struct
|
struct-update
|
||||||
"../base/main.rkt"
|
"../base/main.rkt"
|
||||||
(for-syntax racket/base
|
(for-syntax racket/base
|
||||||
syntax/parse
|
syntax/parse
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require syntax/parse/define
|
(require syntax/parse/define
|
||||||
alexis/util/struct
|
struct-update
|
||||||
racket/provide-syntax
|
racket/provide-syntax
|
||||||
"../base/main.rkt"
|
"../base/main.rkt"
|
||||||
(submod alexis/util/struct get-struct-accessors)
|
|
||||||
(for-syntax racket/base
|
(for-syntax racket/base
|
||||||
syntax/parse
|
syntax/parse
|
||||||
|
syntax/parse/class/struct-id
|
||||||
racket/syntax
|
racket/syntax
|
||||||
racket/struct-info))
|
racket/struct-info))
|
||||||
|
|
||||||
|
@ -21,14 +21,10 @@
|
||||||
struct+lenses-out)
|
struct+lenses-out)
|
||||||
|
|
||||||
|
|
||||||
(define-for-syntax (get-struct-field-ids struct-info failure-context)
|
(define-for-syntax (get-struct-own-accessor-ids struct-id-stx)
|
||||||
(define-values (_ field-ids)
|
(syntax-parse struct-id-stx
|
||||||
(get-struct-accessors struct-info failure-context))
|
[s:struct-id
|
||||||
field-ids)
|
(attribute s.own-accessor-id)]))
|
||||||
|
|
||||||
(define-for-syntax (get-struct-id-field-ids struct-id-stx)
|
|
||||||
(define info (extract-struct-info (syntax-local-value struct-id-stx)))
|
|
||||||
(get-struct-field-ids info struct-id-stx))
|
|
||||||
|
|
||||||
(define-for-syntax (map-format-id lex-context format-str ids)
|
(define-for-syntax (map-format-id lex-context format-str ids)
|
||||||
(define (format-one-id id)
|
(define (format-one-id id)
|
||||||
|
@ -36,10 +32,10 @@
|
||||||
(map format-one-id ids))
|
(map format-one-id ids))
|
||||||
|
|
||||||
(define-for-syntax (struct-get-set-lens-ids struct-id-stx)
|
(define-for-syntax (struct-get-set-lens-ids struct-id-stx)
|
||||||
(define field-ids (get-struct-id-field-ids struct-id-stx))
|
(define accessor-ids (get-struct-own-accessor-ids struct-id-stx))
|
||||||
(define set-ids (map-format-id struct-id-stx "~a-set" field-ids))
|
(define set-ids (map-format-id struct-id-stx "~a-set" accessor-ids))
|
||||||
(define lens-ids (map-format-id struct-id-stx "~a-lens" field-ids))
|
(define lens-ids (map-format-id struct-id-stx "~a-lens" accessor-ids))
|
||||||
(list field-ids set-ids lens-ids))
|
(list accessor-ids set-ids lens-ids))
|
||||||
|
|
||||||
(define-syntax define-struct-lenses
|
(define-syntax define-struct-lenses
|
||||||
(syntax-parser
|
(syntax-parser
|
||||||
|
@ -61,8 +57,8 @@
|
||||||
(define-provide-syntax struct-lenses-out
|
(define-provide-syntax struct-lenses-out
|
||||||
(syntax-parser
|
(syntax-parser
|
||||||
[(struct-lenses-out struct-type:id)
|
[(struct-lenses-out struct-type:id)
|
||||||
#:do [(define field-ids (get-struct-id-field-ids #'struct-type))]
|
#:do [(define accessor-ids (get-struct-own-accessor-ids #'struct-type))]
|
||||||
#:with [lens-id ...] (map-format-id #'struct-type "~a-lens" field-ids)
|
#:with [lens-id ...] (map-format-id #'struct-type "~a-lens" accessor-ids)
|
||||||
#'(combine-out lens-id ...)]))
|
#'(combine-out lens-id ...)]))
|
||||||
|
|
||||||
(define-provide-syntax struct+lenses-out
|
(define-provide-syntax struct+lenses-out
|
||||||
|
|
Loading…
Reference in New Issue
Block a user