on master help sign in
New matching rule for solving simple functions
2a0056aEdwin Brady
src/Idris/Core/Unify.hs+14−1
@@ -69,7 +69,20 @@ match_unify ctxt env topx topy inj holes from =
69 return (map (renameBinders env) (trimSolutions v))
69 return (map (renameBinders env) (trimSolutions v))
70 _ -> tfail e
70 _ -> tfail e
71 where
71 where
72−
72+ -- This rule is highly dubious... it certainly produces a valid answer
73+ -- but it scares me. However, matching is never guaranteed to give a unique
74+ -- answer, merely a valid one, so perhaps we're okay.
75+ -- In other words: it may vanish without warning some day :)
76+ un names x tm@(App (P _ f (Bind fn (Pi t) sc)) a)
77+ | (P (DCon _ _) _ _, _) <- unApply x,
78+ holeIn env f || f `elem` holes
79+ = let n' = uniqueName (sMN 0 "mv") (map fst env) in
80+ checkCycle names (f, Bind n' (Lam t) x)
81+ un names tm@(App (P _ f (Bind fn (Pi t) sc)) a) x
82+ | (P (DCon _ _) _ _, _) <- unApply x,
83+ holeIn env f || f `elem` holes
84+ = let n' = uniqueName fn (map fst env) in
85+ checkCycle names (f, Bind n' (Lam t) x)
73
86
74 un names (P _ x _) tm
87 un names (P _ x _) tm
75 | holeIn env x || x `elem` holes
88 | holeIn env x || x `elem` holes
src/Idris/ElabTerm.hs+3
@@ -698,6 +698,9 @@ elab ist info pattern opts fn tm
698 addImpl ist (PApp fc (PRef fc (sUN "Delay"))
698 addImpl ist (PApp fc (PRef fc (sUN "Delay"))
699 [pexp t])
699 [pexp t])
700
700
701+ -- case is tricky enough without implicit coercions! If they are needed,
702+ -- they can go in the branches separately.
703+ insertCoerce ina t@(PCase _ _ _) = return t
701 insertCoerce ina t =
704 insertCoerce ina t =
702 do ty <- goal
705 do ty <- goal
703 -- Check for possible coercions to get to the goal
706 -- Check for possible coercions to get to the goal