Skip to content
  • Simon Peyton Jones's avatar
    Type vs Constraint: finally nailed · 778c6adc
    Simon Peyton Jones authored and Simon Peyton Jones's avatar Simon Peyton Jones committed
    This big patch addresses the rats-nest of issues that have plagued
    us for years, about the relationship between Type and Constraint.
    See #11715/#21623.
    
    The main payload of the patch is:
    * To introduce CONSTRAINT :: RuntimeRep -> Type
    * To make TYPE and CONSTRAINT distinct throughout the compiler
    
    Two overview Notes in GHC.Builtin.Types.Prim
    
    * Note [TYPE and CONSTRAINT]
    
    * Note [Type and Constraint are not apart]
      This is the main complication.
    
    The specifics
    
    * New primitive types (GHC.Builtin.Types.Prim)
      - CONSTRAINT
      - ctArrowTyCon (=>)
      - tcArrowTyCon (-=>)
      - ccArrowTyCon (==>)
      - funTyCon     FUN     -- Not new
      See Note [Function type constructors and FunTy]
      and Note [TYPE and CONSTRAINT]
    
    * GHC.Builtin.Types:
      - New type Constraint = CONSTRAINT LiftedRep
      - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in
    
    * Exploit the fact that Type and Constraint are distinct throughout GHC
      - Get rid of tcView in favour of coreView.
      - ...
    778c6adc