The Error Monad

The All About Monads in the Haskell Wiki says

class Error a where
  noMsg :: a
  strMsg :: String -> a

class (Monad m) => MonadError e m | m -> e where
  throwError :: e -> m a
  catchError :: m a -> (e -> m a) -> m a

Trying to understand this, my question is: is “e” an exception type and presupposes that exceptions are built in to the language?

presupposes that exceptions are built in to the language

No

is “e” an exception type

Yes or no, depending on what you mean by “an exception type”. It’s not “a type of exception which is built into the language” but the type that you want to be able to throw. It could be String, Text, Int, a user defined data type, anything at all.

2 Likes