When suggesting Language Extensions, also suggest Extensions which imply them
GHC sometimes suggests enabling language extensions. In some cases, the user might not have wanted just that extension, but an extension which implies it.
So far, this is done more-or-less when suggesting forall
without -XExplicitForAll
. Here the suggested fix is:
Perhaps you intended to use RankNTypes
or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
!12112 (closed) seeks to improve this and instead suggest
Use ExplicitForAll (implied by RankNTypes and ScopedTypeVariables)
to enable syntax: forall <tvs>. <type>
I think it could make sense to add this in general whenever a language extension is suggested that has others that imply it. This would for example, when suggesting ExplicitNamespaces
add (implied by TypeFamilies and TypeOperators)
.
As for the implementation of this change there are problems, specifically that importing GHC.Driver.Session(impliedXFlags)
from GHC.Types.Hint.Ppr
leads to various module dependency cycles.
@bgamari suggested to move flags from GHC.Driver.Session
: #24478