A Monad for Parsers
Author: Jasper Sikorra - jsi@informatik.uni-kiel.de
Version: January 2014
warnPM
:: PR a -> [(Pos,String)] -> WM (PR a)
Encapsulate an Error Monad with a Warning Monad creating a PM Monad |
bindPM
:: WM (PR a) -> (a -> WM (PR b)) -> WM (PR b)
Bind |
liftPM
:: (a -> b) -> WM (PR a) -> WM (PR b)
Lift |
cleanPM
:: a -> WM (PR a)
Return without Warnings or Errors |
warnOKPM
:: a -> [(Pos,String)] -> WM (PR a)
Return without Errors but with Warnings |
throwPM
:: Pos -> String -> WM (PR a)
Return without Warnings but with Errors |
throwMultiPM
:: Pos -> [String] -> WM (PR a)
|
singlePM
:: a -> (Pos,String) -> WM (PR a)
Return without Errors but with one Warning |
discardWarningsPM
:: WM (PR a) -> PR a
Remove the Warning Monad from PM |
getWarningsPM
:: WM (PR a) -> [(Pos,String)]
Extract the Warnings |
mapWarnsPM
:: ((Pos,String) -> (Pos,String)) -> WM (PR a) -> WM (PR a)
Apply a function on each Warning |
crumplePM
:: WM (PR (WM (PR a))) -> WM (PR a)
Crumple two Parser Monads |
swapIOPM
:: WM (PR (IO a)) -> IO (WM (PR a))
Swap the PM and the IO Monad |
sequencePM
:: [WM (PR a)] -> WM (PR [a])
Join multiple Parser Monads into one |
fstPM
:: WM (PR (a,b)) -> WM (PR a)
fst defined on PM |
sndPM
:: WM (PR (a,b)) -> WM (PR b)
snd defined on PM |
combinePMs
:: (a -> b -> c) -> WM (PR a) -> WM (PR b) -> WM (PR c)
combines two PMs by function f, throws error if at least one of the two carries an error |
Combining ParseResult and Warnings monads into a new monad
Type synonym: PM a = WM (PR a)
Encapsulate an Error Monad with a Warning Monad creating a PM Monad
|
Return without Errors but with Warnings
|
Return without Warnings but with Errors
|
|
Remove the Warning Monad from PM
|
Extract the Warnings
|
Apply a function on each Warning |
Join multiple Parser Monads into one |