
22 Sep
2017
22 Sep
'17
3:53 p.m.
Dear All, I am having problems writing a polymorphic function. I have a type that has two constructors: data Arg = IndArg {evi::Evi, t1::Treatment, t2::Treatment, out::Outcome, dir::Direction} | MetaArg {target::EviType} deriving (Show) I have a function checks for conflict: checkConflict :: Arg -> Arg -> Bool checkConflict a b = if t1 a == t1 b && t2 a == t2 b && dir a /= dir b then True else False However, I can't make this work with both types of Argument - if I pass it MetaArg, it raises an error. In another language, I would write something like: checkConflict(ArgA,ArgB):