Skip to content
Playground(another site)

bynk.types.derives_field_not_orderable

Error A type declares derives Ord, but one of its fields or payloads is not Ord (for example a Map, a Set, a Bool, a function, or a record that does not itself derive Ord); every part must be orderable for the declaration order to be a total order (constrained-generics slice 1).

derives Ord orders a type field by field, in declaration order, so every field or payload must itself have an order. A Bool, a Map, a Set, a function, and a named type that does not derive Ord itself have none. Change the field to an orderable type, such as an Int rank, or give the field's own type derives Ord, or drop derives Ord and sort by a key with sortBy.

Example

type Task = { title: String, done: Bool } derives Ord // ✗ a `Bool` has no order
type Task = { title: String, priority: Int } derives Ord // ✓

In the Book

See also

  • The grammar rule it governs: type_decl.
  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.derives_field_not_orderable shows the same from the installed toolchain, without a network.