on master help sign in
Minor change to disambiguation rules

When trying alternatives, if elaborating the first introduces unresolved type classes, consider this a failure and elaborate the second. Normally, type classes should resolve as soon after application as possible. (aside: we need to write down precise rules for type-directed disambiguation; they are not straightforward due to the possibility of delaying type class resolution, auto implicits and unresolved unification problems. There is a trade off between successful disambiguation and efficient enough compilation, so we should write down what the current trade off is.)

commita2b3c792bcac309cdf076c143f35fe55a1789f03 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateFri 3 Apr 2015, 11:44 (12 years ago) parent2e919c8
1 file changed+5−1
src/Idris/Core/Elaborate.hs+5−1
src/Idris/Core/Elaborate.hs+5−1
@@ -759,9 +759,13 @@ try' t1 t2 proofSearch
759759 = do s <- get
760760 ps <- get_probs
761761 ulog <- getUnifyLog
762+ ivs <- get_instances
762763 case prunStateT 999999 False ps t1 s of
763− OK ((v, _, _), s') -> do put s'
764+ OK ((v, _, _), s')
765+ | length (instances (proof s')) <= length ivs ->
766+ do put s'
764767 return $! v
768+ | otherwise -> t2
765769 Error e1 -> traceWhen ulog ("try failed " ++ show e1) $
766770 if recoverableErr e1 then
767771 do case runStateT t2 s of