Proposal: remove the 'type' and 'alias' keywords

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 = Int

model : Model
model =


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!

1 Like

This creates an ambiguity.
The declaration Blah = Int could either be a type alias for Int or a declaration of a type with a constructor called Int.

Interesting, well maybe only alias would be necessary in that case then.

I am curious when union types that are just a single 0 argument constructor are useful / how often they are created though. I have never seen that before.

It’s possible to fix that, at the top of my head: keeping = for aliases and | for unions, like:

    | Int

Foo = Int

    | Int
    | Bar

BTW, I proposed something in the same lines: A type proposal

This newbie appreciates the explicitness of type and alias keywords. Take them away and it’s one more brick in my cognitive load – rather than type - ok, here comes a type I get ok, here's something, is it capitalized? ok, now remember what that means.


In that sense, I’ve had problems with type and type alias when forgetting the alias part and being confused about the errors and what was wrong. I think if type alias was only alias, the difference would be even more evident :smiley: but then it wouldn’t be obvious at first glance that it is a type you can use on type signatures.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.