purescript-contrib / purescript-profunctor-lenses

Pure profunctor lenses
MIT License
144 stars 52 forks source link

Some rudimentary interaction with state monads. #19

Closed zrho closed 8 years ago

zrho commented 8 years ago

One very useful thing about lenses is how they can be used in combination with state monads; this allows seemingly imperative programming on the state encapsulated by the monad. To make this happen, I added a few combinators for Setters and Getters and the ability to zoom into a StateT.

zrho commented 8 years ago

Oh, it appears that pull requests also automatically include commits that have been added later. So this also includes re, which gives you the inverse of an Iso or a Prism. For that I had to change Getters to use (the isomorphic profunctor) Forget r instead of Star (Const r), since the first can cleanly be given a Cochoice instance in a strict language.

paf31 commented 8 years ago

Great stuff, thanks!