[Haskell-cafe] Why were datatype contexts removed instead of "fixing them"?

Brandon Allbery allbery.b at gmail.com
Thu Apr 25 16:13:32 CEST 2013


On Thu, Apr 25, 2013 at 6:38 AM, harry <voldermort at hotmail.com> wrote:

> If I understand correctly, the problem with datatype contexts is that if we
> have e.g.
>   data Eq a => Foo a = Foo a
> the constraint Eq a is thrown away after a Foo is constructed, and any
> method using Foos must repeat Eq a in its type signature.
>
> Why were these contexts removed from the language, instead of "fixing"
> them?
>

As I understand it, it's because fixing them involves passing around a
dictionary along with the data, and you can't do that with a standard
declaration (it amounts to an extra chunk of data that's only *sometimes*
wanted, and that "sometimes" complicates things). GADTs already have to
pass around extra data in order to support their constructors and
destructors; and, being new and not part of the standard, they don't have
backward compatibility or standards compatibility issues, so they can get
away with including the extra dictionary without breaking existing programs.

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130425/1e34242f/attachment.htm>


More information about the Haskell-Cafe mailing list