Polymorphic kinds

Sebastien Carlier sebc@macs.hw.ac.uk
Tue, 5 Aug 2003 17:02:08 +0100

On Tuesday 05 August 2003 4:00 pm, Simon Peyton-Jones wrote:
> | > id# :: (a :: # ) -> a
> | > id# x = x
> That should really be rejected. You couldn't call it because you'd have
> to instantiate 'a' to Int# or Double#, and that would mean different
> code for different calls.

GHC (after modifying the parser to allow # to stand for the kind of unlifted 
type) seems to behave very nicely with this definition - it does not generate 
any code for it, and inlines its uses; so the problem never actually arises 
(but I expect it would for more complex code).  I guess I shouldn't rely on 
that, anyhow.

> One clue: take a look at the UArray library.
> http://www.haskell.org/ghc/docs/latest/html/base/Data.Array.Unboxed.html
> UArray is parameterised by Int, Float, Double, but it describes arrays
> that hold Int#, Float#, Double# respectively.  Maybe you could re-use
> ideas from there?

Interesting!  It seems that just writing wrappers around my new primitive 
operations, that do boxing and unboxing as appropriate, works out just fine - 
GHC does all the expected unboxing.  So it is not worth trying to work with 
boxed values directly.  Great, thanks!  :-)