Closed vil1 closed 5 years ago
Does this mean it is no longer possible to have anonymous unions and records? what about schemas for (A, B)
and A \/ B
respectively?
Yes, it is still possible to use :+:
and :*:
to build sums and product of unlabelled schemas (it is still used that way to represent options).
This is an easy, syntactic solution for #28.
We simply define a new ADT
LabelledSum
with its own:+:
method accepting onlyLabelledSum
arguments, and make the first argument forunion
be aLabelledSum
instead of a more generalFSchema
(and respectively we define aLabelledProduct
ADT for building records).Making
Union
andRecord
(notice the renaming) besealed abstract case class
es make sure that they can only be instantiated through theunion
andrecord
method (and therefore contain only labelled sum/products), without modifying theSchema
ADT at all.