Module ParseError

Result Monad for Parsers

Author: Jasper Sikorra - jsi@informatik.uni-kiel.de

Version: January 2014

Summary of exported operations:

err_unknown_msg :: String  Deterministic 
err_unknown_fname :: String  Deterministic 
getPErrorPos :: PError -> Pos  Deterministic 
getPErrorMsg :: PError -> String  Deterministic 
perror :: Pos -> String -> PError  Deterministic 
Construct a PError
okPR :: a -> PR a  Deterministic 
Return without errors
throwPR :: [PError] -> PR a  Deterministic 
Return with errors
bindPR :: PR a -> (a -> PR b) -> PR b  Deterministic 
Bind function
escapePR :: PR a -> ([PError] -> IO a) -> IO a  Deterministic 
Escape the error monad, basically a catch
liftPR :: (a -> b) -> PR a -> PR b  Deterministic 
Lift function
throwUnknownPR :: PR a  Deterministic 
Throw an unknown error
throwOnePR :: PError -> PR a  Deterministic 
Throw an error with one PError
throwPMsg :: Pos -> String -> PR a  Deterministic 
Throw an error with one PError that has a position and message
addErrorsPR :: PR a -> [PError] -> PR a  Deterministic 
Add a list of errors to the Error Monad
addOneErrorPR :: PR a -> PError -> PR a  Deterministic 
swapIOPR :: PR (IO a) -> IO (PR a)  Deterministic 
Swap the PR and the IO Monads
fstPR :: PR (a,b) -> PR a  Deterministic 
fst defined on the Error Monad
sndPR :: PR (a,b) -> PR b  Deterministic 
snd defined on the Error Monad
crumplePR :: PR (PR a) -> PR a  Deterministic 
Crumple two Error Monads
concatPR :: PR [a] -> PR [a] -> PR [a]  Deterministic 
Join two Error Monads
combinePRs :: (a -> b -> c) -> PR a -> PR b -> PR c  Deterministic 
Combines two PRs by a given functions
sequencePR :: [PR a] -> PR [a]  Deterministic 
Join multiple Error Monads into one

Exported datatypes:


PR

The Error Monad

Constructors:

  • OK :: a -> PR a
  • Errors :: [PError] -> PR a

PError

Constructors:

  • PError :: Pos -> String -> PError

Exported operations:

err_unknown_msg :: String  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

err_unknown_fname :: String  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

getPErrorPos :: PError -> Pos  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

getPErrorMsg :: PError -> String  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

perror :: Pos -> String -> PError  Deterministic 

Construct a PError

Further infos:
  • solution complete, i.e., able to compute all solutions

okPR :: a -> PR a  Deterministic 

Return without errors

Further infos:
  • solution complete, i.e., able to compute all solutions

throwPR :: [PError] -> PR a  Deterministic 

Return with errors

Further infos:
  • solution complete, i.e., able to compute all solutions

bindPR :: PR a -> (a -> PR b) -> PR b  Deterministic 

Bind function

escapePR :: PR a -> ([PError] -> IO a) -> IO a  Deterministic 

Escape the error monad, basically a catch

liftPR :: (a -> b) -> PR a -> PR b  Deterministic 

Lift function

throwUnknownPR :: PR a  Deterministic 

Throw an unknown error

Further infos:
  • solution complete, i.e., able to compute all solutions

throwOnePR :: PError -> PR a  Deterministic 

Throw an error with one PError

Further infos:
  • solution complete, i.e., able to compute all solutions

throwPMsg :: Pos -> String -> PR a  Deterministic 

Throw an error with one PError that has a position and message

Further infos:
  • solution complete, i.e., able to compute all solutions

addErrorsPR :: PR a -> [PError] -> PR a  Deterministic 

Add a list of errors to the Error Monad

addOneErrorPR :: PR a -> PError -> PR a  Deterministic 

swapIOPR :: PR (IO a) -> IO (PR a)  Deterministic 

Swap the PR and the IO Monads

fstPR :: PR (a,b) -> PR a  Deterministic 

fst defined on the Error Monad

sndPR :: PR (a,b) -> PR b  Deterministic 

snd defined on the Error Monad

crumplePR :: PR (PR a) -> PR a  Deterministic 

Crumple two Error Monads

concatPR :: PR [a] -> PR [a] -> PR [a]  Deterministic 

Join two Error Monads

Further infos:
  • solution complete, i.e., able to compute all solutions

combinePRs :: (a -> b -> c) -> PR a -> PR b -> PR c  Deterministic 

Combines two PRs by a given functions

sequencePR :: [PR a] -> PR [a]  Deterministic 

Join multiple Error Monads into one