Reputation: 1292
I'm used to using the es2015 idiom of map(_ => _)
, but it seems that a single underscore is not a valid variable name for Elm's lambda functions.
Is this correct? If so, is there a resource documenting/explaining this?
The following fails with Cannot find variable `_`
view : Model -> Html Msg
view model =
div []
[ ul []
(List.map (\_ -> li [] [ text _.message ]) model.messages)
]
However this works:
...
(List.map (\a -> li [] [ text a.message ]) model.messages)
Upvotes: 1
Views: 820
Reputation: 36385
The underscore is a reserved character that means you will be ignoring whatever value it represents. It therefore cannot be used as if it were a variable in a function's body.
Upvotes: 6