Coder Social home page Coder Social logo

contract-repl's People

Contributors

donm avatar stamourv avatar takikawa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

contract-repl's Issues

Separating out non-contract-specific parts of `transform`

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))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.