|
Hi all,
Why does...
showunjust :: Show a => Maybe a -> String
showunjust Nothing = "Error"
showunjust (Just a) = show a
x = showunjust (Just 5) --this is fine on its own
y = showunjust Nothing --but this barfs
...say...
ERROR "odd.hs":8 - Unresolved top-level overloading
*** Binding : y
*** Outstanding context : Show b
It seems to want Nothing to support Show, but the type signature doesn't require that, and I never called show on it.
Otherwise how can I print Maybes nicely?
Thanks in advance,
Adrian.
|