[racket] Typed racket and sort

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Wed Aug 3 15:00:57 EDT 2011

Greetings.

If I try running the following program:

#lang typed/racket
(define ss '("one" "two" "three")) ; (Listof String)
(sort ss string<?)

I get an error message:

Type Checker: Cannot apply expression of type (All (a b) (case-lambda ((Listof a) (a a -> Boolean) [#:cache-keys? Boolean] -> (Listof a)) ((Listof a) (b b -> Boolean) [#:cache-keys? Boolean] #:key (a -> b) -> (Listof a)))), since it is not a function type in: (sort ss string<?)

I'm a little perplexed -- could anyone unpack this for me?

I can see that this is the type declaration for SORT, but 

  (a) The type checker can't do keywords, so I'm slightly surprised to see what appear to be keywords in what appears to be a type declaration, and 
  (b) There doesn't seem to be a case for the keywordless case (and the error doesn't magically go away if I supply #:cache-keys?).

I suspect I'm not grokking something important about polymorphic functions, but I don't know what.

This is with Racket 5.1.1.

Best wishes,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
School of Physics and Astronomy, University of Glasgow, UK




Posted on the users mailing list.