Skip to content

Instantly share code, notes, and snippets.

View pnwamk's full-sized avatar

Andrew Kent pnwamk

View GitHub Profile
@pnwamk
pnwamk / gist:3f14e9a6e223c33bab77
Created March 8, 2015 17:19
contradictory types
Exact-Number -><- Flonum
Exact-Number -><- Flonum-Zero
Float-Complex -><- (U Nonpositive-Exact-Rational Single-Flonum Byte-Larger-Than-One Positive-Index-Not-Byte Positive-Fixnum-Not-Index Positive-Integer-Not-Fixnum Positive-Rational-Not-Integer)
Flonum -><- Zero
Flonum -><- Float-Complex
Flonum -><- One
Flonum -><- Integer
Flonum -><- Nonpositive-Integer
Integer -><- Flonum
Negative-Exact-Rational -><- Nonnegative-Exact-Rational
@pnwamk
pnwamk / gist:4825b85872c6fc62c737
Created March 20, 2015 01:56
better negation tracking!
#lang typed/racket
(: foo (Any -> Number))
(define foo (λ (x) (cond
[(not (string? x))
(cond
[(string? x) "dead code"]
[else 42])]
[else 42])))
(define-datatype Expr
[Var (Symbol)]
[Lambda (Symbol Expr)]
[App (Expr Expr)])
(: foo (Expr -> Symbol))
(define (foo e)
(type-case Expr e
[(Var x) => x]
[(Lambda y b) => y]
#lang typed/racket
(: small-car (~> ([p : (Pairof (Refine [i : Integer]
(< i (cdr p)))
Integer)])
(Refine [i : Integer]
(< i (cdr p)))))
(define (small-car p)
((inst car
Integer
@pnwamk
pnwamk / gist:44b8543bfa2f107f1d3d
Created May 28, 2015 17:12
ugly detailed number type
Typed Racket Tests > Unit Tests > Typechecker tests > tc-expr tests > 597 (let: ((v : Any 5)) (if (number? v) (+ v 1) 3))
597 (let: ((v : Any 5)) (if (number? v) (+ v 1) 3))
FAILURE
location: <pkgs>/typed-racket-test/unit-tests/typecheck-tests.rkt:597:8
actual: (tc-results
(list
(tc-result
(U
Zero
One
- - - - - - - random tests - - - - - - -
SIZE: 10
sort:
cpu time: 9 real time: 10 gc time: 2
unstable-sort:
cpu time: 8 real time: 9 gc time: 1
SIZE: 15
sort:
cpu time: 10 real time: 11 gc time: 1
unstable-sort:
#lang racket
(require racket/unsafe/ops)
(struct Cons (a d) #:transparent
#:methods gen:equal+hash
[(define (equal-proc c1 c2 =?)
(and (=? (unsafe-struct-ref c1 0)
(unsafe-struct-ref c2 0))
[new-metrics]
total arrows observed: 3987
total dependent arrows: 352 (8.8%)
total dependent arrows w/ kws: 0 (0%)
total dependent arrows w/ rst: 0 (0%)
total dependent arrows w/ drst: 0 (0%)
total rest arrows: 726 (18.2%)
total rest arrows w/ kws: 0 (0%)
total rest arrows w/ drst: 0 (0%)
@pnwamk
pnwamk / racket-shootout.txt
Created October 18, 2017 16:57
racket shootout
Racket shootout benchmarks on HEAD (commit 9e16d3f9c9c218825a483f6b53750ed9bbee2470)
[racket ackermann (2364 2358 0) 25]
[racket ackermann (2360 2355 0) 25]
[racket ackermann (2372 2369 0) 25]
[racket ary (3500 3498 0) 11]
[racket ary (3508 3507 0) 11]
[racket ary (3512 3511 4) 11]
[racket binarytrees (852 852 148) 54]
[racket binarytrees (844 844 140) 54]
@pnwamk
pnwamk / racket-shootout-no-precomp-sort.txt
Last active October 18, 2017 17:01
racket shootout but without precompiled versions of sort
Racket shootout benchmarks with no precompiled sort functions (i.e. PR #1854):
[racket ackermann (2356 2357 0) 25]
[racket ackermann (2356 2352 0) 25]
[racket ackermann (2360 2357 0) 25]
[racket ary (3504 3504 0) 11]
[racket ary (3504 3500 4) 11]
[racket ary (3512 3510 0) 11]
[racket binarytrees (856 855 128) 53]
[racket binarytrees (840 839 140) 53]