I’ve thought a lot lately about how nice it is that the syntax in Elm is so minimal, and there aren’t too many keywords to remember. I especially like that there’s no let myFunc or func myFunc or function myFunc function declarations, you just have myFunc x = -- function body stuff.
One thing that stands out to me though, is that the type and alias keywords really aren’t all that necessary, especially as types are always capitalized, and type aliases have no constructor.
-- instead of this
type Email = Email String
-- we could type this
Email = Email String
-- and instead of this
type alias Task = { task : String, complete : Bool }
-- we could have this
Task = { task : String, complete : Bool }
Here’s what it would look like alongside functions:
-- MODEL
Model = Int
model : Model
model =
0
-- UPDATE
Msg = Increment | Decrement
update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
If some sort of visual difference is needed, it could be colored or styled by the text editor. I think this is nice and removes two more unnecessary (in my opinion) keywords.
As an added bonus, it frees up type to be used as a name for things, which is especially nice when working on things like parsers. No more tipe or kind!
I thought I would just put this up to get thoughts and feedback from the community on this, as I’m sure there are things that I haven’t thought of!
but then it wouldn’t be obvious at first glance that it is a type you can use on type signatures.