• simonpj@microsoft.com's avatar
    Make the LiberateCase transformation understand associated types · 7aa3f524
    simonpj@microsoft.com authored
    Consider this FC program:
    	data family AT a :: *
    	data instance AT Int = T1 Int Int
    
    	f :: AT Int -> Int
    	f t = case t of DEFAULT -> <body>
    
    We'd like to replace the DEFAULT by a use of T1, so that if 
    we scrutinise t inside <body> we share the evaluation:
    
    	f t = case (t `cast` co) of T1 x y -> <body>
    
    I decided to do this as part of the liberate-case transformation,
    which is already trying to avoid redundant evals.  
    
    The new transformation requires knowledge of the family instance
    environment, so I had to extend ModGuts to carry the fam_inst_env,
    and put that envt into the liberate-case environment. 
    
    Otherwise it's all pretty straightforward.
    7aa3f524
SimplCore.lhs 23.6 KB