module Control.Monad.ErrorX.Class (
ErrorX(..),
MonadErrorX(..)
) where
import Control.Monad.Index
class (Index ix) => ErrorX ix a where
noMsgx :: ix -> a
strMsgx :: ix -> String -> a
noMsgx ix = strMsgx ix ""
strMsgx ix _ = noMsgx ix
instance (Index ix) => ErrorX ix String where
noMsgx ix = ""
strMsgx ix _ = noMsgx ix
instance (Index ix) => ErrorX ix IOError where
strMsgx ix = userError
class (Monad m, ErrorX ix e, Index ix) => MonadErrorX ix e m | ix m -> e where
throwErrorx :: ix -> e -> m a
catchErrorx :: ix -> m a -> (e -> m a) -> m a