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