Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jan 24 21:40
  • Jan 06 02:38
  • Dec 15 2019 20:06
    Mateiadrielrafael closed #54
  • Dec 15 2019 20:06
    Mateiadrielrafael commented #54
  • Dec 14 2019 16:30
    varon commented #54
  • Dec 08 2019 19:50
    Mateiadrielrafael opened #54
  • Nov 23 2019 12:00
    njlr edited #53
  • Nov 22 2019 23:41
    njlr opened #53
  • Nov 14 2019 15:39
    stroborobo closed #52
  • Nov 14 2019 15:39
    stroborobo commented #52
  • Sep 14 2019 03:59
  • Mar 29 2019 20:09
    et1975 commented #52
  • Mar 29 2019 14:54
    panesofglass commented #52
  • Mar 29 2019 12:21
    stroborobo commented #52
  • Mar 29 2019 12:17
    et1975 commented #52
  • Mar 29 2019 11:44
    stroborobo commented #52
  • Mar 29 2019 10:44
    Build #119 passed
  • Mar 29 2019 10:44
    stroborobo edited #52
  • Mar 29 2019 10:43
    stroborobo opened #52
  • Mar 29 2019 10:35
So my first intro to lenses was aether, and I'm not too around the theory, but we have prism defined as Prism<'a,'b>: ('a->'b option),('a->'b->'a). I can somewhat intuit that, but sometimes I feel like I want to reach for something of the form Prism<'a,'b>: ('a-> Result<'b,string>),('a->'b->'a)
With the idea that the Prism ultimatelty tells us which part in the tree is missing
So when one goes Optic.get lens data we get Result<'a,string> with an error message about why the lens failed. (Which would be handy in logging)
Am I insane/missing the point?
Pete Johanson
Shouldn't be too hard to write a function to compose prisms/lenses that way.
What are you trying to achieve by discovering where the None started in the chain?
May be slightly nicer to have the TError be a string list instead, that gets the chain appended too.
Usually I've been using aether + chiron together. To parse into my own datastructures, it would be nice to debug how and why a lense failed to get a value
At the moment I find myself writing a would bunch of Result<'a,'b> code after I get specific parts of objects
morning, I have a |> List.mapi on a list of a record type
If I want to assign (change) a member in the mapi fun, should I use a lens ?
Pete Johanson
You certainly could. A lens will be more helpful if you're trying to change something ' in the record.
oh... deeper... you right
in this case maybe I just need record overload syntax thank you
Pete Johanson
Yeah, also depends if you've already got lenses for your types defined, might as well use them.
Justin Rawlings
Apologies if this has been asked before, but is there a way to use lenses to map between generic types? Something like this:
open Aether

let a : int option = Some 3

// This does not compile
let b : string option =
    |> Optic.map Option.value_ string
@jmjrawlings - This is a super late answer but...
Just map over the containing type.
a |> Option.map string
you don't need lenses in that case.
If you wanted to do it with lenses:
        let a : int option = Some 3

        let b : string option =
            a |> Optic.map string Option.value_
Hi - how do I use chiron to query values from json data?
sorry wrong room
Torben Clasen
If I have multiple Values inside of my Record that I want to use Optics to update. Could anyone be so kind to whip up a short example?