[Haskell-cafe] coherence when overlapping?
william kim
haskelllist at hotmail.com
Wed Apr 12 05:44:59 EDT 2006
Hi All,
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
> f=e1
>instance C a where
> f=e2
>
>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
setting?
If yes, how is it applicable to rule out the incoherent behaviour?
If otherwise, what is the definition of coherence with overlapping
instances?
Thanks.
--william
_________________________________________________________________
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
mailing list