Unlifted type variables in GHC

Brian Alliet brian at brianweb.net
Fri Dec 8 12:23:27 EST 2006


On Fri, Dec 08, 2006 at 03:48:22PM +0000, Simon Peyton-Jones wrote:
> | I want to make ByteArray# and MutableByteArray# parameterized over
> | their element types. ByteArray# would have kind # -> #, and
> | MutableByteArray#, * -> # -> # . indexByteArray# would have the type
> | (in pseudo haskell) forall (e::#). ByteArray# e -> Int# -> e.
> 
> Probably a bad idea.  The point is that you could then write
> polymorphic functions that would apparently work both on values of
> type Int# and Double#... but they are of different sizes. Seg-fault
> city!

Right... which is why you'd need to make sure you never used those
functions in a polymorphic way. The code generator should choke if it
sees an unlifted type variable.

I'm basically looking for a way to avoid enumerating every possible
unlifted type in the ByteArray# operations.

I'm probably not giving enough details for this to make any sense. I'm
actually writing a new ghc backend and I have way more primitive types
than the normal dozen or so (actually an infinite number since you can
add new ones, I resurrected that "foreign type" code that was leftover
from the .NET backend).

I'll just try it and see how I make out.

-Brian


More information about the Glasgow-haskell-users mailing list