compiler
compiler copied to clipboard
Different type syntax
Single constructor union types feel error-prone for beginners. One example:
type Model = List { url : String }
initialModel : Model
initialModel =
[ { url = "1.jpeg" } ]
type
List { url : String }doesn't matchModel
Adding | before the first variant makes the variants more obvious and explicit:
type WrongModel =
| List { url : String }
type alias CorrectModel =
List { url : String }
-
would produce a nice error message, as the compiler knows that you want an alias there.type Model = List { url : String } =placement becomes consistent with all no-typeconstructs
Dropping type and type alias would make it even cleaner:
Point =
{ x : Float, y : Float }
Fruit =
| Pear
| Banana { angle : Float }
Thanks for reporting this! To set expectations:
- Issues are reviewed in batches, so it can take some time to get a response.
- Ask questions in a community forum. You will get an answer quicker that way!
- If you experience something similar, open a new issue. We like duplicates.
Finally, please be patient with the core team. They are trying their best with limited resources.