Proposal: Don't require users to use undefined
Bas van Dijk
v.dijk.bas at gmail.com
Wed Oct 27 03:12:10 EDT 2010
On Wed, Oct 27, 2010 at 8:09 AM, Isaac Dupree
<ml at isaac.cedarswampstudios.org> wrote:
> 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).
Indeed. My patches for base and the other packages uses
ScopedTypeVariables extensively. It makes code shorter and easier to
read.
Is using ScopedTypeVariables a problem by the way? Should base use
Haskell2010 exclusively or are extensions allowed?
> (ScopedTypeVariables is not in Haskell2010, according to
> http://www.haskell.org/onlinereport/haskell2010/haskellli2.html#x3-5000 )
I hope they will be in Haskell2011.
Bas
More information about the Libraries
mailing list