Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 20 20:18
    cmeeren edited #57
  • Oct 20 20:18
    cmeeren edited #57
  • Oct 20 20:17
    cmeeren opened #57
  • Oct 07 10:50
    Dzoukr commented #56
  • Aug 26 22:29
    et1975 commented #56
  • Aug 25 21:19
    njlr commented #56
  • Aug 25 20:44
    njlr commented #56
  • Aug 25 05:48
    landy commented #56
  • Aug 24 22:12
    et1975 commented #56
  • Aug 24 11:56
    njlr commented #56
  • Aug 06 11:50
    landy commented #56
  • Aug 06 11:32
    et1975 commented #56
  • Aug 06 08:35
    Build #122 passed
  • Aug 06 08:35
    landy opened #56
  • Aug 05 21:18
  • May 12 18:46
    Build #121 passed
  • May 12 18:45

    panesofglass on master

    Update README.md Adds direct i… Merge pull request #55 from njl… (compare)

  • May 12 18:45
    panesofglass closed #55
  • Mar 30 23:16
    Build #120 passed
  • Mar 30 23:16
    njlr opened #55
varon
@varon
@FrankBro is an optic with a protected setter really an optic?
You can't really achieve composition with it. I'd generally advise either using a prism to handle the possibility of failure, or just a plain-old function.
Francois Brodeur
@FrankBro
Alright, you might be right. I'll rethink this.
Alexandr Sugak
@AlexSugak
Hello! How can I generate json with duplicated keys (don't ask me why) using Chiron ?
E.g. I want this to produce json with two "bar" keys, each with its own value:
    type MyType =
        {
            A: string
            B: (string*int) list
        }
        static member ToJson(t: MyType) =
            let writeB bs j = bs |> List.fold (fun json (b1, b2) -> json *> Json.write b1 b2) j
            Json.write "a" t.A
            |> writeB t.B

    let b = {A="foo";B=[("bar", 1);("bar", 2)]}
    b |> Json.serialize |> Json.format
varon
@varon
Is that even valid json, @AlexSugak ?
If it's some external API you need to work with... I think it's time for a "we need to talk" email to the developers.
Alexandr Sugak
@AlexSugak
I guess I made a misstake choosing json out of familiality in the first place. should probably use xml
varon
@varon
My advice would be to try use a list instead of multiple delete commands.
Failing that, can you not just send individual commands, etc?
Let's not ask about why they're using JSON commands in the first place for an HTTP API. Didn't RPC die years ago?
Alexandr Sugak
@AlexSugak
@varon yes, I am testing right now with a list to see if it works. As for individual commands, I need to do a batch update of multiple documents in one operation
varon
@varon
also, wait, how does this question remotely relate to lenses?
shouldn't it be in the chiron channel?
Alexandr Sugak
@AlexSugak
as for "valideness", I didn't think about it initially but it looks like the answer is not that simple https://stackoverflow.com/questions/21832701/does-json-syntax-allow-duplicate-keys-in-an-object
sorry, I followed the link here from Chiron site. do we have a dedicated channel for chiron?
varon
@varon
could probably PR in a link fix, it's likely copied from the aether page.
Alexandr Sugak
@AlexSugak
@varon ok will do, thanks!
funlambda
@funlambda
is there a way for me to use Aether with ToJson/FromJson methods defined in a different assembly than the types I want to convert to/from JSON?
use Chiron*
I have a Core project that contains my "domain" types, and I can't have it reference Chiron since it needs to also compile to JS via Fable
I want to use Chiron to define mapping from these domain types to JSON, but the mapping needs to be defined in a separate server-only assembly
funlambda
@funlambda
oops, didn't realize there was a separate room for Chiron. please ignore -- will repost there
Roman Provazník
@Dzoukr
hi guys, I recently came to Chiron and I love it! I found that I can use function serializeWith and pass it custom mapping function instead of having static member ToJson, which is great. But there is no deserializeWith? Did anyone know why is it missing? I suppose it is by design so I am just curious, what is the internal reason? :)
Alexander Prooks
@aprooks
hi, that's a quick guess but deserialize receives parsed nested json representation. You can use your own function here
parsed |> myDeserialize
and there is a chiron dedicated channel ;)
Roman Provazník
@Dzoukr
oh, is there? :) thanks and sorry
btrepp
@btrepp

does anyone have any clever ideas about making lenses out of record types automatically? say with a type provider?. I don't know enough about type providers but it would be cool to do things like

type MyRecord = { property : string} 

....
MyRecord.property_ : Lens<MyRecord,string>

This can be declared simply enough with

module MyRecord = 
    let property_ : Lens<MyRecord,string> = (fun s -> s.property),(fun v s -> {s with property = v})

But that always looks the same for every property, so would be neat if it could be automatic :)

Ibnu Daru Aji
@ibnuda
Reflection?
Robin Munn
@rmunn
@btrepp - There's an RFC for expanding the capabilities of type proviers, currently in early proof-of-concept stage. Making lenses from record types automatically via a type provider was one of the use cases mentioned. Keep an eye on that one, and contribute if you're able to so that it gets completed faster, and that should be what you're looking for here.
btrepp
@btrepp
@rmunn Thanks!. Thats pretty exciting really. I will keep an eye on it.
btrepp
@btrepp
@Danl2620 serialize into what? (json?) there is a chiron gitter channel :)
Dan Liebgold
@Danl2620
(moved to xynchro/chiron)
varon
@varon
@kolektiv - xyncro/aether#47
Wojtek
@wklm
Hey Everyone :)
Could someone suggest a good example for working with nested jsons with chiron?
varon
@varon
@wklm - this is the aether channel. try the chiron one.
Wojtek
@wklm
@varon sorry, I chiron docs are pointing here
varon
@varon
no worries, probably needs a PR to fix that link
Wojtek
@wklm
:+1:
btrepp
@btrepp
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
@petejohanson
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.
btrepp
@btrepp
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