diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-04-16 18:47:53 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-04-16 18:47:53 +0200 |
commit | b32f827fad4620ab02d764389a5a1ade7a4ee1e4 (patch) | |
tree | 9c7f71044922b157efe96730a30af4af6737f996 | |
parent | 91a52b1e265a288b0c425dafcb1fa1098fbd3cc9 (diff) | |
download | events-b32f827fad4620ab02d764389a5a1ade7a4ee1e4.tar events-b32f827fad4620ab02d764389a5a1ade7a4ee1e4.tar.gz events-b32f827fad4620ab02d764389a5a1ade7a4ee1e4.tar.bz2 events-b32f827fad4620ab02d764389a5a1ade7a4ee1e4.tar.xz events-b32f827fad4620ab02d764389a5a1ade7a4ee1e4.zip |
Made context mutable during interpretation
-rw-r--r-- | events/src/Events/Types.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/events/src/Events/Types.hs b/events/src/Events/Types.hs index 1f41454..54aa34d 100644 --- a/events/src/Events/Types.hs +++ b/events/src/Events/Types.hs | |||
@@ -19,7 +19,7 @@ import Data.Aeson (Object) | |||
19 | 19 | ||
20 | import Data.Time.Clock | 20 | import Data.Time.Clock |
21 | 21 | ||
22 | import Control.Monad.Reader | 22 | import Control.Monad.State.Lazy |
23 | import ListT (ListT) | 23 | import ListT (ListT) |
24 | import qualified ListT | 24 | import qualified ListT |
25 | 25 | ||
@@ -54,9 +54,9 @@ instance Default SpecCtx where | |||
54 | , _ctxEvents = mempty | 54 | , _ctxEvents = mempty |
55 | } | 55 | } |
56 | 56 | ||
57 | type Spec m a = ListT (ReaderT SpecCtx m) a | 57 | type Spec m a = ListT (StateT SpecCtx m) a |
58 | 58 | ||
59 | interpret :: MonadFix m => Spec m (Maybe Event) -> m [Event] | 59 | interpret :: MonadFix m => Spec m (Maybe Event) -> m [Event] |
60 | interpret x = catMaybes <$> mfix x' | 60 | interpret x = catMaybes <$> mfix x' |
61 | where | 61 | where |
62 | x' = runReaderT (ListT.toList x) . flip (set ctxEvents) def . catMaybes | 62 | x' = evalStateT (ListT.toList x) . flip (set ctxEvents) def . catMaybes |