Skip to content

doc: fixes to documentation for gleam/dynamic/decode #826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/gleam/dynamic/decode.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
//// use name <- decode.field("name", decode.string)
//// use badge_count <- decode.field("badge-count", decode.int)
//// decode.success(Trainer(name, badge_count))
//// })
//// }
////
//// let gym_leader_decoder = {
//// use name <- decode.field("name", decode.string)
Expand All @@ -242,9 +242,16 @@
//// ```
////
//// A third decoder can be used to extract and decode the `"type"` field, and the
//// `then` function then returns whichever decoder is suitable for the document.
//// expression can evaluate to whichever decoder is suitable for the document.
////
//// ```gleam
//// // Data:
//// // {
//// // "type" -> "gym-leader",
//// // "name" -> "Misty",
//// // "speciality" -> "water",
//// // }
////
//// let decoder = {
//// use tag <- decode.field("type", decode.string)
//// case tag {
Expand All @@ -253,7 +260,8 @@
//// }
//// }
////
//// decode.run(data, decoder)
//// let result = decode.run(data, decoder)
//// assert result == Ok(GymLeader("Misty", Water))
//// ```

import gleam/bit_array
Expand Down