haskell - Examples of monadic effects inside a rewrite function in Hoopl? -


the type of (forward) rewriting functions in hoopl given mkfrewrite function:

mkfrewrite :: (fuelmonad m) =>     (forall e x.       n e x       -> f       -> m (maybe (hoopl-3.8.6.1:compiler.hoopl.dataflow.graph n e x)))    -> fwdrewrite m n f 

the m type implies can use monadic effects while rewriting. paper "hoopl: modular, reusable library dataflow analysis , transformation" says same in section 4.3, "the rewrite function , client's monad."

can give me example of rewrite function has non-hoopl monadic effects embedded inside it? example, rewriter uses state monad or io.

this should pretty simple, chase types.

you want value of fwdrewrite m n f custom value of m, can pass following function:

analyzeandrewritefwd ::   forall m n f e x entries.     (checkpointmonad m,      nonlocal n,      labelsptr entries) =>   fwdpass m n f ->   maybec e entries ->   graph n e x ->   fact e f ->   m (graph n e x, factbase f, maybeo x f) 

so constraint on m have is checkpointmonad; when run pass you'll final monadic value can run yourself.

in fact, ghc's hoopl passes use m simpluniqmonad, can fresh labels while we're operating on graph.

{-# language typesynonyminstances #-} {-# language typefamilies #-}  import compiler.hoopl import control.monad.state  type statefuel s = checkingfuelmonad (state s)  instance checkpointmonad (state s)     type checkpoint (state s) = s     checkpoint =     restart = put 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -