Skip to content

Conversation

@ollien
Copy link

@ollien ollien commented Nov 30, 2025

Fixes #10

This PR adds the ability to either parse directly to a dynamic (parse_dynamic) or convert an existing TOML document to a dynamic (to_dynamic). I had to do some dynamic building like we discussed on Discord, so hopefully this matches with what we discussed 😅. I've also added decoders for all custom types, so that callers do not have to use the known forms themselves if they don't want to.

I've also added a JS test target to the CI, since there's FFI involved now.

Let me know if you'd like anything fixed up!

@ollien
Copy link
Author

ollien commented Dec 7, 2025

Hi @lpil! Can I bump you about this PR?

Copy link
Owner

@lpil lpil left a comment

Choose a reason for hiding this comment

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

Hello! Thank you for this! Will be super useful.

I've left some notes inline. One of the main things is that new_primitive_decoder is being used a lot instead of the regular decode API. new_primitive_decoder is for decoding primitives via FFI, it's not needed to compose decoders, they already compose!

src/tom.gleam Outdated
}
}

/// Convert a parsed TOML document into a `Dynamic`.
Copy link
Owner

Choose a reason for hiding this comment

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

Fill in this documentation with what it is for please 🙏

Copy link
Author

Choose a reason for hiding this comment

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

I filled this out for both to_dynamic and parse_to_dynamic. Let me know what you think :)

src/tom.gleam Outdated
}

/// A convenience for parsing a TOML document and immediately converting it to a Dynamic
pub fn parse_dynamic(input: String) -> Result(Dynamic, ParseError) {
Copy link
Owner

Choose a reason for hiding this comment

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

Same here, more documentation please.

Also let's call it parse_to_dynamic, to make it a bit clearer 🙏

@ollien ollien requested a review from lpil January 10, 2026 15:45
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.

Add dynamic decoding

2 participants