takikawa / contract-repl Goto Github PK
View Code? Open in Web Editor NEWAn experiment with the REPL & contracts
License: GNU General Public License v3.0
An experiment with the REPL & contracts
License: GNU General Public License v3.0
The non-contract-specific parts of transform
could be separated out into a useful library function. I'm imagining something like this. It's just your code with the contract-specific bits taken out.
;; local-expand/wrap-return-expression :
;; [Stx -> Stx] Stx StxLocalContext [Maybe [Listof Id]] -> Stx
(define ((local-expand/wrap-return-expression wrap) stx ctx stop-ids)
(define expanded-stx (local-expand stx ctx stop-ids))
(define (transform stx)
(syntax-parse stx
[((~literal begin) e:expr ... e1:expr) #`(begin e ... #,(transform #'e1))]
[x:id (transform #'(#%expression x))]
[(~and form (kw:id . _))
#:when (for/or ([k (list #'#%plain-lambda #'case-lambda #'if #'begin #'begin0
#'let-values #'letrec-values #'set! #'quote #'quote-syntax
#'values
#'with-continuation-mark #'#%plain-app #'#%top
#'#%variable-reference #'#%expression)])
(free-identifier=? k #'kw))
(wrap #'form)]
[_ stx]))
(transform expanded-stx))
This contract-repl library would use the a wrap
function like this to deal with the contract-specific parts:
(define (wrap form)
#`(let ([vals (call-with-values (lambda () #,form) list)])
(define n (length vals))
(for ([val vals]
[i (in-naturals 1)])
(cond [(has-contract? val)
(display-val-contract val i n)
val]
[else val]))
(apply values vals))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.