Haskell pattern matching not allowed in Elm?
Following this Elm tutorial , 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'd define it the same way, but with the syntax that I prefer:
update Increment model = model + 1
update Decrement model = model - 1
update Reset model = 0
But it doesn't compile, doesn't this syntax help Elm or am I wrong?
+3
source to share
1 answer
One of Elm's goals is to use a consistent style ; outputting redundant syntax is the end of this. For this reason, you won't find any where
clause and multi-choice function definitions are also not allowed.
+11
source to share