@@ -72,6 +72,7 @@ build ist info emode opts fn tm
7272 mapM_ (\n -> when (n `elem` hs) $
7373 do focus n
7474 g <- goal
75+ ptm <- get_term
7576 resolveTC True True 7 g fn ist) ivs
7677 tm <- get_term
7778 ctxt <- get_context
@@ -965,17 +966,14 @@ elab ist info emode opts fn tm
965966 elab' ina fc (PUnifyLog t) = do unifyLog True
966967 elab' ina fc t
967968 unifyLog False
968− elab' ina fc (PQuasiquote t goal)
969+ elab' ina fc (PQuasiquote t goalt)
969970 = do -- First extract the unquoted subterms, replacing them with fresh
970971 -- names in the quasiquoted term. Claim their reflections to be
971972 -- an inferred type (to support polytypic quasiquotes).
973+ qty <- goal
972974 (t, unq) <- extractUnquotes 0 t
973975 let unquoteNames = map fst unq
974− mapM_ (\uqn -> do uqh <- getNameFrom (sMN 0 "uqh")
975− claim uqh RType
976− movelast uqh
977− claim uqn (Var uqh)) unquoteNames
978−
976+ mapM_ (\uqn -> claim uqn (forget qty)) unquoteNames
979977
980978 -- Save the old state - we need a fresh proof state to avoid
981979 -- capturing lexically available variables in the quoted term.
@@ -1010,7 +1008,7 @@ elab ist info emode opts fn tm
10101008 letbind nTm (Var qTy) (Var qTm)
10111009
10121010 -- Fill out the goal type, if relevant
1013− case goal of
1011+ case goalt of
10141012 Nothing -> return ()
10151013 Just gTy -> do focus qTy
10161014 elabE (ina { e_qq = True }) fc gTy
@@ -1346,7 +1344,7 @@ findInstances :: IState -> Term -> [Name]
13461344findInstances ist t
13471345 | (P _ n _, _) <- unApply t
13481346 = case lookupCtxt n (idris_classes ist) of
1349− [CI _ _ _ _ _ ins] -> ins
1347+ [CI _ _ _ _ _ ins _] -> ins
13501348 _ -> []
13511349 | otherwise = []
13521350
@@ -1382,17 +1380,18 @@ resolveTC :: Bool -- using default Int
13821380 -> Term -- top level goal
13831381 -> Name -- top level function name
13841382 -> IState -> ElabD ()
1385−resolveTC = resTC' []
1383+resolveTC def mvok depth top fn ist
1384+ = do hs <- get_holes
1385+ resTC' [] def hs depth top fn ist
13861386
1387−resTC' tcs def mvok 0 topg fn ist = fail $ "Can't resolve type class"
1388−resTC' tcs def mvok 1 topg fn ist = try' (trivial' ist) (resolveTC def mvok 0 topg fn ist) True
1389−resTC' tcs defaultOn mvok depth topg fn ist
1387+resTC' tcs def topholes 0 topg fn ist = fail $ "Can't resolve type class"
1388+resTC' tcs def topholes 1 topg fn ist = try' (trivial' ist) (resolveTC def False 0 topg fn ist) True
1389+resTC' tcs defaultOn topholes depth topg fn ist
13901390 = do compute
13911391 g <- goal
1392− hs <- get_holes
1393− let argsok = tcArgsOK g hs
1394−-- trace (show (g,hs,argsok,mvok)) $
1395− if (not argsok && not mvok)
1392+ let argsok = tcArgsOK g topholes
1393+-- trace (show (g,hs,argsok,topholes)) $
1394+ if not argsok -- && not mvok)
13961395 then lift $ tfail $ CantResolve True topg
13971396 else do
13981397 ptm <- get_term
@@ -1415,7 +1414,16 @@ resTC' tcs defaultOn mvok depth topg fn ist
14151414 = True
14161415 tcArgsOK ty hs -- if any arguments are metavariables, postpone
14171416 = let (f, as) = unApply ty in
1418− not $ any (isMeta hs) as
1417+ case f of
1418+ P _ cn _ -> case lookupCtxtExact cn (idris_classes ist) of
1419+ Just ci -> tcDetArgsOK 0 (class_determiners ci) hs as
1420+ Nothing -> not $ any (isMeta hs) as
1421+ _ -> not $ any (isMeta hs) as
1422+
1423+ tcDetArgsOK i ds hs (x : xs)
1424+ | i `elem` ds = not (isMeta hs x) && tcDetArgsOK (i + 1) ds hs xs
1425+ | otherwise = tcDetArgsOK (i + 1) ds hs xs
1426+ tcDetArgsOK _ _ _ [] = True
14191427
14201428 isMeta :: [Name] -> Term -> Bool
14211429 isMeta ns (P _ n _) = n `elem` ns
@@ -1489,7 +1497,7 @@ resTC' tcs defaultOn mvok depth topg fn ist
14891497 let got = fst (unApply t)
14901498 let depth' = if tc' `elem` tcs
14911499 then depth - 1 else depth
1492− resTC' (got : tcs) defaultOn mvok depth' topg fn ist)
1500+ resTC' (got : tcs) defaultOn topholes depth' topg fn ist)
14931501 (filter (\ (x, y) -> not x) (zip (map fst imps) args))
14941502 -- if there's any arguments left, we've failed to resolve
14951503 hs <- get_holes