Skip to content

Add warning for type aliases that monomorphise a PolyKinds-ed type

Motivation

module A has -XPolyKinds and defines some polykinded type MyPoly :: Type -> k -> Type

module B does not have -XPolyKinds and defines an alias type MySpecialP = MyPoly Bool

MySpecialP is monokinded, leading to confusing error messages down the line.

Proposal

Does it make sense to have a warning ("-Wmonomorphizing-alias"?) for this? For any type alias, check if the RHS involves PolyKinds, check that it does not have an explicitly mono-kinded kind-signature and that PolyKinds is disabled. If so, raise the warning.

For the unlikely case that the mono-kinded alias is desired, allowing an explicit kind signature to silence the warning seems appropriate.

I have no idea how complex this is to implement. If checking the above condition is too complex or is hard to do without false positives, feel free to close this.

Thanks for your consideration.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information