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