Skip to content

Instantly share code, notes, and snippets.

#lang typed/racket
(require/typed racket/base [list (All (a) Float)])
(* 3.3 list)
#lang typed/racket
(define-type (Even A) (U Null (Pairof A (Odd A))))
(define-type (Odd A) (Pairof A (Even A)))
(: even-lst (Even Integer))
(define even-lst '(1 2 3 4))
(: odd-lst (Odd Integer))
(define odd-lst '(1 2 3))
default-load-handler: cannot open module file
module path: #<path:/home/asumu/plt/racket-tmp/collects/racket/match/match.rkt>
path: /home/asumu/plt/racket-tmp/collects/racket/match/compiled/match_rkt.zo
system error: No such file or directory; errno=2
context...:
standard-module-name-resolver
/home/asumu/plt/racket-tmp/collects/racket/match/match.rkt: [traversing imports]
/home/asumu/plt/racket-tmp/collects/racket/match.rkt: [traversing imports]
/home/asumu/plt/racket-tmp/collects/compiler/cm.rkt:372:0: compile-zo*
/home/asumu/plt/racket-tmp/collects/compiler/cm.rkt:579:26
@takikawa
takikawa / gist:5800388
Created June 17, 2013 21:00
Need nominal type...
$ racket -I typed/racket
Welcome to Racket v5.3.4.12.
-> (require typed/framework)
-> (require typed/racket/gui)
-> ((inst canvas:wide-snip-mixin #:row (init [parent (Instance Dialog%)] [editor (Instance Text:Basic%)])) editor-canvas%)
; wide-snip-mixin: argument class does not implement interface
; argument: #<class:editor-canvas%>
; interface name: #<interface:basic<%>>
; [,bt for context]
raco setup: undeclared dependency detected
for package: "optimization-coach"
on packages:
"drracket"
"gui-lib"
"images"
"sandbox-lib"
"string-constants-lib"
"typed-racket-lib"
"unstable-list-lib"
-> (set-first (set-add s (lambda (x) 3)))
; s: broke its contract
; promised a procedure that accepts 1 mandatory argument without any keywords
; produced: 2
; in: the range of
; a disjunct of
; the set-first method of
; the range of
; a disjunct of
; the set-add method of
-> (set-member? s 3)
; s: contract violation
; expected a procedure that accepts 1 mandatory argument without any keywords
; given: 3
; in: the 2nd argument of
; method set-member? with contract (-> set? (-> number? number?)
; boolean?)
; (set/c (-> number? number?))
; contract from: (definition s)
; blaming: top-level
;; goes in .racketrc
(define current-cow-flags (make-parameter ""))
(define old-print (current-print))
(define (print-with-cowsay val [port (current-output-port)])
(define output (with-output-to-string (thunk (old-print val))))
(when (not (string=? "" output))
(match-define
(list in _ _ _ _)
(process (format "cowsay ~a \"~a\"" (current-cow-flags) output)))
(display (port->string in) port)))
@takikawa
takikawa / gist:6253646
Created August 16, 2013 21:28
Internal definition context stages of grief
<samth> my experience is that the internal definition context stages of grief are:
<samth> (1) what are these int-def-ctx arguments?
<samth> (2) this stuff makes no sense
<samth> (3) why is it so imperative?
<samth> (4) i can't think of a better way
<samth> (5) i am ryan culpepper
#lang racket/base
(require racket/generic
#;racket/set
(except-in racket/set in-set))
(struct foo ()
#:methods gen:set
[(define/generic gin-set in-set)
(define (in-set set) 0)])