[Haskell-beginners] instance 2
Alexander Chen
alexander at chenjia.nl
Wed Apr 22 19:13:58 UTC 2020
hi,
data StringOrInt = TisanInt Int | TisAString String
instance Eq (StringOrInt) where
(==) (TisanInt v) (TisanInt v') = v == v'
(==) (TisAString s) (TisAString s') = s == s'
prelude>
Instance_testen.hs:4:37: error:
Ambiguous occurrence ‘==’
It could refer to either ‘Prelude.==’,
imported from ‘Prelude’ at Instance_testen.hs:1:1
(and originally defined in ‘GHC.Classes’)
or ‘Main.==’, defined at Instance_testen.hs:4:1
|
4 | (==) (TisanInt v) (TisanInt v') = v == v' | ^^
Instance_testen.hs:5:41: error:
Ambiguous occurrence ‘==’
It could refer to either ‘Prelude.==’,
imported from ‘Prelude’ at Instance_testen.hs:1:1
(and originally defined in ‘GHC.Classes’)
or ‘Main.==’, defined at Instance_testen.hs:4:1
|
5 | (==) (TisAString s) (TisAString s') = s == s'
| ^^
[1 of 1] Compiling Main ( Instance_testen.hs, interpreted )
Failed, no modules loaded.
what gives?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200422/402a5602/attachment.html>
More information about the Beginners
mailing list