Skip to content

feat: experiment with adding custom decoder for tagged#3

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

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

Conversation

@Beaudidly
Copy link
Owner

No description provided.

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
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

}
Error(_) -> Error(default)
}
use x <- result.try(x)
Copy link

@karlsson karlsson Jul 10, 2025

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
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


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

gdd.run(value, value_decoder)
Copy link
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