packages feed

operational-extra 0.1.0.0 → 0.2

raw patch · 2 files changed

+23/−8 lines, 2 filesdep +transformersdep ~operationaldep ~time

Dependencies added: transformers

Dependency ranges changed: operational, time

Files

operational-extra.cabal view
@@ -1,8 +1,8 @@ name:                operational-extra-version:             0.1.0.0-synopsis:            Initial project template from stack+version:             0.2+synopsis:            Interpretation functions and simple instruction sets for operational description:         Please see README.md-homepage:            http://github.com/andrewthad/vinyl-operational#readme+homepage:            http://github.com/andrewthad/vinyl-ecosystem license:             BSD3 license-file:        LICENSE author:              Andrew Martin@@ -19,8 +19,9 @@                        Control.Monad.Operational.Exception                        Control.Monad.Operational.Now   build-depends:       base >= 4.7 && < 5-                     , operational-                     , time+                     , operational  >= 0.2.3.2+                     , time         >= 1.4+                     , transformers >= 4.0   default-language:    Haskell2010   default-extensions:     RankNTypes@@ -29,4 +30,5 @@  source-repository head   type:     git-  location: https://github.com/andrewthad/vinyl-operational+  location: https://github.com/andrewthad/vinyl-ecosystem+
src/Control/Monad/Operational/Interpret.hs view
@@ -3,6 +3,7 @@ import           Control.Applicative import           Control.Monad import           Control.Monad.Operational+import           Control.Monad.Trans.Class  data Around m instr = Around (forall a. instr a -> (m (), a -> m ())) @@ -13,8 +14,20 @@     (g1,g2) = g instr     in (f1 *> g1, f2 *> g2) -mapProgramT :: Monad m => (forall b. instr1 b -> instr2 b) -> ProgramT instr1 (ProgramT instr2 m) a -> ProgramT instr2 m a-mapProgramT f prog = interpretWithMonadT (singleton . f) prog+mapProgramT :: Monad m +  => (forall b. instr1 b -> instr2 b) -> ProgramT instr1 m a -> ProgramT instr2 m a+mapProgramT f p = do+  v <- lift $ viewT p+  case v of+    Return a -> return a+    i :>>= k -> singleton (f i) >>= mapProgramT f . k++hoistProgramT :: (Monad m, Monad n)+    => (forall a. m a -> n a) -> ProgramT instr m a -> ProgramT instr n a+hoistProgramT f = id' <=< lift . f . viewT+  where+  id' (Return a) = return a+  id' (i :>>= k) = singleton i >>= hoistProgramT f . k  interpretWithMonadT :: forall instr m b. Monad m   => (forall a. instr a -> m a) -> ProgramT instr m b -> m b