NobbZ
NobbZ

Reputation: 1370

How to stream from an input file into a conduit that has a state

I want to use conduit for reading from a file and then stream it into a tokenizer. The culprit is, that even the same sequence of chars might produce different tokens depending on previous input.

So how can I handle State in a single Conduit inbetween a bunch of IO ones?

Just writing Conduit Char (State TokenizerStateType) Token does yield several errors of wrong types (IO wanted, State got type of errors).

Since I am not at my own computer I can't provide an not-working-minimal-example, but I will add one as soon as I have ghc available.

Upvotes: 2

Views: 139

Answers (1)

Michael Snoyman
Michael Snoyman

Reputation: 31305

I'd recommend using a Conduit Char (StateT TokenizerStateType IO), and using liftIO as necessary to perform IO actions.

Upvotes: 5

Related Questions