Skip to content

Commit 25319eb

Browse files
committed
Add note about order of MirroredElemTypes
1 parent 84ea41a commit 25319eb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/docs/reference/contextual/derivation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ Note the following properties of `Mirror` types,
129129
Scala 2 versions of shapeless). Instead the collection of child types of a data type is represented by an ordinary,
130130
possibly parameterized, tuple type. Dotty's metaprogramming facilities can be used to work with these tuple types
131131
as-is, and higher level libraries can be built on top of them.
132+
+ For both product and sum types, the elements of `MirroredElemTypes` are arranged in definition order (i.e. `Branch[T]`
133+
precedes `Leaf[T]` in `MirroredElemTypes` for `Tree` because `Branch` is defined before `Leaf` in the source file).
134+
This means that `Mirror.Sum` differs in this respect from shapeless's generic representation for ADTs in Scala 2,
135+
where the constructors are ordered alphabetically by name.
132136
+ The methods `ordinal` and `fromProduct` are defined in terms of `MirroredMonoType` which is the type of kind-`*`
133137
which is obtained from `MirroredType` by wildcarding its type parameters.
134138

0 commit comments

Comments
 (0)