It should be possible to allow automatic expansion of cases based on sum types.
The new case definition might look like this for something other than a sum type:
Shape =
{ Circle: { Type: $.RecordType( { origin: Point, radius: $.ValidNumber } )
, area: ( { radius } ) => Math.PI * radius * radius
, move
, move2
}
}
With a little work ( marking the constructors, Types, standard and user-defined functions so they can be identified), the following should be a workable syntax for defining a case based on another sum type:
Assuming Triangle is a sum type with two cases, Base and Equilateral, that should allow for syntax like:
Shape.Triangle.Base( { definition } ) and Shape.Triangle.Equilateral.Type, as well as for tagging a triangle correctly by passing it into Shape().
Shape.tags( equilateralTriangleDef ) could return [ 'Triangle', 'Triangle.Base', 'Triangle.Equilateral' ].
It should be possible to allow automatic expansion of cases based on sum types.
The new case definition might look like this for something other than a sum type:
With a little work ( marking the constructors, Types, standard and user-defined functions so they can be identified), the following should be a workable syntax for defining a case based on another sum type:
Assuming
Triangleis a sum type with two cases,BaseandEquilateral, that should allow for syntax like:Shape.Triangle.Base( { definition } )andShape.Triangle.Equilateral.Type, as well as for tagging a triangle correctly by passing it intoShape().Shape.tags( equilateralTriangleDef )could return[ 'Triangle', 'Triangle.Base', 'Triangle.Equilateral' ].