Work with a StateT transformator
Closed this issue · 4 comments
It would be nice if we can also use a StateT
monad transformer when walking through the AST and thus keep track of the section, and update the state based on content that we see when "walking" over the tree.
walkM
in Text.Pandoc.Walk works for any monad. So yes, you can use it with a state monad or something else with StateT. Am I missing something in your question?
After rereading, I realized it was missing the most important part: the toJSONFilter
which does not seem to allow effectively walk over this.
The implementation looks like
pandoc-types/src/Text/Pandoc/JSON.hs
Lines 120 to 124 in da9aeed
so probably generalizing it to any monad transformer with IO
as the "outer" one is possible. I will take a look into it.
Yes, maybe we could generalize these to any MonadIO instance.
An alternative approach that should work already would be to use the IO Monad and an IORef for state.