Skip to content

Instantly share code, notes, and snippets.

@greghendershott
Created March 5, 2014 18:28
Show Gist options
  • Save greghendershott/9373439 to your computer and use it in GitHub Desktop.
Save greghendershott/9373439 to your computer and use it in GitHub Desktop.
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
;
; Result type: (Any * -> a)
; Expected result: (Integer -> Flonum)
;
; in: (const n)
;;; IMHO the following format would be easier to grok:
; /tmp/tr.rkt:5:2: Type Checker: Polymorphic function `const' could not be applied to arguments:
; Argument 1:
; Expected: a
; Given: Real
; Result:
; Expected: (Integer -> Flonum)
; Given: (Any * -> a)
; in: (const n)
;;; 1. Consistent order for expected vs. given, for arguments and result.
;;; 2. No blank lines; confusing with multiple errors in a row.
;;; p.s. A non-formatting point: It would be great if the error
;;; message for Argument 1 could somehow say, "Expected: Flonum",
;;; since that's the actual fix to make.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment