Awesome
Profunctor Lenses
Pure profunctor lenses: a mechanism for updating, viewing, and setting values within nested data structures.
Learn more about profunctor lenses with:
- Practical Profunctor Optics & Lenses in PureScript, a practical introduction to profunctor optics in PureScript
- Lenses for the Mere Mortal, a book about lenses in PureScript
Installation
Install profunctor-lenses
with Spago:
spago install profunctor-lenses
Quick start
> structure = Tuple (Tuple (Tuple "hi!" 3) 2) 1
> import Data.Lens
> _leftmost = _1 <<< _1 <<< _1
> view _leftmost structure
"hi!"
> set _leftmost "Bye!" structure
(Tuple (Tuple (Tuple "Bye!" 3) 2) 1)
> over _leftmost String.toUpper structure
(Tuple (Tuple (Tuple "HI!" 3) 2) 1)
You can try out the examples in the REPL by running:
spago -x examples.dhall repl
Documentation
profunctor-lenses
documentation is stored in a few places:
- Module documentation is published on Pursuit.
- Usage examples can be found in the test suite and
examples
directory. - Practical Profunctor Optics & Lenses in PureScript, a practical introduction to profunctor optics in PureScript
- Lenses for the Mere Mortal, a book about lenses in PureScript
If you get stuck, there are several ways to get help:
- Open an issue if you have encountered a bug or problem.
- Ask general questions on the PureScript Discourse forum or the PureScript Discord chat.
Contributing
You can contribute to profunctor-lenses
in several ways:
-
If you encounter a problem or have a question, please open an issue. We'll do our best to work with you to resolve or answer it.
-
If you would like to contribute code, tests, or documentation, please read the contributor guide. It's a short, helpful introduction to contributing to this library, including development instructions.
-
If you have written a library, tutorial, guide, or other resource based on this package, please share it on the PureScript Discourse! Writing libraries and learning resources are a great way to help this library succeed.