on master help sign in
Reformulate decEq for Vect.
commit08ddbaa787f5b65a753294dab0c57188f7ad991d authorMatus Tejiscak <ziman@functor.sk> dateTue 1 Apr 2014, 12:50 (13 years ago) parent4bc8589
2 files changed+13−2
libs/prelude/Decidable/Equality.idr+11−1 src/Idris/Core/CaseTree.hs+2−1
libs/prelude/Decidable/Equality.idr+11−1
@@ -174,13 +174,23 @@ total
174174vectInjective2 : {xs, ys : Vect n a} -> {x, y : a} -> x :: xs = y :: ys -> xs = ys
175175vectInjective2 {x=x} {y=x} {xs=xs} {ys=xs} refl = refl
176176
177+instance DecEq a => DecEq (Vect n a) where
178+ decEq [] [] = Yes refl
179+ decEq (x :: xs) (y :: ys) with (decEq x y)
180+ decEq (x :: xs) (x :: ys) | Yes refl with (decEq xs ys)
181+ decEq (x :: xs) (x :: xs) | Yes refl | Yes refl = Yes refl
182+ decEq (x :: xs) (x :: ys) | Yes refl | No neq = No (neq . vectInjective2)
183+ decEq (x :: xs) (y :: ys) | No neq = No (neq . vectInjective1)
184+
185+{- The following definition is elaborated in a wrong case-tree. Examination pending.
186+
177187instance DecEq a => DecEq (Vect n a) where
178188 decEq [] [] = Yes refl
179189 decEq (x :: xs) (y :: ys) with (decEq x y, decEq xs ys)
180190 decEq (x :: xs) (x :: xs) | (Yes refl, Yes refl) = Yes refl
181191 decEq (x :: xs) (y :: ys) | (_, No nEqTl) = No (\p => nEqTl (vectInjective2 p))
182192 decEq (x :: xs) (y :: ys) | (No nEqHd, _) = No (\p => nEqHd (vectInjective1 p))
183−
193+-}
184194
185195-- For the primitives, we have to cheat because we don't have access to their
186196-- internal implementations.
src/Idris/Core/CaseTree.hs+2−1
@@ -19,7 +19,7 @@ data CaseDef = CaseDef [Name] !SC [Term]
1919-- in other words, it never inspects anything else than variables.
2020--
2121-- ProjCase is a special powerful case construct that allows inspection
22−-- of compound terms. Occurences of ProjCase arise no earlier than
22+-- of compound terms. Occurrences of ProjCase arise no earlier than
2323-- in the function `prune` as a means of optimisation
2424-- of already built case trees.
2525--
@@ -603,6 +603,7 @@ prune proj (Case n alts) = case alts' of
603603 -- f x = ... x!0 ...
604604 --
605605 -- Hence, we disable this step.
606+ -- TODO: re-enable this in toIR
606607 --
607608 -- as@[ConCase cn i args sc]
608609 -- | proj -> mkProj n 0 args (prune proj sc)