This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (module m typed/racket | |
| ;; the generated contract for this is | |
| ;; | |
| ;; (define-values:102 (generated-contract4:103) | |
| ;; (#%app:104 | |
| ;; continuation-mark-key/c/proc:105 | |
| ;; (#%app:106 flat-named-contract 'Integer exact-integer?))) | |
| ;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang typed/racket | |
| ;; Typed Racket has some neat tricks | |
| ;; that allow it to type Racket programs. | |
| ;; One important trick is that it can pass "filter" information around | |
| ;; in branches of a cond expression, | |
| ;; as well as a few other expressions like cond. | |
| ;; Filters tell you additional type information about a value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Post { | |
| import Comment from Comment; | |
| import Model from DS; | |
| export get Post() { return _Post; } | |
| class _Post extends Model {} | |
| _Post.schema((post) => { | |
| post.attr('title'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Post { | |
| import Comment from Comment; | |
| import Model from DS; | |
| class Post extends Model {} | |
| Post.schema((post) => { | |
| post.attr('title'); | |
| post.attr('body'); | |
| post.hasMany('comments', (args...) => Comment(args...)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| . Type Checker: untyped identifier apply-contract imported from module <private/base.rkt> in: #%module-begin | |
| . Type Checker: untyped identifier coerce-contract imported from module <private/guts.rkt> in: #%module-begin | |
| . Type Checker: untyped identifier flat-named-contract imported from module <racket/contract> in: #%module-begin | |
| . Type Checker: untyped identifier build-source-location imported from module <syntax/srcloc> in: #%module-begin | |
| . Type Checker: Summary: 4 errors encountered in: | |
| #%module-begin | |
| #%module-begin | |
| #%module-begin | |
| #%module-begin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (define people '(liz steve aj marti david ann pat annie mae helen jane carl | |
| sam katie will lindsey | |
| )) | |
| (define last-year '((sam aj) (katie will) (liz jane) (aj liz) (steve marti) (pat steve) (mae katie) | |
| (ann annie) (helen mae) (carl helen) (jane david) (annie carl) | |
| (will sam) (david pat) (marti ann))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (require compiler/cm mzlib/compile unstable/logging) | |
| (manager-compile-notify-handler displayln) | |
| (define prefix "/home/samth/sw/plt/collects/tests/typed-racket/succeed/") | |
| (define (del file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (define-syntax m | |
| (list #f #'cons #'pair? (list #'car #'cdr) (list #f #f) #t)) | |
| (match (cons 1 2) | |
| [(m a b) (+ a b)]) | |
| ;; => 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (define (find-duplicates elts) | |
| (define ht (make-hash)) | |
| (for/list ([x elts] | |
| #:when (hash-update! ht x add1 0) | |
| #:when (= 2 (hash-ref ht x))) | |
| x)) | |
| (find-duplicates '(1 2 2 3 1 4 5 4 4 4)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket/base | |
| (for ([i (in-range 5 +inf.0 2)]) (displayln i)) |