Note [Which types are unboxed?]

GHC/Core/Opt/WorkWrap/Utils.hs:800 compiler 1 ticket

Worker/wrapper will unbox

  1. A strict data type argument, that
       * is an algebraic data type (not a newtype)
       * is not recursive (as per 'isRecDataCon')
       * has a single constructor (thus is a "product")
       * that may bind existentials (#18982)
     We can transform
     > data D a = forall b. D a b
     > f (D @ex a b) = e
     to
     > $wf @ex a b = e
     via 'mkWWstr'.

  2. The constructed result of a function, if
       * its type is an algebraic data type (not a newtype)
       * is not recursive (as per 'isRecDataCon')
       * (might have multiple constructors, in contrast to (1))
       * the applied data constructor *does not* bind existentials
       * nor does it bind constraints (equalities or dictionaries)
     We can transform
     > f x y = let ... in D a b
     to
     > $wf x y = let ... in (# a, b #)
     via 'mkWWcpr'.

     (CPR1).  We don't allow existentials for CPR W/W, because we don't have
     unboxed dependent tuples (yet?). Otherwise, we could transform
     > f x y = let ... in D @ex (a :: ..ex..) (b :: ..ex..)
     to
     > $wf x y = let ... in (# @ex, (a :: ..ex..), (b :: ..ex..) #)

     (CPR2) we don't allow constraints for CPR W/W, because an unboxed tuple
     contains types of kind `TYPE rr`, but not of kind `CONSTRAINT rr`.
     This is annoying; there is no real reason for this except that we don't
     have TYPE/CONSTAINT polymorphism.  See Note [TYPE and CONSTRAINT]
     in GHC.Builtin.Types.Prim.

The respective tests are in 'canUnboxArg' and
'canUnboxResult', respectively.

References 0

This Note does not link to any other.

Referenced by 8