Make the LiberateCase transformation understand associated types
authorsimonpj@microsoft.com <unknown>
Thu, 11 Jan 2007 09:15:33 +0000 (09:15 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 11 Jan 2007 09:15:33 +0000 (09:15 +0000)
commit7aa3f5247ae454b10b61e2f28a9431f0889a8cff
tree2aa4d635fd300e9c397a9a03ea7d91fdb0f2acca
parent899fd7fb59cedf25b3939f951016f0c8b5d1541a
Make the LiberateCase transformation understand associated types

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.
compiler/deSugar/Desugar.lhs
compiler/main/HscTypes.lhs
compiler/simplCore/LiberateCase.lhs
compiler/simplCore/SimplCore.lhs
compiler/typecheck/TcRnDriver.lhs