Proposal: Don't require users to use undefined

Isaac Dupree ml at isaac.cedarswampstudios.org
Wed Oct 27 02:09:42 EDT 2010


On 10/27/10 01:51, Bas van Dijk wrote:
> On Tue, Oct 26, 2010 at 9:09 PM, Henning Thielemann
> <lemming at henning-thielemann.de>  wrote:
>>
>> On Tue, 26 Oct 2010, Bas van Dijk wrote:
>>
>>> malloc :: forall a. Storable a =>  IO (Ptr a)
>>> malloc = mallocBytes (untag (sizeOf :: SizeOf a))
>>>
>>> (Note that this does require the ScopedTypeVariables language extension.)
>>
>> Haskell 98 solution would be nicer. Something like
>>
>>> malloc :: Storable a =>  IO (Ptr a)
>>> malloc =
>>
>>      let aux :: Storable a =>  SizeOf a ->  IO (Ptr a)
>>          aux = mallocBytes . untag
>>      in  aux sizeOf
>
> Great! It's nice to know that this proposal doesn't require ScopedTypeVariables.

It may not *require* it, but the code using ScopedTypeVariables is far 
more readable than that Haskell98/Haskell2010 code (though, perhaps we 
can improve on its readability a bit).

(ScopedTypeVariables is not in Haskell2010, according to 
http://www.haskell.org/onlinereport/haskell2010/haskellli2.html#x3-5000 )

-Isaac


More information about the Libraries mailing list