diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-03-30 12:35:50 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-03-30 12:35:50 +0100 |
commit | f1f93b21df509a7e7509c6d3ce829504785b38fd (patch) | |
tree | b88ae6f4a87beb87a21069ac10c4bde84971a2a4 /compiler/coreSyn | |
parent | fe0a45ef706f09a6ced55b457c38c9b96f01711f (diff) | |
download | haskell-f1f93b21df509a7e7509c6d3ce829504785b38fd.tar.gz |
Comments only
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r-- | compiler/coreSyn/CoreUtils.lhs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs index 44aebb8169..df7277893c 100644 --- a/compiler/coreSyn/CoreUtils.lhs +++ b/compiler/coreSyn/CoreUtils.lhs @@ -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 |