<div dir="ltr">Not tested but maybe adding an Eq instance to your datatype would help? So try changing 'deriving (Show)' to 'deriving (Show, Eq)'.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 22, 2017 at 2:55 PM, Matt Williams <span dir="ltr"><<a href="mailto:matt.williams45.mw@gmail.com" target="_blank">matt.williams45.mw@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Apologies - sent too soon - code edited below<div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear All,<div><br></div><div>I am having problems writing a polymorphic function.</div><div><br></div><div>I have a type that has two constructors:</div><div><br></div><div><div>data Arg = IndArg {evi::Evi, t1::Treatment, t2::Treatment, out::Outcome, dir::Direction}</div><div>Â Â Â Â Â Â | MetaArg {target::EviType}</div><div>Â Â Â Â Â Â deriving (Show)</div></div><div><br></div><div>I have a function checks for conflict:</div><div><br></div><div><div>checkConflict :: Arg -> Arg -> Bool</div><div>checkConflict a b = if t1 a == t1 b && t2 a == t2 b && dir a /= dir b then True</div><div>Â Â Â Â Â Â Â Â Â Â Â else False<br></div></div><div><br></div><div>However, I can't make this work with both types of Argument - if I pass it MetaArg, it raises an error.</div><div><br></div><div>In another language, I would write something like:</div><div><br></div><div>checkConflict(ArgA,ArgB):</div></div></blockquote></div></div><div>Â Â Â Â Â if type(ArgA) == IndArg:</div><div>Â Â Â Â Â Â Â Â Â <do this></div><div>Â Â Â Â Â elif type(ArgA) == MetaArg:</div><div>Â Â Â Â Â Â Â Â Â <do other></div><div><br></div><div>Any thoughts would be welcomed.</div><div><br></div><div>BW,</div><div>Matt</div><div><br></div></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>