Result Monad for Parsers
Author: Jasper Sikorra - jsi@informatik.uni-kiel.de
Version: January 2014
err_unknown_msg
:: String
|
err_unknown_fname
:: String
|
getPErrorPos
:: PError -> Pos
|
getPErrorMsg
:: PError -> String
|
perror
:: Pos -> String -> PError
Construct a PError |
okPR
:: a -> PR a
Return without errors |
throwPR
:: [PError] -> PR a
Return with errors |
bindPR
:: PR a -> (a -> PR b) -> PR b
Bind function |
escapePR
:: PR a -> ([PError] -> IO a) -> IO a
Escape the error monad, basically a catch |
liftPR
:: (a -> b) -> PR a -> PR b
Lift function |
throwUnknownPR
:: PR a
Throw an unknown error |
throwOnePR
:: PError -> PR a
Throw an error with one PError |
throwPMsg
:: Pos -> String -> PR a
Throw an error with one PError that has a position and message |
addErrorsPR
:: PR a -> [PError] -> PR a
Add a list of errors to the Error Monad |
addOneErrorPR
:: PR a -> PError -> PR a
|
swapIOPR
:: PR (IO a) -> IO (PR a)
Swap the PR and the IO Monads |
fstPR
:: PR (a,b) -> PR a
fst defined on the Error Monad |
sndPR
:: PR (a,b) -> PR b
snd defined on the Error Monad |
crumplePR
:: PR (PR a) -> PR a
Crumple two Error Monads |
concatPR
:: PR [a] -> PR [a] -> PR [a]
Join two Error Monads |
combinePRs
:: (a -> b -> c) -> PR a -> PR b -> PR c
Combines two PRs by a given functions |
sequencePR
:: [PR a] -> PR [a]
Join multiple Error Monads into one |
The Error Monad
Constructors:
OK
:: a -> PR a
Errors
:: [PError] -> PR a
Constructors:
PError
:: Pos -> String -> PError
|
|
|
|
Construct a PError
|
Return without errors
|
Return with errors
|
Throw an unknown error
|
Throw an error with one PError
|
Throw an error with one PError that has a position and message
|
Add a list of errors to the Error Monad |
|
Join two Error Monads
|
Combines two PRs by a given functions |
Join multiple Error Monads into one |