Articles from Alex Korban

Primary tabs

How to read Elm types like `Html Msg`

A question I've seen quite often from people new to Elm is "How do I read types like Html Msg"? When the function signature is view : Model -> Html Msg, does view return some kind of function which takes a Msg argument? Or does it return a function that returns a Msg? Or is Html instead some kind of type decorator that extends Msg?

When you start out with Elm, this stuff can be confusing - I know I stumbled over it for a while.

To understand what's going on, a useful analogy to recall is the ...

How to read Elm types like `Html Msg`

A question I've seen quite often from people new to Elm is "How do I read types like Html Msg"? When the function signature is view : Model -> Html Msg, does view return some kind of function which takes a Msg argument? Or does it return a function that returns a Msg? Or is Html instead some kind of type decorator that extends Msg?

When you start out with Elm, this stuff can be confusing - I know I stumbled over it for a while.

To understand what's going on, a useful analogy to recall is the ...

Decoding JSON to nested record fields in Elm

I'm working on a tool that handles PostgreSQL EXPLAIN output in JSON format.

The data consists of a tree of nodes representing different parts of a query execution plan:

Sort on zone_idHash JoinSeq Scan on zonesHashSeq Scan on projects

Each node has a lot of attributes (more than 10), but with a significant portion of attributes common to all nodes.

The large number of attributes led me to use the Json.Decode.Pipeline package because it makes them easier to handle.

First attempt: universal...

Decoding JSON to nested record fields in Elm

I'm working on a tool that handles PostgreSQL EXPLAIN output in JSON format.

The data consists of a tree of nodes representing different parts of a query execution plan:

Sort on zone_idHash JoinSeq Scan on zonesHashSeq Scan on projects

Each node has a lot of attributes (more than 10), but with a significant portion of attributes common to all nodes.

The large number of attributes led me to use the Json.Decode.Pipeline package because it makes them easier to handle.

First attempt: universal...