Skip to content

Commit

Permalink
core,type: lazy-load gregor and json procs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Dec 29, 2023
1 parent 92058a9 commit bbde37b
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions deta-lib/type.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,42 @@
syntax/parse/pre)
db
db/util/postgresql
gregor
gregor/time
json
racket/contract/base
racket/format
racket/lazy-require
"private/type.rkt")

(lazy-require
[gregor (moment-provider?
datetime-provider?
date-provider?
time-provider?
moment
datetime
moment->iso8601/tzid
datetime->iso8601
date->iso8601
iso8601/tzid->moment
iso8601->datetime
iso8601->date
iso8601->time
->moment
->datetime/local
->date
->time
->year
->month
->day
->hours
->minutes
->seconds
->nanoseconds
->utc-offset)]
[gregor/time (time->iso8601)]
[json (jsexpr?
string->jsexpr
jsexpr->string)])

(provide
type?
define-type)
Expand All @@ -24,6 +53,11 @@
(define gen:type-load type-load)
(define gen:type-dump type-dump)

(define (get-type-declaration type dialect decl)
(if (procedure? decl)
(decl type dialect)
decl))

(define-syntax (define-type stx)
(syntax-parse stx
[(_ id:id (~optional (fld:id ...))
Expand All @@ -49,10 +83,7 @@
[(define (type-contract type)
(~? contract-e (~? (contract-fn-e type) any/c)))
(define (type-declaration type dialect)
(let ([decl declaration-e])
(if (procedure? decl)
(decl type dialect)
decl)))
(get-type-declaration type dialect declaration-e))
(define (type-load type dialect v)
(~? (load-e type dialect v) v))
(define (type-dump type dialect v)
Expand Down

0 comments on commit bbde37b

Please sign in to comment.