--- We attempt to unbox/unpack a strict field when either:
--- (i) The tycon is imported, and the field is marked '! !', or
--- (ii) The tycon is defined in this module, the field is marked '!',
--- and the -funbox-strict-fields flag is on.
---
--- This ensures that if we compile some modules with -funbox-strict-fields and
--- some without, the compiler doesn't get confused about the constructor
--- representations.
-
-chooseBoxingStrategy :: TyCon -> Type -> StrictnessMark -> StrictnessMark
- -- Transforms any MarkedUserStricts into MarkUnboxed or MarkedStrict
-chooseBoxingStrategy tycon arg_ty strict
- = case strict of
- MarkedUserStrict
- | opt_UnboxStrictFields
- && unbox arg_ty -> MarkedUnboxed
- | otherwise -> MarkedStrict
- other -> strict
- where
- -- beware: repType will go into a loop if we try this on a recursive
- -- type (for reasons unknown...), hence the check for recursion below.
- unbox ty =
- case splitTyConApp_maybe ty of
- Nothing -> False
- Just (arg_tycon, _)
- | isRecursiveTyCon arg_tycon -> False
- | otherwise ->
- case splitTyConApp_maybe (repType ty) of
- Nothing -> False
- Just (arg_tycon, _) -> isProductTyCon arg_tycon