[Haskell-cafe] A Question about IO monad

Nikita Karetnikov nikita at karetnikov.org
Sun Mar 1 14:07:59 UTC 2015

>> A tiny nitpick: you can get a total function if you return a default
>> value instead of erroring out.
> What default value would you return for the function `Maybe a -> a`?

You can do it with unsafeCoerce, but there are restrictions.  And that's
not what I meant, sorry.  I mentally substituted an a for an Int:

f :: Maybe Int -> Int
f (Just x) = x
f Nothing  = 0

And there's also the maybe function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150301/d7ed281d/attachment.sig>

More information about the Haskell-Cafe mailing list