mirror of
https://github.com/GaloisInc/macaw.git
synced 2024-12-25 15:13:24 +03:00
Add some more helpers for the Generator monad
This commit is contained in:
parent
00f2b1d423
commit
48f556ffcb
@ -11,6 +11,8 @@ module Data.Macaw.PPC.Generator (
|
||||
PPCGenerator,
|
||||
runGenerator,
|
||||
execGenerator,
|
||||
evalGenerator,
|
||||
genResult,
|
||||
Expr(..),
|
||||
BlockSeq(..),
|
||||
PreBlock(..),
|
||||
@ -160,6 +162,16 @@ runGenerator s0 act = ET.runExceptT (St.runStateT (runGen act) s0)
|
||||
execGenerator :: GenState ppc s -> PPCGenerator ppc s () -> ST s (Either GeneratorError (GenState ppc s))
|
||||
execGenerator s0 act = ET.runExceptT (St.execStateT (runGen act) s0)
|
||||
|
||||
evalGenerator :: GenState ppc s -> PPCGenerator ppc s a -> ST s (Either GeneratorError a)
|
||||
evalGenerator s0 act = ET.runExceptT (St.evalStateT (runGen act) s0)
|
||||
|
||||
genResult :: PPCGenerator ppc s (GenResult ppc s)
|
||||
genResult = do
|
||||
s <- St.get
|
||||
return GenResult { resBlockSeq = blockSeq s
|
||||
, resState = Just (s ^. blockState)
|
||||
}
|
||||
|
||||
addStmt :: Stmt ppc s -> PPCGenerator ppc s ()
|
||||
addStmt stmt = (blockState . pBlockStmts) %= (Seq.|> stmt)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user