[Haskell-cafe] Cons of -XUndecidableInstances

Yitzchak Gale gale at sefer.org
Mon Jun 6 07:52:02 CEST 2011


Scott Lawrence wrote:
> More specifically, I have
>
>  class Model m a | m -> a where ...
>  class Entropy d where ...
>  instance (Model m a) => Entropy m where ...
>
> The first line requires MultiParamTypeClasses and
> FunctionalDependencies... the third
> requires UndecidableInstances...
> Is this likely to cause a problem?

Yes.

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.

Your best bet is to step back and think again about
the problem you are trying to solve. What is the
best way to formulate the problem functionally?
That will lead you in the right direction. Please
feel free to share more details about what you are
trying to do. We would be happy to help you work out
some good directions.

Regards,
Yitz



More information about the Haskell-Cafe mailing list