[Haskell-cafe] Proposal to solve Haskell's MPTC dilemma
Max Bolingbroke
batterseapower at hotmail.com
Thu May 20 18:54:13 EDT 2010
On 20 May 2010 20:30, Carlos Camarao <carlos.camarao at gmail.com> wrote:
> Consider instances defined in non-imported modules to be visible in the
> current
> context is not correct, I think...
I was under the impression that this was not specified, because
orphans are a bit of an oddity. But naturally the Haskell spec says
what to do (Sec 5.4,
http://www.haskell.org/onlinereport/modules.html):
"Thus, an instance declaration is in scope if and only if a chain of
import declarations leads to the module containing the instance
declaration."
So you are correct.
> Sorry, I do not follow you here (why *at one particular instance*?).
> A polymorphic (overloaded or not) function is defined and then used at
> specific cases,
> with different (instance) types.
I got carried away here and didn't think that comment through, sorry
for the error. You propose delaying the (possible) lack of a unique
instantiation of the type variables to the overloaded definitions use
site, but that *does not mean* that there is only one possible
instantiation at the *original definition site* because some of the
type variables in the possibly-ambiguous context are still free in the
type and hence subject to further unification.
> Also, the same fragilty occurs if FDs are used.
This remark is surprising to me. I thought the point of the FDs being
declared on the original class (and the subsequent coverage condition
check on instances) was to ensure that this fragility couldn't happen.
Can you show an example (without using orphan instances) so I can get
the idea?
Thanks,
Max
More information about the Haskell-Cafe
mailing list