[Haskell-cafe] Re: [Haskell] Re: Boxing (Day) Question

Simon Peyton-Jones simonpj at microsoft.com
Wed Jan 4 04:48:05 EST 2006

| > You'd still need several versions of the code for a polymorphic
function, one
| > for pointer values, one for 4-byte non-pointers, one for 8-byte
| > etc.
| Yes, but that's up to the user. A type variable always has a
| kind, so for instance one might want an array over any 4-byte
| non-pointer value:
|   data Array4 (a :: #4)
| Functions on Array4 only need one version of code. This makes
| polymorphism less useful, of course, but the goal here is to be closer
| to the machine.

Ah, now I see what you mean.  I had not thought of doing that, but it'd
make sense, esp if there were lots of 4-byte-non-pointer types.  But
there are only a couple (Int# and Word32#) so I'm not sure it's worth
the effort.  But (without thinking about it too hard) it looks like a
very sensible idea.  The trickiness is in the fact that some type
constructors (notably (->)) are somewhat kind-polymorphic, which gives
rise to some awkwardness in the type checker.  So the details might not
be entirely straightforward.


More information about the Haskell-Cafe mailing list