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

Emil Axelsson emax at chalmers.se
Fri Apr 26 07:06:41 CEST 2013

2013-04-26 04:31, wren ng thornton skrev:
> On 4/25/13 9:49 PM, Dan Doel wrote:
>> I don't really think they're worth saving in general, though. I haven't
>> missed them, at least.
> The thing I've missed them for (and what I believe they were originally
> designed for) is adding constraints to derived instances. That is, if I
> have:
>      data Bar a => Foo a = ... deriving Baz
> Then this is equivalent to:
>      data Foo a = ...
>      instance Bar a => Baz (Foo a) where ...
> where the second ellipsis is filled in by the compiler. Now that these
> constraints have been removed from the language, I've had to either (a)
> allow instances of derived classes which do not enforce sanity
> constraints, or (b) implement the instances by hand even though they're
> entirely boilerplate.

I think standalone deriving solves this:

     deriving instance Bar a => Baz (Foo a)

/ Emil

More information about the Haskell-Cafe mailing list