diff options
Diffstat (limited to 'provider/posts/events')
-rw-r--r-- | provider/posts/events/01.lhs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/provider/posts/events/01.lhs b/provider/posts/events/01.lhs index fd1bd03..01e769e 100644 --- a/provider/posts/events/01.lhs +++ b/provider/posts/events/01.lhs | |||
@@ -73,7 +73,7 @@ We are going to want to parse a specification of some kind into a form we can ru | |||
73 | Below we see one such form. | 73 | Below we see one such form. |
74 | 74 | ||
75 | `ListT`{.haskell} allows for nondeterministic computation – it allows us to split | 75 | `ListT`{.haskell} allows for nondeterministic computation – it allows us to split |
76 | our wordline and continue depth-first much like `[]`{.haskell}. | 76 | our wordline[^worldlineSplits] and continue depth-first much like `[]`{.haskell}. |
77 | 77 | ||
78 | Within every wordline we modify a distinct snapshot of `ObjCtx`{.haskell} we took | 78 | Within every wordline we modify a distinct snapshot of `ObjCtx`{.haskell} we took |
79 | while branching. | 79 | while branching. |
@@ -83,7 +83,7 @@ We also share one `EvalCtx`{.haskell} across all worldlines. | |||
83 | > type Eval m a = StateT ObjCtx (ListT (StateT EvalCtx m)) a | 83 | > type Eval m a = StateT ObjCtx (ListT (StateT EvalCtx m)) a |
84 | 84 | ||
85 | `ListT`{.haskell} does not ship with extensive support for the | 85 | `ListT`{.haskell} does not ship with extensive support for the |
86 | [transformers package][transformers]: | 86 | [transformers package][transformers][^pipes]: |
87 | 87 | ||
88 | > instance MonadState s m => MonadState s (ListT m) where | 88 | > instance MonadState s m => MonadState s (ListT m) where |
89 | > get = lift get | 89 | > get = lift get |
@@ -92,7 +92,7 @@ We also share one `EvalCtx`{.haskell} across all worldlines. | |||
92 | The context shared among all worldlines mainly contains all objects that | 92 | The context shared among all worldlines mainly contains all objects that |
93 | eventually get computed – haskells lazyness ensures that we terminate as | 93 | eventually get computed – haskells lazyness ensures that we terminate as |
94 | long as we don´t have objects depend on themselves in a sufficiently | 94 | long as we don´t have objects depend on themselves in a sufficiently |
95 | degenerate way. | 95 | degenerate way[^degenerate]. |
96 | 96 | ||
97 | > data EvalCtx = EvalCtx | 97 | > data EvalCtx = EvalCtx |
98 | > { _ctxEvents :: [Object] | 98 | > { _ctxEvents :: [Object] |
@@ -105,7 +105,7 @@ degenerate way. | |||
105 | > } | 105 | > } |
106 | 106 | ||
107 | Every wordline constructs exactly one object while having access to a set | 107 | Every wordline constructs exactly one object while having access to a set |
108 | of declarations that can occur anywhere on the wordline. | 108 | of declarations that can occur anywhere on the wordline[^ctxVars]. |
109 | 109 | ||
110 | > data ObjCtx = ObjCtx | 110 | > data ObjCtx = ObjCtx |
111 | > { _objOccurs :: Bool | 111 | > { _objOccurs :: Bool |
@@ -135,8 +135,20 @@ layers to depend on one another: | |||
135 | > where | 135 | > where |
136 | > x' = evalStateT (ListT.toList (objCtx <$> execStateT x def)) . flip (set ctxEvents) def . catMaybes | 136 | > x' = evalStateT (ListT.toList (objCtx <$> execStateT x def)) . flip (set ctxEvents) def . catMaybes |
137 | 137 | ||
138 | [^ctxVars]: In the base version of this file we carry declarations we may refer to when | ||
139 | creating objects (`_objVars`{.haskell}) within `EvalCtx`{.haskell} instead of `ObjCtx`{.haskell}. | ||
140 | Why is that a bad idea? | ||
141 | |||
142 | [^worldlineSplits]: What does such a branching point look like in do notation? | ||
143 | |||
144 | [^pipes]: It has been pointed out to me that `ListT`{.haskell} from [pipes][] does. | ||
145 | |||
146 | [^degenerate]: Constructing an example that doesn´t terminate is trivial. Try constructing one that does while | ||
147 | still being self-referential! | ||
148 | |||
138 | [Google Calendar]: <https://calendar.google.com> | 149 | [Google Calendar]: <https://calendar.google.com> |
139 | [Remind]: <https://www.roaringpenguin.com/products/remind> | 150 | [Remind]: <https://www.roaringpenguin.com/products/remind> |
140 | [JSON]: <https://en.wikipedia.org/wiki/JSON> | 151 | [JSON]: <https://en.wikipedia.org/wiki/JSON> |
141 | [monad transformers]: <https://en.wikibooks.org/wiki/Haskell/Monad_transformers> | 152 | [monad transformers]: <https://en.wikibooks.org/wiki/Haskell/Monad_transformers> |
142 | [transformers]: <https://hackage.haskell.org/package/transformers> | 153 | [transformers]: <https://hackage.haskell.org/package/transformers> |
154 | [pipes]: <https://hackage.haskell.org/package/pipes> | ||