Skip to content

Conversation

@gilramir
Copy link
Contributor

@gilramir gilramir commented Jan 2, 2026

Use andMap to incrementally decode a JSON object. Each andMap provides a value that will be an argument to a type constructor.

Use andMap to incrementally decode a JSON object. Each andMap
provides a value that will be an argument to a type constructor.
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)
```
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 robinheghan merged commit 256375e into gren-lang:main Jan 4, 2026
1 of 2 checks passed
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