Thoth.Json icon indicating copy to clipboard operation
Thoth.Json copied to clipboard

API change proposal for a next version

Open MangelMaxime opened this issue 6 years ago • 1 comments

Issue by vbfox Thursday Aug 15, 2019 at 12:37 GMT Originally opened as https://github.com/MangelMaxime/Thoth/issues/160


While playing with potential optimizations of Thoth javascript side a few months ago I found that a lot of time is spent constructing the path in the decoder.

There is a relatively simple fix that change the decoder API to never build the full string on the success path but instead build it only on error.

- type Decoder<'T> = string -> JsonValue -> Result<'T, DecoderError>
+ type Decoder<'T> = JsonValue -> Result<'T, DecoderError>

The changes I did at the time can be found in https://github.com/vbfox/Thoth/commit/4b42df89a43f6aaefe3ee06f27f31b5a6c6f3d4b I'll PR the other optimizations but this one as it affect the API needs more discussion.

MangelMaxime avatar Nov 08 '19 14:11 MangelMaxime

Comment by MangelMaxime Tuesday Aug 20, 2019 at 08:53 GMT


I read quickly the diff, but this indeed seems reasonable changes.

It should also, remove from the user the need to understand what path is when writing their own decoders because I think the path is only changing when dealing with array, object, etc. but not "primitives" types.

I will include it in the next major version of Thoth.Json thank you for the proposal :)

MangelMaxime avatar Nov 08 '19 14:11 MangelMaxime