trick: no record
type alias
constructor function
record
Every directly aliased record type gets its default constructor function:
type alias Point =
{ x : Float, y : Float }
Point 4 2
--> { x = 4, y = 2 }
you can avoid this by using
type alias Record =
RecordWithoutConstructorFunction
{ yourCurrentRecord }
Automatic record constructor functions come with countless problems:
order matters
example from elm-review-record-alias-constructor
type alias User =
{ status : String
, name : String
}
decodeUser =
map2 User
(field "name" string)
(field "status" string)
Did you spot the mistake?
possible name clashes
type Declaration
= Function Function
| ...
type alias Function =
{ expression : Expression, ... }
patterns like record succeed
/constant
are encouraged
patterns like using a type
are discouraged
doesn't work for indirect or extensible aliases
read more in the readme!
find & fix your current usages of record type alias
constructor functions: elm-review
rule NoRecordAliasConstructor
insert RecordWithoutConstructorFunction
/... where necessary: elm-review
rule NoRecordAliasWithConstructor