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   
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

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   

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

err_unknown_fname :: String   

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

getPErrorPos :: PError -> Pos   

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

getPErrorMsg :: PError -> String   

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

perror :: Pos -> String -> PError   

Construct a PError

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

okPR :: a -> PR a   

Return without errors

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

throwPR :: [PError] -> PR a   

Return with errors

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

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

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

throwOnePR :: PError -> PR a   

Throw an error with one PError

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

throwPMsg :: Pos -> String -> PR a   

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   

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

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

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