on master help sign in
Fix case-tree projection transformation.
commit7ada26408b529da34f2f1f462dd03287e66b9328 authorMatus Tejiscak <ziman@functor.sk> dateWed 19 Mar 2014, 22:19 (13 years ago) parent30ba576
2 files changed+11−8
src/Idris/Core/CaseTree.hs+10−7 src/Idris/ElabDecls.hs+1−1
src/Idris/Core/CaseTree.hs+10−7
@@ -596,11 +596,15 @@ prune proj (Case n alts)
596596 -- vs.
597597 -- f x = ... x!0 ...
598598 -- There's currently no code to handle this stuff. (TODO)
599− as@[ConCase cn i args sc] -> if proj && False then mkProj n 0 args sc
600− else Case n as
601− as@[SucCase cn sc] -> if proj then mkProj n (-1) [cn] sc
602− else Case n as
603− as@[ConstCase _ sc] -> prune proj sc
599+ --
600+ --as@[ConCase cn i args sc]
601+ -- | proj -> mkProj n 0 args (prune proj sc)
602+
603+ as@[SucCase cn sc]
604+ | proj -> mkProj n (-1) [cn] (prune proj sc)
605+
606+ as@[ConstCase _ sc]
607+ -> prune proj sc
604608
605609 -- Bit of a hack here! The default case will always be 0, make sure
606610 -- it gets caught first.
@@ -643,8 +647,7 @@ prune proj (Case n alts)
643647 forceArg n = App (App (App (P Ref (sUN "Force") Erased) Erased) Erased)
644648 (P Bound n Erased)
645649
646− mkProj n i [] sc = prune proj sc
647− mkProj n i (x : xs) sc = mkProj n (i + 1) xs (projRep x n i sc)
650+ mkProj n i xs sc = foldr (\x -> projRep x n i) sc xs
648651
649652 -- Change every 'n' in sc to 'n-1'
650653-- mkProjS n cn sc = prune proj (fmap projn sc) where
src/Idris/ElabDecls.hs+1−1
@@ -1122,7 +1122,7 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
11221122
11231123 tree' <- tclift $ simpleCase tcase knowncovering reflect
11241124 RunTime fc inacc atys pdef'
1125− logLvl 3 (show tree)
1125+ logLvl 3 $ "Unoptimised " ++ show n ++ ": " ++ show tree
11261126 logLvl 3 $ "Optimised: " ++ show tree'
11271127 ctxt <- getContext
11281128 ist <- getIState