by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
  • 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
Alojzy Leszcz
@bratfizyk
sorry for the false alarm
Andrew Cherry
@kolektiv
no problem :)
Alojzy Leszcz
@bratfizyk
Heya - about the unit feature testing: so far so good
Andrew Cherry
@kolektiv
:) sounds good!
Stefan Reichel
@stefan-akelius
This message was deleted
btrepp
@btrepp

With lenses and prisms, is there a guide in which it is appropriate to use either?. are prisms mainly for nested datastructures?. In freya the IfMatch_ header is returned as an IfMatch option Lens, rather than an IfMatch prism.

Say i wanted to deal with some nested values, it would make sense to use an epimorphism eg ifmatchweaktag_: Epimorphism<IfMatch,EntityTag.Weak>
But then with IfMatch itself being a Lens<IfMatch option> this doesn't compose.

I have written a composing epimorphism

      let private toPrism_ : Epimorphism<'T option, 'T> = (fun x -> x),
                                                            (fun v -> Some v)

but I'm not sure if this is idiomatic. I ask because I have my own lens in freya for the ClaimsPrincipal Lens<State,ClaimsPrincipal option>, which I can see the advantage for (eg my middeware could remove the claims principal if it wants to), but then most uses I can think of would want Prism<State,ClaimsPrincipal>.

varon
@varon
@btrepp Andrew will have a better answer, but from my experience, there's no harm in providing both.
Especially if you're providing a library, it can be a lot easier to work with if the lenses/prisms already exist.
Jon Schoning
@jonschoning

https://xyncro.tech/aether/guides/morphisms.html

type Epimorphism<'a,'b> = ('a -> 'b option) * ('b -> 'a)
My understanding of epi is that it is morally surjective; wouldn't a function from 'a to 'b always have to succeed/produce a value then, because surjection means that the entire codomain receives a value?

Jon Schoning
@jonschoning
i think it makes sense if we're considering the function from going from the preimage of 'a instead of the domain of 'a, then in that case there could be values in the domain of 'a that the function doesn't act on
Jon Schoning
@jonschoning
epimorphism would look more like ('a -> 'b) * ('b -> NonEmptySeq<'a>)
Alojzy Leszcz
@bratfizyk
Hi Andrew. About the Defaults for unit type - no problems from my side. Just deployed a new version of my service to my testing environment. Should be safe to remove the "rc" label (hopefully I won't regret saying that ;) ).
Andrew Cherry
@kolektiv
i haven't noticed any issues, so hopefully... :) i'll push to general release later when i get a moment!
Eugene Tolmachev
@et1975
@kolektiv Aether gets a Fable build: https://github.com/et1975/fable-aether/
hope you don't mind
varon
@varon
It's great to see Aether included in more places!
Maxime Mangel
@MangelMaxime

Hello guys :)
Is it possible to write something like that:

        let m' =
          model
          |> Optic.set (Model.Name_ >-> StringField.Value_) data.Name
          |> Optic.set Model.PatientPermissions_ data.PatientPermissions

My problem is the last line which is getting an error because Model.PatientPermissions_ don't have supported overload.
I could write it with standard record update but would look less "fluid" :)

Alojzy Leszcz
@bratfizyk
Hi guys,
The API I'm using returns one field that's an array of mixed types: sometimes it's a DateTime, sometimes it's a float. I think in order to deserialize it with Chiron I need to define a special F# type for it like:
type internal StringOrDecimal =
    | String of string
    | Decimal of decimal
But then I fail to create To/FromJson methods for the type. I've tried something like this:
    static member ToJson (x: StringOrDecimal) =
        match x with
        | String arg -> Json.String arg
        | Decimal arg -> Json.Number arg
but obviously the type of the function is incorrect. Any help with that ?
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.