Code Monkey home page Code Monkey logo

elm-optics's People

Contributors

heimdell avatar sparksp avatar

Watchers

 avatar  avatar

Forkers

eparchas

elm-optics's Issues

`c` operator for composition

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 :)

Dictionary "atKey" update

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?

Indexed Traversals?

Curious if you've figured out how to integrate List.indexedMap and friends into this to build up the concept of Indexed Optics?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.