@@ -99,6 +99,7 @@ build ist info emode opts fn tm
9999 mapM_ (\n -> when (n `elem` hs) $
100100 do focus n
101101 g <- goal
102+ ptm <- get_term
102103 resolveTC True True 7 g fn ist) ivs
103104 tm <- get_term
104105 ctxt <- get_context
@@ -994,17 +995,14 @@ elab ist info emode opts fn tm
994995 elab' ina fc (PUnifyLog t) = do unifyLog True
995996 elab' ina fc t
996997 unifyLog False
997− elab' ina fc (PQuasiquote t goal)
998+ elab' ina fc (PQuasiquote t goalt)
998999 = do -- First extract the unquoted subterms, replacing them with fresh
9991000 -- names in the quasiquoted term. Claim their reflections to be
10001001 -- an inferred type (to support polytypic quasiquotes).
1002+ qty <- goal
10011003 (t, unq) <- extractUnquotes 0 t
10021004 let unquoteNames = map fst unq
1003− mapM_ (\uqn -> do uqh <- getNameFrom (sMN 0 "uqh")
1004− claim uqh RType
1005− movelast uqh
1006− claim uqn (Var uqh)) unquoteNames
1007−
1005+ mapM_ (\uqn -> claim uqn (forget qty)) unquoteNames
10081006
10091007 -- Save the old state - we need a fresh proof state to avoid
10101008 -- capturing lexically available variables in the quoted term.
@@ -1039,7 +1037,7 @@ elab ist info emode opts fn tm
10391037 letbind nTm (Var qTy) (Var qTm)
10401038
10411039 -- Fill out the goal type, if relevant
1042− case goal of
1040+ case goalt of
10431041 Nothing -> return ()
10441042 Just gTy -> do focus qTy
10451043 elabE (ina { e_qq = True }) fc gTy
@@ -1375,7 +1373,7 @@ findInstances :: IState -> Term -> [Name]
13751373findInstances ist t
13761374 | (P _ n _, _) <- unApply t
13771375 = case lookupCtxt n (idris_classes ist) of
1378− [CI _ _ _ _ _ ins] -> ins
1376+ [CI _ _ _ _ _ ins _] -> ins
13791377 _ -> []
13801378 | otherwise = []
13811379
@@ -1411,17 +1409,18 @@ resolveTC :: Bool -- using default Int
14111409 -> Term -- top level goal
14121410 -> Name -- top level function name
14131411 -> IState -> ElabD ()
1414−resolveTC = resTC' []
1412+resolveTC def mvok depth top fn ist
1413+ = do hs <- get_holes
1414+ resTC' [] def hs depth top fn ist
14151415
1416−resTC' tcs def mvok 0 topg fn ist = fail $ "Can't resolve type class"
1417−resTC' tcs def mvok 1 topg fn ist = try' (trivial' ist) (resolveTC def mvok 0 topg fn ist) True
1418−resTC' tcs defaultOn mvok depth topg fn ist
1416+resTC' tcs def topholes 0 topg fn ist = fail $ "Can't resolve type class"
1417+resTC' tcs def topholes 1 topg fn ist = try' (trivial' ist) (resolveTC def False 0 topg fn ist) True
1418+resTC' tcs defaultOn topholes depth topg fn ist
14191419 = do compute
14201420 g <- goal
1421− hs <- get_holes
1422− let argsok = tcArgsOK g hs
1423−-- trace (show (g,hs,argsok,mvok)) $
1424− if (not argsok && not mvok)
1421+ let argsok = tcArgsOK g topholes
1422+-- trace (show (g,hs,argsok,topholes)) $
1423+ if not argsok -- && not mvok)
14251424 then lift $ tfail $ CantResolve True topg
14261425 else do
14271426 ptm <- get_term
@@ -1444,7 +1443,16 @@ resTC' tcs defaultOn mvok depth topg fn ist
14441443 = True
14451444 tcArgsOK ty hs -- if any arguments are metavariables, postpone
14461445 = let (f, as) = unApply ty in
1447− not $ any (isMeta hs) as
1446+ case f of
1447+ P _ cn _ -> case lookupCtxtExact cn (idris_classes ist) of
1448+ Just ci -> tcDetArgsOK 0 (class_determiners ci) hs as
1449+ Nothing -> not $ any (isMeta hs) as
1450+ _ -> not $ any (isMeta hs) as
1451+
1452+ tcDetArgsOK i ds hs (x : xs)
1453+ | i `elem` ds = not (isMeta hs x) && tcDetArgsOK (i + 1) ds hs xs
1454+ | otherwise = tcDetArgsOK (i + 1) ds hs xs
1455+ tcDetArgsOK _ _ _ [] = True
14481456
14491457 isMeta :: [Name] -> Term -> Bool
14501458 isMeta ns (P _ n _) = n `elem` ns
@@ -1518,7 +1526,7 @@ resTC' tcs defaultOn mvok depth topg fn ist
15181526 let got = fst (unApply t)
15191527 let depth' = if tc' `elem` tcs
15201528 then depth - 1 else depth
1521− resTC' (got : tcs) defaultOn mvok depth' topg fn ist)
1529+ resTC' (got : tcs) defaultOn topholes depth' topg fn ist)
15221530 (filter (\ (x, y) -> not x) (zip (map fst imps) args))
15231531 -- if there's any arguments left, we've failed to resolve
15241532 hs <- get_holes