[Haskell-cafe] Re: [Haskell] A puzzle and an annoying feature
Martin Sulzmann wrote: [Discussion moved from Haskell to Haskell-Cafe] Hi, Regarding - lazy overlap resolution aka unique instances Well, if there's only instance which is not exported, then you can use functional dependencies. Assume class C a instance ... = C t Internally, use class C a | - a instance ... = C t But using functional dependencies feels like a sledge hammer, and it is also not Haskell 98. -- Lennart ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] A puzzle and an annoying feature
Lennart Augustsson writes: [...] But using functional dependencies feels like a sledge hammer, and it is also not Haskell 98. Well, I'm simply saying that your proposed extension which is not Haskell 98 can be expressed in terms of a known type class extension. I agree that something weaker than FDs would be sufficient here. Martin ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell] A puzzle and an annoying feature
Seeing as we are taling about type class extensions, can you see any problems with the following... class X x instance Int instance Float instance x Here we have overlapping instances... (bad), but if we look at the cases there is one which will match 'x' but never any of the others... that is when the overloading is unresolved... like in: show (read y) suppose we replace X with class X x y | x - y instance Int Int instance Float Float instance x Int What we mean is for 'x' to catch anything that does not match (not Int or Float)... but this is broken because the programs meaning can change when extra instances are added... But considering above, the 'unresolved condition' is included in x, as well as all the overlapping cases... so is it safe to say: class X x y | x - y instance Int Int instance Float Float instance (_|_) Int Where (_|_) is some symbol that represents no match is possible or a failure of the overloading resolution... This _cannot_ overlap with the other instances, and is distinct (the meaning does not change if instances are added)... This could be used to force resolution in unresolvable cases (much like Integrals default to Integer is ambiguous)... Any thoughts? Keean. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe