I'm following LYHFGG and I have this
class YesNo a where
yesno :: a -> Bool
instance YesNo Int where
yesno 0 = False
yesno _ = True
but then I have to specify Int here
> yesno (5 :: Int)
True
Just with 5 gives this error
Ambiguous type variable ‘a0’ arising from the literal ‘5’
prevents the constraint ‘(Num a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
I tried this
instance YesNo (Num a) where
yesno 0 = False
yesno _ = True
but got cryptic errors. What can I do to make yesno take any of Num's numbers?
LB
_______________________________________________