[racket-dev] Typed units?

From: Neil Toronto (neil.toronto at gmail.com)
Date: Mon Oct 8 12:42:33 EDT 2012

I currently have a function

   array-fft : (Array Complex) -> (Array Float-Complex)

courtesy Robby and James. I'd also eventually like

   bfarray-fft : (Array Bigfloat-Complex) -> (Array Bigfloat-Complex)

and others, corresponding to different kinds and precisions of numbers.

It would also be nice to allow the matrix operations to work on Bigfloat 
and other kinds of numbers; currently, they're limited to Number. More 
generally, it would be nice to make all the algorithms in the math 
library generic.

One obvious approach is to use units, and provide the units and some 
implementations that are already wired up. Is this fundamentally hard to 
do in Typed Racket, easy but nobody had a reason yet, or somewhere in 

Generics is another option, but it seems they'd be harder to implement 
in TR because dispatch is done at runtime.

Neil ⊥

Posted on the dev mailing list.