Skip to content
  • Simon Peyton Jones's avatar
    Improve pruning of case alternatives to account for GADTs · 2763f56d
    Simon Peyton Jones authored
    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
    2763f56d