diff options
-rw-r--r-- | events/src/Events/Types.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/events/src/Events/Types.hs b/events/src/Events/Types.hs index 54aa34d..4527fc7 100644 --- a/events/src/Events/Types.hs +++ b/events/src/Events/Types.hs | |||
@@ -6,8 +6,8 @@ | |||
6 | module Events.Types | 6 | module Events.Types |
7 | ( TimeRange(..), rangeStart, rangeDuration | 7 | ( TimeRange(..), rangeStart, rangeDuration |
8 | , Event(..), payload, occursWithin | 8 | , Event(..), payload, occursWithin |
9 | , SpecCtx(..), ctxVars, ctxEvents | 9 | , EvalCtx(..), ctxVars, ctxEvents |
10 | , Spec, interpret | 10 | , Eval, evaluate |
11 | , module Data.Aeson | 11 | , module Data.Aeson |
12 | , module Data.Time.Clock | 12 | , module Data.Time.Clock |
13 | , module Data.Default.Class | 13 | , module Data.Default.Class |
@@ -42,21 +42,21 @@ data Event = Event | |||
42 | } | 42 | } |
43 | makeLenses ''Event | 43 | makeLenses ''Event |
44 | 44 | ||
45 | data SpecCtx = SpecCtx | 45 | data EvalCtx = EvalCtx |
46 | { _ctxVars :: Object | 46 | { _ctxVars :: Object |
47 | , _ctxEvents :: [Event] | 47 | , _ctxEvents :: [Event] |
48 | } | 48 | } |
49 | makeLenses ''SpecCtx | 49 | makeLenses ''EvalCtx |
50 | 50 | ||
51 | instance Default SpecCtx where | 51 | instance Default EvalCtx where |
52 | def = SpecCtx | 52 | def = EvalCtx |
53 | { _ctxVars = mempty | 53 | { _ctxVars = mempty |
54 | , _ctxEvents = mempty | 54 | , _ctxEvents = mempty |
55 | } | 55 | } |
56 | 56 | ||
57 | type Spec m a = ListT (StateT SpecCtx m) a | 57 | type Eval m a = ListT (StateT EvalCtx m) a |
58 | 58 | ||
59 | interpret :: MonadFix m => Spec m (Maybe Event) -> m [Event] | 59 | evaluate :: MonadFix m => Eval m (Maybe Event) -> m [Event] |
60 | interpret x = catMaybes <$> mfix x' | 60 | evaluate x = catMaybes <$> mfix x' |
61 | where | 61 | where |
62 | x' = evalStateT (ListT.toList x) . flip (set ctxEvents) def . catMaybes | 62 | x' = evalStateT (ListT.toList x) . flip (set ctxEvents) def . catMaybes |