Merged
Conversation
Use andMap to incrementally decode a JSON object. Each andMap provides a value that will be an argument to a type constructor.
robinheghan
requested changes
Jan 3, 2026
src/Json/Decode.gren
Outdated
Comment on lines
723
to
743
| ``` | ||
| -- The Type | ||
| type alias Info = | ||
| { height : Float | ||
| , age : Int | ||
| } | ||
|
|
||
| -- The Constructor | ||
| makeInfo : Float -> Int -> Info | ||
| makeInfo height age = | ||
| { height = height | ||
| , age = age | ||
| } | ||
|
|
||
| -- The Decoder | ||
| infoDecoder : Decoder Info | ||
| infoDecoder = | ||
| succeed makeInfo | ||
| |> andMap (field "height" float) | ||
| |> andMap (field "age" int) | ||
| ``` |
Member
There was a problem hiding this comment.
The style in the rest of this package is to indent example code, instead of enclosing them with backticks.
Btw, have you checked to see how this is rendered?
You can get a preview using:
npm install gren-packages
gren-doc-preview
Contributor
Author
There was a problem hiding this comment.
Ok, I'll change the markdown.
Yes, I use gren-doc-preview for reviewing the rendering for all my doc commits. It's great to have that tool available.
Use indentation instead of backticks in the MarkDown
robinheghan
approved these changes
Jan 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use andMap to incrementally decode a JSON object. Each andMap provides a value that will be an argument to a type constructor.