Reputation: 5949
If I try to define new type alias, for example, in a following manner:
type alias ListOfInts = [Int]
I get following error:
I was partway through parsing a type alias, but I got stuck here:
11| type alias ListOfInts = [Int]
^
I was expecting to see a type next. Try putting Int or String for now?
Is there a way to define type alias for Lists in Elm?
Upvotes: 2
Views: 287
Reputation: 18259
Unlike some other languages such as Haskell, Elm does not use square brackets as special notation for its list type. Consequently, as the compiler tells you, it can't make sense of the [
in a context where it expects to see a type.
The type is instead written List Int
, as you can find for example in the Elm guide.
So just change your code to this:
type alias ListOfInts = List Int
Upvotes: 4