Open TheSeamau5 opened 9 years ago
As a noob myself the:
I am looking for one of the following things:
a constructor for a union type
whitespace
Means nothing, the docs on type aliases are lacking also http://elm-lang.org/docs/syntax#type-aliases (dosen't actually say what they are),
from reading online I figured its for defining types which are based on other built in types (not that I'm sure why its required)
This is a simple case of accidentally using type alias instead of type
type alias GameState
= Started
| Paused
Current error message is not helpful:
-- SYNTAX PROBLEM ---------------------------------------------
I ran into something unexpected when parsing your code!
2| | Paused
^
I am looking for one of the following things:
end of input
whitespace
Maybe something like this instead?
-- SYNTAX PROBLEM ---------------------------------------------
I ran into something unexpected when parsing your code!
0| type alias GameState
1| = Started
2| | Paused
^
It looks like you intend to create a new type, but you define it as a type alias.
You should probably use this instead:
0| type GameState
(Read more about differences here blabla)
This is trivial once you know the difference between the two, but it's one of the things beginners may run into quickly. And in this case I think use of "|" makes user's intention clear
It's cool that the compiler recommends the use of types instead of type aliases when things get recursive, but I think that it would be cool if there was a recommendation that goes the other way.
For example:
Yields:
Ideally, you'd like something to say:
and then with an explanation of the difference between types and type aliases. This could be useful, especially for people coming from Haskell or beginners who still haven't grasped the difference between
type
andtype alias