Skip to content

feat: experiment with adding custom decoder for tagged#3

Merged
Beaudidly merged 7 commits into
mainfrom
feat/custom-dynamic-for-tagged
Jul 14, 2025
Merged

feat: experiment with adding custom decoder for tagged#3
Beaudidly merged 7 commits into
mainfrom
feat/custom-dynamic-for-tagged

Conversation

@Beaudidly

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/gbor/ffi_gbor.gleam Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these functions could go into decode.gleam as private functions and the file be removed?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Done

Comment thread src/gbor/decode.gleam Outdated
}
Error(_) -> Error(default)
}
use x <- result.try(x)

@karlsson karlsson Jul 10, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored and responded here

Comment thread src/gbor/decode.gleam Outdated

use <- bool.guard(when: tag != expected_tag, return: Error(default))

gdd.run(value, value_decoder)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

@Beaudidly Beaudidly force-pushed the feat/custom-dynamic-for-tagged branch from 74b474d to f3a4035 Compare July 13, 2025 19:54
@Beaudidly Beaudidly merged commit bfab60c into main Jul 14, 2025
1 check passed
@Beaudidly Beaudidly deleted the feat/custom-dynamic-for-tagged branch August 8, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants