on master help sign in
Better match checking
commit991c2298a184e5b4d246fe853dc3f28a792ec361 authorEdwin Brady <eb@cs.st-andrews.ac.uk> dateMon 16 Jan 2012, 16:08 (15 years ago) parenta3c6231
2 files changed+6−3
src/Idris/AbsSyntax.hs+5−2 src/Idris/ElabDecls.hs+1−1
src/Idris/AbsSyntax.hs+5−2
@@ -1202,7 +1202,10 @@ toEither (RightOK ho) = Right ho
12021202-- and what they match. Returns the pair that failed if not a match.
12031203
12041204matchClause :: PTerm -> PTerm -> Either (PTerm, PTerm) [(Name, PTerm)]
1205−matchClause x y = checkRpts $ match (fullApp x) (fullApp y) where
1205+matchClause = matchClause' False
1206+
1207+matchClause' :: Bool -> PTerm -> PTerm -> Either (PTerm, PTerm) [(Name, PTerm)]
1208+matchClause' names x y = checkRpts $ match (fullApp x) (fullApp y) where
12061209 matchArg x y = match (fullApp (getTm x)) (fullApp (getTm y))
12071210
12081211 fullApp (PApp _ (PApp fc f args) xs) = fullApp (PApp fc f (args ++ xs))
@@ -1219,7 +1222,7 @@ matchClause x y = checkRpts $ match (fullApp x) (fullApp y) where
12191222 match (PRef f n) (PApp _ x []) = match (PRef f n) x
12201223 match (PApp _ x []) (PRef f n) = match x (PRef f n)
12211224 match (PRef _ n) (PRef _ n') | n == n' = return []
1222− match (PRef _ n) tm = return [(n, tm)]
1225+ match (PRef _ n) tm | not names = return [(n, tm)]
12231226 match (PEq _ l r) (PEq _ l' r') = do ml <- match' l l'
12241227 mr <- match' r r'
12251228 return (ml ++ mr)
src/Idris/ElabDecls.hs+1−1
@@ -625,7 +625,7 @@ checkInferred :: FC -> PTerm -> PTerm -> Idris ()
625625checkInferred fc inf user =
626626 do logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n" ++
627627 showImp True user
628− tclift $ case matchClause user inf of
628+ tclift $ case matchClause' True user inf of
629629 Right vs -> return ()
630630 Left (x, y) -> tfail $ At fc
631631 (Msg $ "The type-checked term and given term do not match: "