Try a bunch of different decoders. page
will try one parser, in the given order. If a parser fails, the next one is tried, but if it succeeds, its result is returned without trying the remaining parsers. If all parsers fail, Parser.oneOf fails. page
Context: [⇒ MiniLatex ⇐ 2023-09-13]
Notice the close correspondence between the production for the nonterminal symbol LatexExpr and the construction of the parser: reading the right-hand side of the first is like reading the argument to oneOf from top to bottom. video
> Reading across the right-hand side of the production is like reading down the code for the parser. So there there's an intimate relationship between these production rules and parser combinators.
In case of our Wiki Module, there seems to be an intimate relationship between eventDecoder and storyDecoder.
eventDecoder code
eventDecoder : Decode.Decoder Event eventDecoder = Decode.oneOf [ Decode.map Create createDecoder , Decode.map Edit editDecoder , Decode.map Add addDecoder , Decode.map Fork forkDecoder -- Add other journal event variants as needed -- remove -- move -- fork -- reference -- roster ]
Note: Reference and roster are not events (or action items) but story item types. Roster is a story item type in the paragraph branch. Reference is one type in the future branch. This error in association or the wrong classification under eventDecoder instead of the correct one under storyDecoder, this confusion underlines the close relationship between event and story decoders.
storyDecoder code
storyDecoder : Decode.Decoder Story storyDecoder = Decode.oneOf [ Decode.map Future futureDecoder , Decode.map Paragraph paragraphDecoder , Decode.map Factory factoryDecoder , Decode.map (\_ -> EmptyContainer) (Decode.succeed EmptyContainer) ]
~
We are representing physical Containers by delimiting Boundaries and basic facts by empty Containers.
Do both intervals become empty at the same time?
DOT FROM lambda-browsing