2 ms·
`Stack -> (Char, Stack)` is equivalent to `(Stack -> Char, Stack -> Stack)`, which amounts to adding a `peek` method to the scheme above. The inclusion of `peek
by Twisol 5y ago
`Stack -> (Char, Stack)` is equivalent to `(Stack -> Char, Stack -> Stack)`, which amounts to adding a `peek` method to the scheme above. The inclusion of `peek` changes nothing about the description of stack mutations above, and its clear separation better maps to what Raph is modeling in the first place.
To be more explicit: Raph is modeling a scene graph, and a traversal of the scene graph consists of a series of pushes and pops on a stack, together with operations on nodes that act on a particular state of the stack. To parallelize these operations we need to be able to access the state of the stack at multiple points along the traversal.
Each operation will use `peek` (and likely `pop`, too, but notice that it doesn't affect other operations here; it's more like moving a cursor down the stack) to drive its own behavior, but those read operations are independent of the traversal itself. It is the traversal we are modeling.