Skip to content
  • sheaf's avatar
    9d4ba36f
    Add rewriting to typechecking plugins · 9d4ba36f
    sheaf authored
    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.
    9d4ba36f
    Add rewriting to typechecking plugins
    sheaf authored
    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.
Loading