[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


Hi everyone,

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.

Regards

Rouan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120621/4e85bcb1/attachment.htm>


More information about the Haskell-Cafe mailing list