-absEval anal (Con (Literal _) args) env
- = -- Literals terminate (strictness) and are not poison (absence)
- AbsTop
-
-absEval anal (Con (PrimOp op) args) env
- = -- Not all PrimOps evaluate all their arguments
- if or (zipWith (check_arg anal)
- [absEval anal arg env | arg <- args, isValArg arg]
- arg_demands)
- then AbsBot
- else case anal of
- StrAnal | result_bot -> AbsBot
- other -> AbsTop
- where
- (arg_demands, result_bot) = primOpStrictness op
- check_arg StrAnal arg dmd = evalStrictness dmd arg
- check_arg AbsAnal arg dmd = evalAbsence dmd arg
-
-absEval anal (Con (DataCon con) args) env
- | isProductTyCon (dataConTyCon con)
- = -- Products; filter out type arguments
- AbsProd [absEval anal a env | a <- args, isValArg a]
-
- | otherwise -- Not single-constructor
- = case anal of
- StrAnal -> -- Strictness case: it's easy: it certainly terminates
- AbsTop
- AbsAnal -> -- In the absence case we need to be more
- -- careful: look to see if there's any
- -- poison in the components
- if any anyBot [absEval AbsAnal arg env | arg <- args]
- then AbsBot
- else AbsTop