Multiplicities need better documentation, invariant checking
While looking working on a patch today I found myself quite confounded by the type of splitFunTy
in the post-Linear-Types world:
splitFunTy :: Type -> (Type, Type, Type)
-- ^ Attempts to extract the argument and result types from a type, and
-- panics if that is not possible. See also 'splitFunTy_maybe'
splitFunTy = expectJust "splitFunTy" . splitFunTy_maybe
The Haddocks here should acknowledge that the multiplicity is returned. Further, it may be worth using the Mult
type synonym.
Somewhat orthogonally, Mult
is a type synonym yet outside of Core Lint there appears to be little (no?) checking within the compiler of the invariant that values of Mult
have the right kind. There should presumably be some assertions somewhere to verify this. Might it be worthwhile making Mult
a newtype around Type
to help verify where these