@@ -493,7 +493,8 @@ match_fill guess ctxt env (Bind x (Hole ty) sc) =
493 do (val, valty) <- lift $ check ctxt env guess
493 do (val, valty) <- lift $ check ctxt env guess
494-- let valtyn = normalise ctxt env valty
494-- let valtyn = normalise ctxt env valty
495-- let tyn = normalise ctxt env ty
495-- let tyn = normalise ctxt env ty
496− ns <- match_unify' ctxt env (valty, Nothing) (ty, Nothing)
496+ ns <- match_unify' ctxt env (valty, Just $ SourceTerm val)
497+ (ty, Just ExpectedType)
497 ps <- get
498 ps <- get
498 let (uh, uns) = unified ps
499 let (uh, uns) = unified ps
499-- put (ps { unified = (uh, uns ++ ns) })
500-- put (ps { unified = (uh, uns ++ ns) })
@@ -511,7 +512,8 @@ complete_fill :: RunTactic
511complete_fill ctxt env (Bind x (Guess ty val) sc) =
512complete_fill ctxt env (Bind x (Guess ty val) sc) =
512 do let guess = forget val
513 do let guess = forget val
513 (val', valty) <- lift $ check ctxt env guess
514 (val', valty) <- lift $ check ctxt env guess
514− ns <- unify' ctxt env (valty, Nothing) (ty, Nothing)
515+ ns <- unify' ctxt env (valty, Just $ SourceTerm val')
516+ (ty, Just ExpectedType)
515 ps <- get
517 ps <- get
516 let (uh, uns) = unified ps
518 let (uh, uns) = unified ps
517-- put (ps { unified = (uh, uns ++ ns) })
519-- put (ps { unified = (uh, uns ++ ns) })
@@ -529,7 +531,8 @@ solve ctxt env (Bind x (Guess ty val) sc)
529 dropdots <-
531 dropdots <-
530 case lookup x (notunified ps) of
532 case lookup x (notunified ps) of
531 Just tm -> -- trace ("NEED MATCH: " ++ show (x, tm, val) ++ "\nIN " ++ show (pterm ps)) $
533 Just tm -> -- trace ("NEED MATCH: " ++ show (x, tm, val) ++ "\nIN " ++ show (pterm ps)) $
532− do match_unify' ctxt env (tm, Nothing) (val, Nothing)
534+ do match_unify' ctxt env (tm, Just InferredVal)
535+ (val, Just GivenVal)
533 return [x]
536 return [x]
534 _ -> return []
537 _ -> return []
535 action (\ps -> ps { holes = traceWhen (unifylog ps) ("Dropping hole " ++ show x) $
538 action (\ps -> ps { holes = traceWhen (unifylog ps) ("Dropping hole " ++ show x) $
@@ -822,13 +825,17 @@ updateEnv ns [] = []
822updateEnv ns ((n, b) : env)
825updateEnv ns ((n, b) : env)
823 = (n, fmap (updateSolvedTerm ns) b) : updateEnv ns env
826 = (n, fmap (updateSolvedTerm ns) b) : updateEnv ns env
828+updateProv ns (SourceTerm t) = SourceTerm $ updateSolvedTerm ns t
825updateError [] err = err
831updateError [] err = err
826updateError ns (At f e) = At f (updateError ns e)
832updateError ns (At f e) = At f (updateError ns e)
827updateError ns (Elaborating s n e) = Elaborating s n (updateError ns e)
833updateError ns (Elaborating s n e) = Elaborating s n (updateError ns e)
828updateError ns (ElaboratingArg f a env e)
834updateError ns (ElaboratingArg f a env e)
829 = ElaboratingArg f a env (updateError ns e)
835 = ElaboratingArg f a env (updateError ns e)
830updateError ns (CantUnify b (l,lp) (r,rp) e xs sc)
836updateError ns (CantUnify b (l,lp) (r,rp) e xs sc)
837+ = CantUnify b (updateSolvedTerm ns l, fmap (updateProv ns) lp)
831− = CantUnify b (updateSolvedTerm ns l, lp) (updateSolvedTerm ns r, rp) (updateError ns e) xs sc
838+ (updateSolvedTerm ns r, fmap (updateProv ns) rp) (updateError ns e) xs sc
832updateError ns e = e
839updateError ns e = e
834solveInProblems x val [] = []
841solveInProblems x val [] = []