Discussion: How much to pipeline

I only pizza if there are two or more values in the chain

I think error messages are better when you do someList |> List.map (\item -> whatever) rather than List.map (\item -> whatever) someList. It’s almost always the lambda that is wrong so I like when it is marked as the error rather than someList.

-- TYPE MISMATCH - src/Example.elm

This function cannot handle the argument sent through the (|>) pipe:

182|     someList |> List.map (\( _, x ) -> x + 1)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The argument is:

    List number

But (|>) is piping it to a function that expects:

    List ( a, number )

Hint: Only Int and Float values work as numbers.

-- TYPE MISMATCH - src/Example.elm

The 2nd argument to `map` is not what I expect:

186|     List.map (\( _, x ) -> x + 1) someList
                                       ^^^^^^^^
This `someList` value is a:

    List number

But `map` needs the 2nd argument to be:

    List ( a, number )

Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!

Hint: Only Int and Float values work as numbers.
3 Likes