[Haskell-cafe] A Question about IO monad
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...
Size: 818 bytes
Desc: not available
More information about the Haskell-Cafe