Module CPP.ICode.ParseMonad

A Monad for Parsers

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

Version: September 2022

Summary of exported operations:

warnPM :: PR a -> [(Pos,String)] -> PM a  Deterministic 
Encapsulate an Error Monad with a Warning Monad creating a PM Monad
bindPM :: PM a -> (a -> PM b) -> PM b  Deterministic 
Bind
liftPM :: (a -> b) -> PM a -> PM b  Deterministic 
Lift
cleanPM :: a -> PM a  Deterministic 
Return without Warnings or Errors
warnOKPM :: a -> [(Pos,String)] -> PM a  Deterministic 
Return without Errors but with Warnings
throwPM :: Pos -> String -> PM a  Deterministic 
Return without Warnings but with Errors
throwMultiPM :: Pos -> [String] -> PM a  Deterministic 
singlePM :: a -> (Pos,String) -> PM a  Deterministic 
Return without Errors but with one Warning
discardWarningsPM :: PM a -> PR a  Deterministic 
Remove the Warning Monad from PM
getWarningsPM :: PM a -> [(Pos,String)]  Deterministic 
Extract the Warnings
mapWarnsPM :: ((Pos,String) -> (Pos,String)) -> PM a -> PM a  Deterministic 
Apply a function on each Warning
crumplePM :: PM (PM a) -> PM a  Deterministic 
Crumple two Parser Monads
swapIOPM :: PM (IO a) -> IO (PM a)  Deterministic 
Swap the PM and the IO Monad
sequencePM :: [PM a] -> PM [a]  Deterministic 
Join multiple Parser Monads into one
fstPM :: PM (a,b) -> PM a  Deterministic 
fst defined on PM
sndPM :: PM (a,b) -> PM b  Deterministic 
snd defined on PM
combinePMs :: (a -> b -> c) -> PM a -> PM b -> PM c  Deterministic 
combines two PMs by function f, throws error if at least one of the two carries an error

Exported datatypes:


newtype PM

Combining ParseResult and Warnings monads into a new monad

Constructor:

  • PM :: (WM (PR a)) -> PM a

Exported operations:

warnPM :: PR a -> [(Pos,String)] -> PM a  Deterministic 

Encapsulate an Error Monad with a Warning Monad creating a PM Monad

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

bindPM :: PM a -> (a -> PM b) -> PM b  Deterministic 

Bind

liftPM :: (a -> b) -> PM a -> PM b  Deterministic 

Lift

cleanPM :: a -> PM a  Deterministic 

Return without Warnings or Errors

warnOKPM :: a -> [(Pos,String)] -> PM a  Deterministic 

Return without Errors but with Warnings

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

throwPM :: Pos -> String -> PM a  Deterministic 

Return without Warnings but with Errors

throwMultiPM :: Pos -> [String] -> PM a  Deterministic 

singlePM :: a -> (Pos,String) -> PM a  Deterministic 

Return without Errors but with one Warning

discardWarningsPM :: PM a -> PR a  Deterministic 

Remove the Warning Monad from PM

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

getWarningsPM :: PM a -> [(Pos,String)]  Deterministic 

Extract the Warnings

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

mapWarnsPM :: ((Pos,String) -> (Pos,String)) -> PM a -> PM a  Deterministic 

Apply a function on each Warning

crumplePM :: PM (PM a) -> PM a  Deterministic 

Crumple two Parser Monads

swapIOPM :: PM (IO a) -> IO (PM a)  Deterministic 

Swap the PM and the IO Monad

sequencePM :: [PM a] -> PM [a]  Deterministic 

Join multiple Parser Monads into one

fstPM :: PM (a,b) -> PM a  Deterministic 

fst defined on PM

sndPM :: PM (a,b) -> PM b  Deterministic 

snd defined on PM

combinePMs :: (a -> b -> c) -> PM a -> PM b -> PM c  Deterministic 

combines two PMs by function f, throws error if at least one of the two carries an error