[Haskell-cafe] Why does Enum succ and pred functions throw exception
Rouan van Dalen
rvdalen at yahoo.co.uk
Thu Jun 21 11:11:24 CEST 2012
Can anyone shed some light on why the succ and pred functions of the Enum typeclass throw
exceptions if we go over the upper or lower boundary, and not return Maybe a?
I was hoping to have some functions like:
safeSucc :: (Enum a) => a -> Maybe a
Because the succ and pred functions throw exceptions I can only catch them in
the IO monad. This makes it hard to deal with this situation in pure code.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe