
18 Feb
2016
18 Feb
'16
4:38 a.m.
.. and one more option: -- Enum order specifies the order instances are tried data InstanceChoice = ChooseFirst | ChooseSecond | IgnoreBoth deriving Enum type family Choose a b where Choose Int y = ChooseFirst Choose x Int = ChooseSecond Choose x y = IgnoreBoth class (Choose a b) => Closed a b where fun :: a -> b -> Int instance Closed Int y where fun x _ = x instance Closed x Int where fun _ y = y instance Closed x y where fun _ _ = 0