[Haskell-cafe] coherence when overlapping?
haskelllist at hotmail.com
Wed Apr 12 05:44:59 EDT 2006
One important property of type class dictionary translation is coherence
which basically says that two typing derivations for the same term at the
same type in the same environment must be equivalent. This definition is
established with the assumption of non-overlapping.
In the GHC documentation which describes the extension of overlapping
instances, an example similar to the following is given.
>class C a where
> f:a -> a
>instance C Int where
>instance C a where
>let g x = f x
>in g 1
In this case GHC takes an ¡°incoherent¡± decision by taking the second
instance as an instantiation of function f even it is executed with an input
of type Int.
My question is whether the ¡°incoherence¡± behaviour of overlapping
instances is derived from the definition of coherence in the non-overlapping
If yes, how is it applicable to rule out the incoherent behaviour?
If otherwise, what is the definition of coherence with overlapping
Find just what you are after with the more precise, more powerful new MSN
Search. http://search.msn.com.sg/ Try it now.
More information about the Haskell-Cafe