Proposal: Don't require users to use undefined

Edward Kmett ekmett at gmail.com
Wed Oct 27 08:35:03 EDT 2010


There is a Proxy data type in the Data.Tagged library for exactly this
purpose, with conversions to and from Tagged. Proxy is easier to use with
type annotations, but Tagged seems to be easier for the compiler to erase,
since a Proxy is still an argument.

A less controversial proposal might be to see if it makes sense to just do
the portions of this proposal suited to standardizing Data.Tagged, (removing
the Data.Default dependency) even if the existing library functions are not
converted.

-Edward

On Tue, Oct 26, 2010 at 3:36 PM, Roman Leshchinskiy <rl at cse.unsw.edu.au>wrote:

> On 26/10/2010, at 19:36, Bas van Dijk wrote:
>
> >> How about:
> >>
> >> malloc :: Storable a => IO (Ptr a)
> >> malloc  = doMalloc Nothing
> >>  where
> >>   doMalloc       :: Storable b => Maybe b -> IO (Ptr b)
> >>   doMalloc dummy  = mallocBytes (sizeOf dummy)
> >
> > I don't think this will work because 'Maybe a' doesn't have a Storable
> instance.
>
> Meh, it's late, just ignore me.
>
> This is what I was thinking while typing the above nonsense. You could
> redefine sizeOf and friends to take (Dummy a) instead of `a' as an argument
> and then use this:
>
> data Dummy a = Dummy
>
> malloc :: Storable a => IO (Ptr a)
> malloc  = doMalloc Dummy
> where
>  doMalloc       :: Storable b => Dummy b -> IO (Ptr b)
>  doMalloc dummy  = mallocBytes (sizeOf dummy)
>
> In any case, for me this is not a compelling reason to break several widely
> used interfaces.
>
> Roman
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20101027/a44ac614/attachment.html


More information about the Libraries mailing list