Module ParseMonad

A Monad for Parsers

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

Version: January 2014

Summary of exported operations:

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

Exported datatypes:


PM

Combining ParseResult and Warnings monads into a new monad

Type synonym: PM a = WM (PR a)


Exported operations:

warnPM :: PR a -> [(Pos,String)] -> WM (PR 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 :: WM (PR a) -> (a -> WM (PR b)) -> WM (PR b)  Deterministic 

Bind

liftPM :: (a -> b) -> WM (PR a) -> WM (PR b)  Deterministic 

Lift

cleanPM :: a -> WM (PR a)  Deterministic 

Return without Warnings or Errors

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

Return without Errors but with Warnings

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

throwPM :: Pos -> String -> WM (PR a)  Deterministic 

Return without Warnings but with Errors

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

throwMultiPM :: Pos -> [String] -> WM (PR a)  Deterministic 

singlePM :: a -> (Pos,String) -> WM (PR a)  Deterministic 

Return without Errors but with one Warning

discardWarningsPM :: WM (PR a) -> PR a  Deterministic 

Remove the Warning Monad from PM

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

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

Extract the Warnings

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

mapWarnsPM :: ((Pos,String) -> (Pos,String)) -> WM (PR a) -> WM (PR a)  Deterministic 

Apply a function on each Warning

crumplePM :: WM (PR (WM (PR a))) -> WM (PR a)  Deterministic 

Crumple two Parser Monads

swapIOPM :: WM (PR (IO a)) -> IO (WM (PR a))  Deterministic 

Swap the PM and the IO Monad

sequencePM :: [WM (PR a)] -> WM (PR [a])  Deterministic 

Join multiple Parser Monads into one

fstPM :: WM (PR (a,b)) -> WM (PR a)  Deterministic 

fst defined on PM

sndPM :: WM (PR (a,b)) -> WM (PR b)  Deterministic 

snd defined on PM

combinePMs :: (a -> b -> c) -> WM (PR a) -> WM (PR b) -> WM (PR c)  Deterministic 

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