Skip to content
Snippets Groups Projects
Commit 9d4ba36f authored by sheaf's avatar sheaf
Browse files

Add rewriting to typechecking plugins

Type-checking plugins can now directly rewrite type-families.
The TcPlugin record is given a new field, tcPluginRewrite.
The plugin specifies how to rewrite certain type-families with a value
of type `UniqFM TyCon TcPluginRewriter`, where:

type TcPluginRewriter
  =  RewriteEnv -- Rewriter environment
  -> [Ct]       -- Givens
  -> [TcType]   -- type family arguments
  -> TcPluginM TcPluginRewriteResult

data TcPluginRewriteResult
  = TcPluginNoRewrite
  | TcPluginRewriteTo
      { tcPluginRewriteTo    :: Reduction
      , tcRewriterNewWanteds :: [Ct]
      }

When rewriting an exactly-saturated type-family application,
GHC will first query type-checking plugins for possible rewritings
before proceeding.

Includes some changes to the TcPlugin API, e.g. removal
of the EvBindsVar parameter to the TcPluginM monad.
parent c367b39e
No related branches found
No related tags found
No related merge requests found
Showing
with 795 additions and 180 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment