on master help sign in
Fix case-tree projection transformation.
7ada264Matus Tejiscak
src/Idris/Core/CaseTree.hs+10−7
@@ -596,11 +596,15 @@ prune proj (Case n alts)
596 -- vs.
596 -- vs.
597 -- f x = ... x!0 ...
597 -- f x = ... x!0 ...
598 -- There's currently no code to handle this stuff. (TODO)
598 -- There's currently no code to handle this stuff. (TODO)
599+ --
599− as@[ConCase cn i args sc] -> if proj && False then mkProj n 0 args sc
600+ --as@[ConCase cn i args sc]
600− else Case n as
601+ -- | proj -> mkProj n 0 args (prune proj sc)
602+
601− as@[SucCase cn sc] -> if proj then mkProj n (-1) [cn] sc
603+ as@[SucCase cn sc]
602− else Case n as
604+ | proj -> mkProj n (-1) [cn] (prune proj sc)
605+
603− as@[ConstCase _ sc] -> prune proj sc
606+ as@[ConstCase _ sc]
607+ -> prune proj sc
604
608
605 -- Bit of a hack here! The default case will always be 0, make sure
609 -- Bit of a hack here! The default case will always be 0, make sure
606 -- it gets caught first.
610 -- it gets caught first.
@@ -643,8 +647,7 @@ prune proj (Case n alts)
643 forceArg n = App (App (App (P Ref (sUN "Force") Erased) Erased) Erased)
647 forceArg n = App (App (App (P Ref (sUN "Force") Erased) Erased) Erased)
644 (P Bound n Erased)
648 (P Bound n Erased)
645
649
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
648
651
649 -- Change every 'n' in sc to 'n-1'
652 -- Change every 'n' in sc to 'n-1'
650-- mkProjS n cn sc = prune proj (fmap projn sc) where
653-- 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
1122
1122
1123 tree' <- tclift $ simpleCase tcase knowncovering reflect
1123 tree' <- tclift $ simpleCase tcase knowncovering reflect
1124 RunTime fc inacc atys pdef'
1124 RunTime fc inacc atys pdef'
1125− logLvl 3 (show tree)
1125+ logLvl 3 $ "Unoptimised " ++ show n ++ ": " ++ show tree
1126 logLvl 3 $ "Optimised: " ++ show tree'
1126 logLvl 3 $ "Optimised: " ++ show tree'
1127 ctxt <- getContext
1127 ctxt <- getContext
1128 ist <- getIState
1128 ist <- getIState