[Haskell] Re: Boxing (Day) Question
lennart at augustsson.net
Mon Dec 26 20:17:34 EST 2005
Ashley Yakeley wrote:
> In article <43AFCA38.5000302 at augustsson.net>,
> Lennart Augustsson <lennart at augustsson.net> wrote:
>>On the whole it looks like you want type variables with kind #.
>>There are very good implementation reasons for not allowing this.
>>If you had type variables of kind # you could have polymorphic
>>functions over unboxed values. But since the values are unboxed
>>they don't have a uniform representation (e.g., a Double# is probably
>>twice the size of a Float#). So polymorphic functions over unboxed
>>values are not easy to implement. (You can imagine implementations
>>of them, but none of them are pleasent.)
> Oh, I hadn't thought of that.
> One solution might be to have a kind for each kind of storage:
> * for boxed values
> #4 for 4-byte values
> #8 for 8-byte values
> #P for pointers to things that need to be GC'd (or whatever)
> Do you think this would work?
Yes, I think it would work. But I'd think it would be awkward.
Now you need to know the size of each unboxed type to make polymorphic
functions (and that's not even portable).
More information about the Haskell