Open AshleyYakeley opened 4 years ago
If we allow recursive types (#2), then we should allow recursive type synonym definitions, e.g. type T = [T]
.
Easiest way to do this, with parameters and recursion:
Equivalents of storable types won't be storable, which would be surprising for synonyms.
Type synonyms with both parameters and recursion probably makes no sense, for example:
type T a = Maybe (T (List a))
This doesn't correspond to a Pinafore type.
So let's drop recursion.
Simplest way is to take a very template-like approach. Types have parameters, but they are not checked for variance and {-p,+q}
is not allowed. They simply substitute in, so you could do, e.g. type Endo a = a -> a
, even though that "parameter" is neither covariant nor contravariant.
Slightly nicer (maybe?) would be to enforce parameter variance, and allow rangevariance, but otherwise treat it as a template.
One possibility, that would dovetail with #172:
type
creates a new ground type constructor with no other special propertiestype storable
creates a new ground type constructor that is storableNote that greatest dynamic supertype would not be preserved. But subtype relations would be, since the new type would be equivalent to its source.
Option 1
type T = type
Pinafore infers the maybe-polarity ofT
Option 2
type T = type
--T
is ambipolartype + T = type
--T
is positivetype - T = type
--T
is negativePrefer option 2, possibly syntax could change.