[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