Something is off with the body of the any definition:
{ a = () }
^^^^^^^^^^
The body is a record of type:
{ a : () }
But the type annotation on any says it should be:
{ a | a : () }
type argument mismatches
type ExtendedRecord record
= ExtendedRecord { record | a : () }
number : ExtendedRecord number
number =
ExtendedRecord { a = () }
unit : ExtendedRecord ()
unit =
ExtendedRecord { a = () }
also error as expected:
Something is off with the body of the definition:
19| ExtendedRecord { a = () }
^^^^^^^^^^^^^^^^^^^^^^^^^
This ExtendedRecord call produces:
ExtendedRecord {}
But the type annotation says it should be:
ExtendedRec ()
mismatches between record type alias and non-record
type alias ExtendedRecord record =
{ record | field : () }
number : ExtendedRecord number
number =
()
unit : ExtendedRecord ()
unit =
()
also error as expected:
Something is off with the body of the definition:
10| ()
^^
The body is a unit value:
()
But the type annotation says it should be:
ExtendedRecord number/()
behavior with constrained variables
number : { number | field : () }
number =
()
Something is off with the body of the number definition:
11| ()
^^
The body is a unit value:
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:541:21 in main:Type.Type
This happens for all constrained variable types (compappend, appendable, comparable, number).
behavior with inferred variables
When using a and { a | field : a } in one function type, calling that function with bad typed arguments leads to elm running into an error trying to produce an error message.
changeNothing : a -> { a | a : a } -> { a | a : a }
changeNothing _ a =
a
breaks =
changeNothing () {}
The code in breaks is incorrect but when elm tries to tell us, it fails with
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:541:21 in main:Type.Type
a seems to be inferred as a : (), breaking the extensible record type.
behavior with type and type alias
type alias
Problematic is the following:
unit : ExtendedRecord ()
unit =
{}
where the value is any record and the ExtendedRecord argument is constrained, inferred to or any non-record type. This sub-issue is covered in
type ExtendedRecord number =
ExtendedRecord { number | a : () }
number : ExtendedRecord number
number =
ExtendedRecord ()
The 1st argument to ExtendedRecord is not what I expect:
10| ExtendedRecord ()
^^
This argument is a unit value:
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:541:21 in main:Type.Type
When a
{
type used in an extensible record| ... }
type alias
ortype
the printed elm error message is interrupted by a haskell error.
normal behavior
type
argument mismatchesalso error as expected:
mismatches between record
type alias
and non-recordalso error as expected:
behavior with constrained variables
This happens for all constrained variable types (
compappend
,appendable
,comparable
,number
).behavior with inferred variables
When using
a
and{ a | field : a }
in one function type, calling that function with bad typed arguments leads to elm running into an error trying to produce an error message.The code in
breaks
is incorrect but when elm tries to tell us, it fails witha
seems to be inferred asa : ()
, breaking the extensible record type.behavior with
type
andtype alias
type alias
Problematic is the following:
where the value is any record and the
ExtendedRecord
argument is constrained, inferred to or any non-record type. This sub-issue is covered intype
argumentsadditional details