feat: experiment with adding custom decoder for tagged#3
Conversation
src/gbor/ffi_gbor.gleam
Outdated
There was a problem hiding this comment.
Maybe these functions could go into decode.gleam as private functions and the file be removed?
src/gbor/decode.gleam
Outdated
| } | ||
| Error(_) -> Error(default) | ||
| } | ||
| use x <- result.try(x) |
There was a problem hiding this comment.
I am not sure, but do you need this line and the code below, or isn't it enough to just return Ok(default) for the False and Error case? Now you do gdd.run here and then again when you run the decoder.
src/gbor/decode.gleam
Outdated
|
|
||
| use <- bool.guard(when: tag != expected_tag, return: Error(default)) | ||
|
|
||
| gdd.run(value, value_decoder) |
There was a problem hiding this comment.
@karlsson I refactored this a little bit, but to address your comment:
#(tag, value) above from checked_tagged comes out as #(Int, Dynamic)
So I was trying to figure out how we could make the decoder "pipeline" decoding to the final type there.
I thought it would have been then, but it seems to apply to the same initial value https://hexdocs.pm/gleam_stdlib/gleam/dynamic/decode.html#then
74b474d to
f3a4035
Compare
No description provided.