I assume that the definition of sans- with proposed in the article is
data Type t = RInt | RChar | RList (Type t) | RPair (Type t) (Type t)
Above, the parameter t never used. This is really a phantom.
This means, for example,
RInt :: Type a
for any type a . In contrast, if the with constraints were respected, it would be impossible to have RInt :: Type t for any t, but for t ~ Int .
The with syntax is missing in the GHC, but the GADTs play essentially the same role.
{-
Note that with is replaced by an equality constraint in each constructor. It is basically the same thing written in different ways.
More compactly, we can rewrite the above into
data Type t where RInt :: Type Int RChar :: Type Char RList :: Type a -> Type [a] RPair :: Type a -> Type b -> Type (a,b)
where the constraints were "embedded" in the final type.
chi
source share