Skip to content

Instantly share code, notes, and snippets.

#lang racket
(require rackunit)
;; int -> string
(define (line n)
(list->string (build-list n (λ (x) #\*))))
(check-equal? (line 3) "***")
(check-equal? (line 1) "*")
. 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
@takikawa
takikawa / test
Created December 5, 2012 18:11
TR and mandatory keywords
plt/racket-git/collects/typed-racket/utils/tc-utils.rkt:154:0: Internal Typechecker Error: funapp with keyword args ((Unknown Type: #(struct:Keyword 952 #(struct:combined-frees #hasheq() ()) #(struct:combined-frees #hasheq() ()) #f #f #:foo Integer #t))) NYI
while typechecking:
(#%app f)
originally:
(f)
#lang racket
(require (for-syntax syntax/parse))
(define-match-expander list-or
(lambda (stx)
(syntax-parse stx
[(_ pat) #'(app (lambda (lst)
(for/or ([elem lst])
(match elem [pat elem] [_ #f])))
$ raco pkg install pfds
=: contract violation
expected: number?
given: #<eof>
argument position: 1st
other arguments...:
31
context...:
/home/asumu/plt/racket-git/collects/file/untgz.rkt:27:3
/home/asumu/plt/racket-git/collects/planet2/lib.rkt:400:17
@takikawa
takikawa / gist:4237247
Created December 7, 2012 22:59
stack trace from check
#lang racket
(require rackunit)
(test-begin
(parameterize ([current-check-around
(λ (thunk)
(with-handlers ([exn? (λ (e) ((error-display-handler) "check" e))])
(thunk)))])
(check-equal? 1 2)))
@takikawa
takikawa / gist:4698623
Created February 2, 2013 18:05
Submodules in scribble/lp
#lang scribble/lp
@chunk[<a> (module main racket (provide x) (define x 3))]
@chunk[<b> (module test racket
(require rackunit (submod ".." main))
(check-equal? x 3))]
@chunk[<*> (begin <a> <b>)]
Context: the package taglib is installed in shared scope, but not
in the default user scope. The user is trying to remove the
package (with the default --user option).
Old error message:
$ raco pkg remove taglib
raco pkg remove: package not currently installed
package: taglib
currently installed: [none]
@takikawa
takikawa / gist:5025401
Last active December 14, 2015 03:59
current-check-handler
#lang racket
(require rackunit)
(define old-handler (current-check-handler))
(parameterize ([current-check-handler
(λ (exn)
;; put custom processing here
(displayln "do something")
#lang racket
;; a fun implementation of balanced brackets from Rosetta Code
(define (balanced? str)
(with-handlers ([exn:fail? (λ (exn) #f)])
(define in (open-input-string str)
(let loop ([x (read in)])
(if (not (eof-object? x))
(loop (read in))
#t))))