Improve pruning of case alternatives to account for GADTs
authorsimonpj@microsoft.com <unknown>
Wed, 12 Apr 2006 15:23:27 +0000 (15:23 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 12 Apr 2006 15:23:27 +0000 (15:23 +0000)
commit2763f56de2097a34176aa883dd4f0b3de1cb896c
tree63e5c32546022791b8834bce68151e0beef43d5c
parent91a9aeebdf06c8c47a3b0eaf48ef297e7d460601
Improve pruning of case alternatives to account for GADTs

Consider

  data T a where
    T1 :: T Int
    T2 :: T Bool
    T3 :: T Char

  f :: T Bool -> Int
  f x = case x of
  DEFAULT -> ...
  T2 -> 3

Here the DEFAULT case covers multiple constructors (T1,T3), but none
of them can match a scrutinee of type (T Bool).  So we can prune away
the default case altogether.

In implementing this, I re-factored this bit of the simplifier, elminiating
prepareAlts from SimplUtils, and putting all the work into simplAlts in
Simplify

The proximate cause was a program written by Manuel using PArrays
compiler/coreSyn/CoreUtils.lhs
compiler/coreSyn/PprCore.lhs
compiler/simplCore/SimplUtils.lhs
compiler/simplCore/Simplify.lhs
compiler/types/Unify.lhs
compiler/utils/Maybes.lhs