2
{-# LANGUAGE FlexibleInstances #-}
3
{-# LANGUAGE TypeSynonymInstances #-}
5
------------------------------------------------------------------------------
6
-- | Wrapper for Control.Monad.Except from the mtl package
7
------------------------------------------------------------------------------
9
module Agda.Utils.Except
10
( Error(noMsg, strMsg)
13
, MonadError(catchError, throwError)
17
------------------------------------------------------------------------
18
#if MIN_VERSION_mtl(2,2,1)
19
-- New mtl, reexport ExceptT, define class Error for backward compat.
20
------------------------------------------------------------------------
22
import Control.Monad.Except
24
-- | We cannot define data constructors synonymous, so we define the
25
-- @mkExceptT@ function to be used instead of the data constructor
27
mkExceptT :: m (Either e a) -> ExceptT e m a
30
-- From Control.Monad.Trans.Error of transformers 0.3.0.0.
39
-- | A string can be thrown as an error.
40
instance Error String where
43
------------------------------------------------------------------------
45
-- Old mtl, need to define ExceptT from ErrorT
46
------------------------------------------------------------------------
48
import Control.Monad.Error
52
-- | We cannot define data constructors synonymous, so we define the
53
-- @mkExceptT@ function to be used instead of the data constructor
55
mkExceptT :: m (Either e a) -> ExceptT e m a
58
-- | 'runExcept' function using mtl 2.1.*.
59
runExceptT :: ExceptT e m a -> m (Either e a)
60
runExceptT = runErrorT