[Haskell-cafe] Re: overlapping instances, selecting if type a does not belong to class?

2007-02-27 Thread Marc Weber
However, it seems that your particular problem can be solved with simpler means: instance (HList a) = HListAppendArbitrary a HNil a where hAppendArbitrary a _ = a instance (HList a, HList b, HList c) = HListAppendArbitrary a (HCons b d) c where hAppendArbitrary a b = hAppend

[Haskell-cafe] Re: overlapping instances, selecting if type a does not belong to class?

2007-02-27 Thread oleg
The problem you report can be fixed with some trickery and local functional dependencies. I'd like to show a different solution, which follows a useful general pattern, of isolating overlapping instances to one small part of the program that analyzes the type. The rest of the type program just

[Haskell-cafe] Re: overlapping instances, selecting if type a does not belong to class?

2007-02-26 Thread Marc Weber
Wow. That said, it is quite possible in Haskell to achieve genuine class-based dispatch, with backtracking if necessary: http://pobox.com/~oleg/ftp/Haskell/poly2.txt Thanks for digging this up. I'll have to reread it tomorrow. I wasn't able to find the definition of AllOf(But): quote

[Haskell-cafe] Re: Overlapping instances

2005-08-24 Thread Ashley Yakeley
In article [EMAIL PROTECTED], Frank [EMAIL PROTECTED] wrote: I would like to state that a class Sup is exhaustively broken down in two subclasses Sub1 and Sub2 (meaning, for every instance of Sub1 and every instance of Sub2, the methods in Sup apply). I try to code this as: instance