Skip to content
  • Simon Peyton Jones's avatar
    Replace (State# RealWorld) with Void# where we just want a 0-bit value · f4384647
    Simon Peyton Jones authored
    We were re-using the super-magical "state token" type (which has
    VoidRep and is zero bits wide) for situations in which we simply want
    to lambda-abstract over a zero-bit argument. For example, join points:
    
       case (case x of { True -> e1; False -> e2 }) of
          Red  -> f1
          Blue -> True
    
    ==>
    
      let $j1 = \voidArg::Void# -> f1
      in
      case x of
        True -> case e1 of
                  Red -> $j1 void
                  Blue -> True
        False -> case e2 of
                  Red -> $j1 void
                  Blue -> True
    
    This patch introduces
    
       * The new primitive type GHC.Prim.Void#, with PrimRep = VoidRep
    
       * A new global Id GHC.Prim.voidPrimId :: Void#.
         This has no binding because the code generator drops it,
         but is used as an argument (eg in the call of $j1)
    
       * A new local Id, MkId.voidArgId, which can be lambda-bound
         when you need to lambda-abstract over it.
    
    and uses them throughout.
    
    Now the State# thing is used only when we need state!
    f4384647