Unlifted type variables in GHC
Simon Peyton-Jones
simonpj at microsoft.com
Fri Dec 8 10:48:22 EST 2006
| 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!
This stuff is not impossible. Microsoft's CLR allows exactly this, and compiles fresh code for each instantiation of a function at a type of different size or pointer-hood than the ones already compiled. But GHC does not do that, and won't anytime soon.
The paper I wrote with John Launchbury "Unboxed types as first class citizens" elaborates, I think.
Simon
More information about the Glasgow-haskell-users
mailing list