Commit f1f93b21 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Comments only

parent fe0a45ef
......@@ -400,18 +400,23 @@ trimConArgs (DataAlt dc) args = dropList (dataConUnivTyVars dc) args
\begin{code}
filterAlts :: [Unique] -- ^ Supply of uniques used in case we have to manufacture a new AltCon
-> Type -- ^ Type of scrutinee (used to prune possibilities)
-> [AltCon] -- ^ Constructors known to be impossible due to the form of the scrutinee
-> [AltCon] -- ^ 'imposs_cons': constructors known to be impossible due to the form of the scrutinee
-> [(AltCon, [Var], a)] -- ^ Alternatives
-> ([AltCon], Bool, [(AltCon, [Var], a)])
-- Returns:
-- 1. Constructors that will never be encountered by the *default* case (if any)
-- 2. Whether we managed to refine the default alternative into a specific constructor (for statistcs only)
-- 3. The new alternatives
-- 1. Constructors that will never be encountered by the
-- *default* case (if any). A superset of imposs_cons
-- 2. Whether we managed to refine the default alternative into a specific constructor (for statistics only)
-- 3. The new alternatives, trimmed by
-- a) remove imposs_cons
-- b) remove constructors which can't match because of GADTs
-- and with the DEFAULT expanded to a DataAlt if there is exactly
-- remaining constructor that can match
--
-- NB: the final list of alternatives may be empty:
-- This is a tricky corner case. If the data type has no constructors,
-- which GHC allows, then the case expression will have at most a default
-- alternative.
-- which GHC allows, or if the imposs_cons covers all constructors (after taking
-- account of GADTs), then no alternatives can match.
--
-- If callers need to preserve the invariant that there is always at least one branch
-- in a "case" statement then they will need to manually add a dummy case branch that just
......
......@@ -1494,6 +1494,7 @@ of the inner case y, which give us nowhere to go!
\begin{code}
prepareAlts :: OutExpr -> OutId -> [InAlt] -> SimplM ([AltCon], [InAlt])
-- The returned alternatives can be empty, none are possible
prepareAlts scrut case_bndr' alts = do
us <- getUniquesM
-- Case binder is needed just for its type. Note that as an
......
......@@ -1946,6 +1946,7 @@ simplAlts :: SimplEnv
-> SimplM (OutExpr, OutId, [OutAlt]) -- Includes the continuation
-- Like simplExpr, this just returns the simplified alternatives;
-- it does not return an environment
-- The returned alternatives can be empty, none are possible
simplAlts env scrut case_bndr alts cont'
= -- pprTrace "simplAlts" (ppr alts $$ ppr (seTvSubst env)) $
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment