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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With