Skip to content

Instantly share code, notes, and snippets.

View pnwamk's full-sized avatar

Andrew Kent pnwamk

View GitHub Profile
#lang typed/racket
(define (foo [x : Any]) : Number
(let ([x* x])
(begin
(set! x* "sneaky string")
(if (number? x)
x*
42))))
@pnwamk
pnwamk / gist:eba07d62b322e2fac3e2
Created January 10, 2015 19:33
foo.rkt (aliasing path error)
;; ERROR EXAMPLE FILE "foo.rkt"
#lang typed/racket/base
;(provide Foo) ;; comment this line to see THE ERROR
(provide in-foo)
(require (for-syntax racket/base))
;; -- taken from 'math/private/Foo/typed-array-struct.rkt'
(struct: (A) foo ([shape : (Vectorof Index)]
@pnwamk
pnwamk / gist:11b14797f3b6cb03f717
Created January 10, 2015 19:33
main.rkt (aliasing path error)
;; ERROR EXAMPLE FILE "main.rkt"
#lang typed/racket/base
(require "foo.rkt")
(: for-foo (-> (foo Any) Void))
(define (for-foo arr)
(for ([sample (in-foo arr)]) (void)))
@pnwamk
pnwamk / gist:018926c002ac2ec170e9
Created January 11, 2015 00:21
let aliasing internal error test
#lang typed/racket/base
(module foo-home typed/racket/base
;(provide foo) ;; comment this line to see THE ERROR
(provide in-foo)
(require (for-syntax racket/base))
;; -- taken from 'math/private/Foo/typed-array-struct.rkt'
@pnwamk
pnwamk / gist:38e49bf5f61016b736f5
Created January 26, 2015 01:49
dependencies in occurrence typing
#lang typed/racket
(: foo (Any Any -> Number))
(define (foo x y)
(cond
[(or (and (string? x) (string? y))
(and (number? x) (number? y)))
(if (number? x)
y ;; <- doesn't typecheck
(match tail
...
[(if ,p ,tT ,fT)
(cps
[tTail* tE <- (Tail tTail) (: Tail/c Env/c)]
[fTail* fE <- (Tail fTail) (: Tail/c Env/c)]
[then
(let*-values ([(l+ tE*) (label-block tTail* 'T #f)]
[(l- fE*) (label-block fTail* 'F #f)]
[(tail* Ep)])
(library (Compiler contracts)
(export UVar/c
FVar/c
Label/c
Relop/c
Binop/c
DispOp/c
Index/c
Int32/c
Int64/c
Internal Typechecker Error: no type for (quote put-text) at: #f line #f col #f
while typechecking:
here
originally:
here
context...:
/Users/amk/Repos/plt/extra-pkgs/typed-racket/typed-racket-lib/typed-racket/utils/tc-utils.rkt:262:0: int-err
/Users/amk/Repos/plt/racket/collects/racket/contract/private/arrow-val-first.rkt:265:18
parser-name3
dots-loop
@pnwamk
pnwamk / gist:e9e7470bddc99acce9e3
Created March 7, 2015 15:18
racket/share/pkgs/plot-lib/plot/private/plot2d/decoration.rkt
#lang typed/racket/base
;; Renderers for plot decorations: axes, grids, labeled points, etc.
(require typed/racket/class typed/racket/draw racket/match racket/math racket/list
plot/utils
"../common/type-doc.rkt"
"../common/utils.rkt"
"clip.rkt"
"plot-area.rkt")
@pnwamk
pnwamk / gist:1ea1de2fb0673dc309a5
Last active August 29, 2015 14:16
contradictory change
;; contradictory: Filter/c Filter/c -> boolean?
;; Returns true if the AND of the two filters is equivalent to Bot
;; OLD contradictory? definition
(define (contradictory? f1 f2)
(match* (f1 f2)
[((TypeFilter: t1 p) (NotTypeFilter: t2 p))
(subtype t1 t2)]
[((NotTypeFilter: t2 p) (TypeFilter: t1 p))
(subtype t1 t2)]