Gen.t in Sedlexing

I’ve been migrating my lexer away from ocamllex to Sedlex (to enable lexing of Utf8 files).
However, I’ve seen the stream interface has been deprecated and replaced by from_gen. According to the docs, from_gens signature is char Gen.t -> lexbuf.
In the source, it’s simply a function returning a char option.

Where is the Gen.t type coming from. What is it exactly? Can I open an in_channel as char Gen.t?

Gen.t is a generic iterator provided by the gen library. The Gen.t type is not abstract and is represented as a function unit -> 'a option. So you can either provide your own byte iterator, or use Gen.IO.with_in function.

1 Like

Alright. Got it. I actually found the library, but didn’t realized I should take a look at the dependencies of sedlex, and check whether it depends on it or no. Thanks!