[racket] Ad-hoc polymorphism in Typed Racket

From: Noel Welsh (noelwelsh at gmail.com)
Date: Tue Feb 15 07:02:54 EST 2011

So this isn't really ad-hoc, is it? I can't extend the type in another
module (typically done with structure properties in Racket). Anyway, a
union type will do for me, for now.


On Mon, Feb 14, 2011 at 9:57 PM, Vincent St-Amour <stamourv at ccs.neu.edu> wrote:
> For the built-in functions that are currently supported by TR, the
> ad-hoc polymorphism should work. If you want to write your own ad-hoc
> polymorphic functions, you can give them types constructed with the
> case-lambda type constructor (which is not the same thing as Racket's
> case-lambda macro):
> http://docs.racket-lang.org/ts-reference/index.html?q=case-lambda#%28form._%28%28lib._typed/racket/base..rkt%29._case-lambda%29%29
> In git, you can also use case-> as a synonym for case-lambda.
>> In particular, I'd
>> like to use the dict library.
> The dict library is not currently supported. The main problem is that
> I'm not aware of a way to express the fact that a (Vectorof X) is a
> (Dictof Integer X) in TR's type system, which currently makes dict
> operations untypeable. We could give them types that exclude vectors,
> though.
> Would that be an acceptable solution for you?
> Vincent

Posted on the users mailing list.