24 Oct 12:37 2013

## Why do I need UndecidableInstances?

Alejandro Serrano Mena <trupill <at> gmail.com>

2013-10-24 10:37:15 GMT

2013-10-24 10:37:15 GMT

Dear café,

I'm trying to compile a set of simple examples using Functional Dependencies. One of the first ones is the case of natural numbers, which I've defined along with some operations as:

data Zero

data Succ a

class Plus x y z | x y -> z

instance Plus Zero x x

instance Plus x y z => Plus (Succ x) y (Succ z)

class Max x y z | x y -> z

instance Max Zero y y

instance Max (Succ x) Zero (Succ x)

instance Max x y z => Max (Succ x) (Succ y) (Succ z)

I thought the compiler would accept this only with the extensions EmptyDataDecls, MultiParamTypeClasses, FunctionalDependencies and FlexibleInstances. But, to my surprise, GHC is also asking me for UndecidableInstances. Why is this the case?

Thanks in advance :)

_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe