panesofglass on master
Update README.md Adds direct i… Merge pull request #55 from njl… (compare)
let inline serialise (x : 'a) = (Chiron.Mapping.Json.serialize >> Chiron.Formatting.Json.format) x
> serialise [| 1; 2 |];; val it : string = "[1,2]"
> serialise [| "1"; "2" |];; System.TypeInitializationException: The type initializer for 'Escaping' threw an exception. ---> System.TypeInitializationException: The type initializer for '<StartupCode$Chiron>.$Chiron' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'FParsec, Version=22.214.171.124, Culture=neutral, PublicKeyToken=40ccfc0a09edbb5d' or one of its dependencies. The system cannot find the file specified. at <StartupCode$Chiron>.$Chiron..cctor() --- End of inner exception stack trace --- at Chiron.Escaping..cctor() in C:\projects\chiron\src\Chiron\Chiron.fs:line 0 > --- End of inner exception stack trace --- at Chiron.Escaping.escape(String s) at Chiron.Formatting.formatJson(Int32 level, JsonFormattingOptions options, Json _arg1) in C:\projects\chiron\src\Chiron\Chiron.fs:line 704 at Chiron.Formatting.formatArray@710-1.Invoke(Json _arg1) in C:\projects\chiron\src\Chiron\Chiron.fs:line 710 at Chiron.Formatting.join@667-2.Invoke(StringBuilder b) in C:\projects\chiron\src\Chiron\Chiron.fs:line 670 at Chiron.Formatting.formatArray@708-4.Invoke(StringBuilder x) in C:\projects\chiron\src\Chiron\Chiron.fs:line 708 at Chiron.Formatting.formatArray@708-5.Invoke(StringBuilder x) in C:\projects\chiron\src\Chiron\Chiron.fs:line 708 at Chiron.Formatting.Json.format(Json json) in C:\projects\chiron\src\Chiron\Chiron.fs:line 743 at <StartupCode$FSI_0005>.$FSI_0005.main@() Stopped due to error
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
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
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?
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" :)
type internal StringOrDecimal = | String of string | Decimal of decimal
static member ToJson (x: StringOrDecimal) = match x with | String arg -> Json.String arg | Decimal arg -> Json.Number arg
... "data": [ [ "2016-12-04", 767.99, 750.0, 758.995, 760.519, 760.519, 760.111, 2376697.26975, 3137.22338 ] ], ...