[Haskell-cafe] Cons of -XUndecidableInstances

Yves Parès limestrael at gmail.com
Tue Jun 7 17:58:25 CEST 2011

Personally, I came much less against UndecidableInstances when I was trying
to do OOP in Haskell than when I was trying do Prolog-like things at the
type level.
Things like transitive relations: (If a type B contains an A, and if C
contains B, then C contains A, and so on).
I kind of abandonned quickly that way of reasoning ^^.

2011/6/7 Yitzchak Gale <gale at sefer.org>

> I wrote:
> >>> You almost never want to use UndecidableInstances
> >>> when writing practical programs in Haskell.
> >>> When GHC tells you that you need them, it almost
> >>> always means that your types are poorly designed,
> >>> usually due to influence from previous experience
> >>> with OOP.
> wren ng thornton wrote:
> >> That's a bit unfair. There are many kinds of type-level
> >> hackery which require UndecidableInstances but are
> >> (a) perfectly safe for practical use, and
> >> (b) have nothing to do with OOP.
> >> One particularly trivial example that comes to mind is:
> >>    newtype Mu f = Mu (f (Mu f))
> I agree. I've even used that one (well, something similar
> anyway).
> Oleg wrote:
> > It seems that UndercidableInstances keep getting a bad rap.
> > There are legitimate and decidable applications of
> > UndercidableInstances. These applications have nothing to do
> > with OOP, or HList for that matter... That extension should not
> > be categorically stigmatized.
> I'm sorry if I came across as giving it a bad rap, or
> stigmatizing it. That was certainly not my intention. There
> are plenty of excellent techniques that use this and other
> GHC extensions; accomplished Haskellers should have
> them in their toolbox.
> But I stand by my statement, which is coming from my
> perspective as a professional Haskell software developer,
> not a PL researcher. Perhaps I should clarify it though.
> I am making two claims:
> 1. In everyday practical Haskell programming, it is very
> unusual that a technique requiring direct use of
> UndecidableInstances is the right tool for the job. Of course,
> that observation is colored by my own experience, but I
> believe that it is generally true.
> 2. If a person is surprised by the GHC error suggesting
> that UndecidableInstances is needed and is struggling with
> understanding it, then it is almost certain that person has
> inappropriately used OOP thinking in trying to design a
> Haskell program.
> Experienced Haskellers familiar with those techniques
> do not get the error. Or they get it and say, "Oops, forgot
> the UndecidableInstances."
> Whereas most programmers coming to Haskell have had
> OOP experience. The first thing that happens when they
> try to write a program in Haskell of any significant complexity
> is the "UndecidableInstances" error. It happened to me, too.
> Thanks,
> Yitz
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110607/66917a07/attachment.htm>

More information about the Haskell-Cafe mailing list