Reputation: 779
Following this Elm tutorial and I assumed that the function
update : Msg -> Model -> Model
is defined in the tutorial as
update msg model =
case msg of
Increment -> model + 1
Deccrement -> model - 1
Reset -> 0
I thought I would define it the same way but with syntax I prefer:
update Increment model = model + 1
update Decrement model = model - 1
update Reset model = 0
But this doesn't compile, does Elm not support this syntax or did I make a mistake?
Upvotes: 5
Views: 251
Reputation: 5524
One of the goals of Elm is to use a consistent style; removing redundant syntax is a conclusion of this. For that reason, you will not find any where
clause and function definitions with multiple variants are not permitted either.
Upvotes: 12