heimdell / elm-optics Goto Github PK
View Code? Open in Web Editor NEWA faithful for of `lens` to Elm
License: BSD 3-Clause "New" or "Revised" License
A faithful for of `lens` to Elm
License: BSD 3-Clause "New" or "Revised" License
Hi, I briefly looked at your package and it seems to be quite similar to https://package.elm-lang.org/packages/arturopala/elm-monocle/latest/. To help people decide which package to use, maybe your readme could have a quick explanation for why or why not to use your package over elm-monocle?
Hi, love the way your lib tackles optics with Elm, especially composition (I'm the guy that wrote the Compose
module in elm-monocle
๐
), but there's one thing I'd like to add: a flipped version of the o
operator (which we could name c
?).
Why?
Consider this in the REAMDE's examples:
(o (o dictValues components_)
(o each (o first (o just_ y_))))
At first glance, it's hard to tell what this is doing. Now let's straighten it out a bit with the forward operator:
y_
|> o just_
|> o first
|> o each
|> o components_
|> o dictValues
It's fine... but it goes in reverse kind of, starting from the "inwards" most optic to the "outwards" most. Feels a bit like holding a spyglass in reverse.
Now consider this:
dictValues
|> c components_
|> c each
|> c first
|> c just_
|> c y_
Here we see we start traversing dictValues
, going inside the components_
field of those values, traversing each
tuple taking the first
value and searching for just_
something that has a y_
field.
Sure, we can already do that with:
o dictValues
<| o components_
<| o each
<| o first
<| o just_ y_
But it looks a bit less readable to me, with the last line having 2 optics to compose and all.
So, what do you think?
I'll send an MR if you like the idea :)
Hello and thanks for the great library!
This is more of a question than an issue. I am trying to update the value of a Dictionary at a specific key
and I have been using atKey
with no success. Here is the code
> Dict.fromList [("a", 5)] |> assign (atKey "a") 10
Dict.fromList [("a",5)]
: Dict String number
Nothing changes in the returned dictionary. Same is true when using over
What am I doing wrong?
Curious if you've figured out how to integrate List.indexedMap
and friends into this to build up the concept of Indexed Optics?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.