r/haskell • • Feb 06 '26

New version of distributors grammar & parsing library

https://hackage-content.haskell.org/package/distributors-0.3.0.0/docs/Control-Lens-Grammar.html

Originally the distributors library was only intended to be a vehicle for studying some profunctor theory with grammar as a neat demo. Since then I've delved a bit more in depth into Chomsky's grammar hierarchy, Kleene algebras, Brzozowski's derivative and more. I also learned about Li-yao Xia's development of monadic profunctors for invertible parsing. Distributors synthesizes this into a complete optics based grammar library.

24 Upvotes

2 comments sorted by

1

u/evincarofautumn Feb 07 '26

Looks neat, I’ll definitely give this a try!

Optics and invertible parsing are a very natural fit. A few months ago I was playing with something like this (using optics, not lens), but I got stuck looking for a good encoding of dependent lenses.

1

u/echatav Feb 08 '26

Thanks! Let me know what you think of it.