You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Writing intermediate transformations or lenses is cumbersome because of the need to do explicit state-passing. Normally, you'd want to simplify this using StateT, however the problem is that you don't get a type suitable for Parser. The type you want is:
StateT (Producer a m x) (Producer b m) r
... but that doesn't unify with Parser, so you can't embed Parsers within such a StateT block.
However, the solution is simple: you can wrap any Parser in hoist lift and then it will have the correct type:
parser::StateT (Produceramx) mr
hoist lift parser ::StateT (Produceramx) (Producerbm) r
Then you can write transformations/lenses using StateT to manage all state-passing and still embed parsers within those blocks.
This ticket is to remind myself to update the documentation to explain this trick and to update the source code to use this trick, too.
The text was updated successfully, but these errors were encountered:
Writing intermediate transformations or lenses is cumbersome because of the need to do explicit state-passing. Normally, you'd want to simplify this using
StateT
, however the problem is that you don't get a type suitable forParser
. The type you want is:... but that doesn't unify with
Parser
, so you can't embedParser
s within such aStateT
block.However, the solution is simple: you can wrap any
Parser
inhoist lift
and then it will have the correct type:Then you can write transformations/lenses using
StateT
to manage all state-passing and still embed parsers within those blocks.This ticket is to remind myself to update the documentation to explain this trick and to update the source code to use this trick, too.
The text was updated successfully, but these errors were encountered: