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=188.8.131.52, 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?