]> Git — Sourcephile - haskell/symantic.git/blob - symantic-grammar/Language/Symantic/Grammar/Error.hs
Rename source -> withSource, and g_*.
[haskell/symantic.git] / symantic-grammar / Language / Symantic / Grammar / Error.hs
1 {-# LANGUAGE TypeApplications #-}
2 module Language.Symantic.Grammar.Error where
3
4 import Data.Proxy (Proxy)
5
6 -- * Class 'Inj_Error'
7 class Inj_Error a b where
8 inj_Error :: a -> b
9 instance Inj_Error err e => Inj_Error err (Either e a) where
10 inj_Error = Left . inj_Error
11
12 liftError ::
13 forall e0 err e1 a.
14 Inj_Error e0 e1 =>
15 Inj_Error e1 err =>
16 Proxy e1 -> Either e0 a -> Either err a
17 liftError _e1 (Right a) = Right a
18 liftError _e1 (Left e) = Left $ inj_Error @e1 @err $ inj_Error @e0 @e1 e