syntax.id
contains syntax for "plain" values, i.e. it places no constraints on the type of the value.
In general, when you import syntax for an expression of the form x.op
, the place to import the syntax depends on the type of x
, because op
needs to be a valid operation on that type.
Because \/[A, B]
is universally quantified for A and B, using the syntax x.left
and x.right
places no constraints on the type of x
. Hence, it belongs in syntax.id
.
For a working understanding of what syntax is available where, it is worth looking at the source of some of the modules that make up the syntax
packages. For example, contrast IdOps[A]
, which has syntax for any A
, with FunctorOps[F[_],A]
, which has the requirement that F
is a Functor
.
I am not sure where the name id
comes from exactly; perhaps it is related to the identity functor Id
, which can be defined as type Id[A] = A
. If you had to choose a type constraint for values usable with syntax.id
, it would be that they are in Id
. Being universally quantified in A
, the operations can't know about the structure of a value of A
, hence they can't be structure-altering operations on A
.