[Haskell-cafe] Cons of -XUndecidableInstances
oleg at okmij.org
oleg at okmij.org
Tue Jun 7 09:50:37 CEST 2011
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.
This topic is discussed at length in the article
http://okmij.org/ftp/Haskell/types.html#undecidable-inst-defense
Here are the conclusions:
Thus there are patently decidable type programs that require
UndecidableInstances. That extension should not be categorically
stigmatized.
In conclusion, UndecidableInstances is not a dangerous flag. It will never
cause the type-checker to accept a program that `goes wrong.' The only bad
consequence of using the flag is type checker's might be telling us that it
cannot decide if our program is well-typed, given the context-stack--depth
limit. We may ask the type-checker to try a bit harder (with a larger depth
limit), or look through our program and find the problem.
UndecidableInstances are quite like the primitive recursion criterion:
all primitive recursion functions surely terminate; non-primitive recursion
functions generally don't. Still there are many classes of non-primitive
recursive functions that are total. To see their totality, one has to use
more complex criteria.
More information about the Haskell-Cafe
mailing list