
Dear cafe, today I wrote a type class with three parameters. class Foo a b c | a b -> c where foo :: a -> b -> c instance Foo A R A where ... instance Foo R A A where ... In addition to the functional dependency I'd like to express that at least one of the parameters a and b is c, that is, Foo is the union of the two classes class Foo1 a b where foo1 :: a -> b -> a class Foo2 a b where foo2 :: a -> b -> b and furthermore the choice between Foo1 and Foo2 determines one parameter to be a fixed type, say R. I understand that logical disjunction poses problems for instance resolution [1] because adding an instance may affect the instance dictionary lookup. This should not happen in my case because in the end this would be a one-parameter type class. The ultimate aim is to use the same symbol for both a function foo :: R -> a -> a and for flip foo. Of course writing flip foo is not that much of a nuisance, I just wonder whether Haskell is expressive enough to do this. Olaf [1] https://stackoverflow.com/questions/10255148/how-can-i-combine-two-type-cons...