Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 30 23:16
    Build #120 passed
  • Mar 30 23:16
    njlr opened #55
  • Mar 30 23:12
    njlr forked
    njlr/aether
  • 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
Alojzy Leszcz
@bratfizyk
An example of the field that the API returns:
...
"data": [ [ "2016-12-04",  767.99, 750.0, 758.995, 760.519, 760.519, 760.111, 2376697.26975, 3137.22338 ] ],
...
varon
@varon
You probably want to write some dynamic type checking:
match x with
| :? string as s -> ...
| :? int as i -> ...
| _ -> ...
Alojzy Leszcz
@bratfizyk
I'm not sure - this would result in having the ToJson of type: obj -> Json<unit>. I don't think providing To/From Json for obj is a good practice.
Later I'll take a deeper look into Chiron source code - for sure I'll find some hints there.
varon
@varon
The only valid type for an array that holds differently typed things IS obj.
Alojzy Leszcz
@bratfizyk
Well... that's arguable - I might just create a DU like the one I pasted above and use that to represent my array.
I'm afraid there is however a more serious problem with using obj - correct me if I'm wrong, but I think that in order to use Chiron, I need to put To/FromString definitions in the same assembly where my type is defined. That's why I can't really extend the obj type.
(Again - as I said, correct me if I'm wrong).
Vladimir Sapronov
@vsapronov
Hello Folks! I'm looking for some pure F# library for json (de)serialization. I'm working at some a big F#-based tech-company, so I wonder if I can get quick answers. I also viewed unit tests for Chiron, but I can't find docs, do you have some?
Also: Does Chiron use reflection? Is there any way to customize names of properties that record will be serialized to (without writing full ToJson/FromJson), smth like JsonProperty attribute in Newtonsoft?
Maxime Mangel
@MangelMaxime
@vsapronov Hello, you can find some documentatio on how to use Chiron here: https://xyncro.tech/chiron/guides/links.html
I think you will have to write the ToJson/FromJson because it's "your job" to write how the Json will be wrote
Jonathan Fishbein
@JFishbein1_twitter
Francois Brodeur
@FrankBro
Hi. I'm trying to use something similar to the Epimorphism example but reversed. On the website, the record field is of type string and we transform a Lens<Record, string> into a Prism<Record, int> via an Epimorphism<string, int>.
In my case, my record's field is an integer but the value will be a string. So I would want basically the setter to be protected. Does that make sense?
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 :)