{-# LANGUAGE TypeApplications #-} module Language.Symantic.Grammar.Error where import Data.Either (Either(..)) import Data.Function (($), (.)) import Data.Proxy (Proxy) -- * Class 'ErrorInj' class ErrorInj a b where errorInj :: a -> b instance ErrorInj err e => ErrorInj err (Either e a) where errorInj = Left . errorInj liftError :: forall e0 err e1 a. ErrorInj e0 e1 => ErrorInj e1 err => Proxy e1 -> Either e0 a -> Either err a liftError _e1 (Right a) = Right a liftError _e1 (Left e) = Left $ errorInj @e1 @err $ errorInj @e0 @e1 e