[Haskell-cafe] Proposal to solve Haskell's MPTC dilemma

Carlos Camarao carlos.camarao at gmail.com
Thu May 20 20:58:26 EDT 2010


 On Thu, May 20, 2010 at 7:54 PM, Max Bolingbroke <
batterseapower at hotmail.com> wrote:

> On 20 May 2010 20:30, Carlos Camarao <carlos.camarao at gmail.com> wrote:
>


> > ... Also, the same fragilty occurs if FDs are used.
>
> This remark is surprising to me. I thought the point of the FDs being
> declared on the original class (and the subsequent coverage condition
> check on instances) was to ensure that this fragility couldn't happen.
> Can you show an example (without using orphan instances) so I can get
> the idea?
>
> Thanks,
> Max
>


Well, what I meant is just that the same would happen if we had
a FD a->b in Example 1... (maybe I am not following you).

That is: the same would happen if Example 1 was written with a FD
as follows:

class F a b | a -> b where
   f:: a -> b
instance O a where
  o:: a

And we had the same context:

instance F Bool Bool where
   f = not
instance O Bool where
  o = True
k = f o
kb = not k

Then: kb is well-typed, because FD a |->b "closes the world",
causing type (F a b, O a)=>Bool to be simplified ("improved")
to Bool.

But this type-correct program would become not typeable if
instances such as the ones referred to before (by Daniel Fischer)

  instance F Int Bool where
    f = even
  instance O Int where
    o = 0

were later introduced, or imported...

Cheers,
Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100520/ea6c1bf9/attachment.html


More information about the Haskell-Cafe mailing list