-
-
Save dminuoso/be53ec068306073650802d157ea02e5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Proceed only if there are no errors. Will error out otherwise. | |
(>|>) :: Comp e a -> Comp e b -> Comp e b | |
f >|> g = condemn f >> g | |
-- | Proceed only if there are no errors. Will error out otherwise. | |
(>|>=) :: Comp e a -> (a -> Comp e b) -> Comp e b | |
x >|>= f = condemn x >>= f | |
-- | Sequence only if there are no errors, skips the other action otherwise. | |
-- | |
-- This is useful for skipping semantic checks that depend on invariants asserted | |
-- by an earlier pass. | |
(>?>) :: Comp e a -> Comp e a -> Comp e a | |
l >?> r = do | |
m <- l | |
e <- askErrors | |
case e of | |
[] -> r | |
_s -> pure m | |
condemn :: Comp e a -> Comp e a | |
condemn act = act <* cut | |
cut :: Comp e () | |
cut = do | |
e <- askErrors | |
case e of | |
[] -> pure () | |
_xs -> throwIO BailOut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment