Unresolved top-level overloading with Nothing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Unresolved top-level overloading with Nothing

Adrian May
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.