Skip to content

Instantly share code, notes, and snippets.

View greghendershott's full-sized avatar

Greg Hendershott greghendershott

View GitHub Profile
#lang racket
;; Let's write an untyped Racket module that works fine when `require`d
;; by untyped Racket. But also, let's try to use it from Typed Racket.
(provide foo
macro-foo)
;; A user may `require/type` this _function_, and it works fine.
(define (foo x)
@greghendershott
greghendershott / tilde-a.rkt
Created February 14, 2014 13:20
~a seems wonky in Typed Racket?
#lang typed/racket
(~a 1)
;; racket /tmp/tr.rkt
;; /tmp/tr.rkt:1:0: Type Checker: untyped identifier apply-contract imported from module <private/base.rkt>
;; in: #%module-begin
;; context...:
;; /Applications/Racket_v5.93/share/pkgs/typed-racket-lib/typed-racket/utils/tc-utils.rkt:98:12: for-loop
;; f18
;; /Applications/Racket_v5.93/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:227:0: type-check
#lang racket/base
(require syntax/parse
racket/match
racket/port
(only-in racket/list filter-map remove-duplicates)
rackjure/threading)
(provide -read
-read-syntax
@greghendershott
greghendershott / gist:9373439
Created March 5, 2014 18:28
Typed Racket error message
#lang typed/racket
(: foo (Real -> (Integer -> Float)))
(define (foo n)
(const n))
; /tmp/tr.rkt:5:2: Type Checker: Polymorphic function `const' could not be applied to arguments:
; Argument 1:
; Expected: a
; Given: Real
@greghendershott
greghendershott / gist:9470075
Created March 10, 2014 17:42
Building Racket from GitHub master/HEAD as of today. What does "Error 2" mean at lines 1647 and 1649?
~/src/plt/racket$ make CPUS=1
if [ "1" = "" ] ; \
then make plain-in-place PKGS="main-distribution plt-services" ; \
else make cpus-in-place PKGS="main-distribution plt-services" ; fi
make[1]: Entering directory `/home/greg/src/plt/racket'
make -j 1 plain-in-place JOB_OPTIONS="-j 1" PKGS="main-distribution plt-services"
make[2]: Entering directory `/home/greg/src/plt/racket'
make base
make[3]: Entering directory `/home/greg/src/plt/racket'
mkdir -p build/config
@greghendershott
greghendershott / gist:9487460
Last active August 29, 2015 13:57
The typecheck error has no srcloc. Also the "in:" expression is the entire `test` submodule, not the specific piece of it. (In a longer example, the piece might even be ellided, after the "...".)
#lang typed/racket/base
(require racket/flonum)
(module+ test
(require typed/rackunit)
(define (from upto)
(for/flvector ([i (in-range from upto)])
0.0)))
; Type Checker: Error in macro expansion -- insufficient type information to typecheck. please add more type annotations
; in: ((require typed/rackunit) (define (from upto) (for/flvector ((i (in-range from upto))) 0.0)))
@greghendershott
greghendershott / gist:9512916
Created March 12, 2014 18:15
Additional example for PR 14389
Here's what I think is a variation of the same bug.
It uses `for:` (my original report involved using `for/flvector`).
---
#lang typed/racket/base
(module m typed/racket/base
(: f (Nonnegative-Real -> Float))
### Keybase proof
I hereby claim:
* I am greghendershott on github.
* I am greghendershott (https://keybase.io/greghendershott) on keybase.
* I have a public key whose fingerprint is 2E96 43B5 C285 5815 6140 8A12 81A9 7656 9121 EC46
To claim this, I am signing this object:
@greghendershott
greghendershott / gist:11049662
Created April 18, 2014 15:22
Type information lost for required function, when used at REPL
Given these two files:
;; tr0.rkt
#lang typed/racket/base
(: f (Number -> Number))
(define (f n)
n)
(provide f)
;; tr1.rkt
@greghendershott
greghendershott / gist:0a04bcd5c9b6737980b7
Created May 7, 2014 12:34
Do we need "context...:" part of Typed Racket error messages?

Given a tr.rkt like:

#lang typed/racket/base
(require plot/typed)
(plot (function vector-ref) 0 1)  ;nonsense, but just for error message

You get something like: