Role annotations on classes require module-wide IncoherentInstances
Per #8773 (closed), specifying a non-nominal role for a class parameter requires IncoherentInstances
:
{-# LANGUAGE RoleAnnotations #-}
{-# LANGUAGE IncoherentInstances #-}
class C c
type role C phantom
For instances, the IncoherentInstances
module-wide LANGUAGE
pragma has been deprecated in favour of per-instance {-# INCOHERENT #-}
pragmas. However, there doesn't appear to be an equivalent for type role
on classes. This is awkward because I do not want the instances of C
to be marked as incoherent, and hence they cannot be defined in the same module as C
.
I think it would make sense to be able to use {-# INCOHERENT #-}
after type role
, so that it would be accepted without module-wide IncoherentInstances
.