<div dir="ltr">Hi,<div><br></div><div>I think the problem is indentation. Write the code this way:</div><div><br></div><div><font face="monospace">data StringOrInt = TisanInt Integer | TisAString String<br><br>instance Eq (StringOrInt) where<br><font color="#ff0000"> (==) (TisanInt v) (TisanInt v') = v == v'<br> (==) (TisAString s) (TisAString s') = s==s'</font></font><font color="#ff0000"><br></font></div><div><br></div><div>where the red lines are indented (it means you have to leave two white spaces at the beginning of those lines).</div><div><br></div><div>Ut</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mer 22 apr 2020 alle ore 21:14 Alexander Chen <<a href="mailto:alexander@chenjia.nl">alexander@chenjia.nl</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:Arial;font-size:13px"><div>hi,</div><div><br></div><div><i>data StringOrInt = TisanInt Int | TisAString String</i></div><div><i><br></i></div><div><i>instance Eq (StringOrInt) where </i></div><div><i>(==) (TisanInt v) (TisanInt v') = v == v'</i></div><div><i>(==) (TisAString s) (TisAString s') = s == s'</i></div><div><i><br></i></div><i><br></i><div><div style="font-family:Arial;font-size:13px"><i>prelude></i></div></div><div style="font-family:Arial;font-size:13px"><i><br></i></div><div><div><i>Instance_testen.hs:4:37: error:</i></div><div><i> Ambiguous occurrence ‘==’</i></div><div><i> It could refer to either ‘Prelude.==’,</i></div><div><i> imported from ‘Prelude’ at Instance_testen.hs:1:1</i></div><div><i> (and originally defined in ‘GHC.Classes’)</i></div><div><i> or ‘Main.==’, defined at Instance_testen.hs:4:1</i></div><div><i> |</i></div><div><i>4 | (==) (TisanInt v) (TisanInt v') = v == v' | ^^</i></div><div><i><br></i></div><div><i>Instance_testen.hs:5:41: error:</i></div><div><i> Ambiguous occurrence ‘==’</i></div><div><i> It could refer to either ‘Prelude.==’,</i></div><div><i> imported from ‘Prelude’ at Instance_testen.hs:1:1</i></div><div><i> (and originally defined in ‘GHC.Classes’)</i></div><div><i> or ‘Main.==’, defined at Instance_testen.hs:4:1</i></div><div><i> |</i></div><div><i>5 | (==) (TisAString s) (TisAString s') = s == s' </i></div><div><i> | ^^</i></div><div><i>[1 of 1] Compiling Main ( Instance_testen.hs, interpreted )</i></div><div><i>Failed, no modules loaded.</i></div><div><i><br></i></div><div><br></div><div><br></div><div><b>what gives?</b></div></div></div>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">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-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>