@@ -292,12 +292,12 @@ makeLemma fn updatefile l n
292 let isProv = checkProv tyline (show n)
292 let isProv = checkProv tyline (show n)
294 ctxt <- getContext
294 ctxt <- getContext
295− mty <- case lookupTyName n ctxt of
295+ (fname, mty) <- case lookupTyName n ctxt of
296− [(_,t)] -> return t
296+ [t] -> return t
297− [] -> ierror (NoSuchVariable n)
297+ [] -> ierror (NoSuchVariable n)
298− ns -> ierror (CantResolveAlts (map fst ns))
298+ ns -> ierror (CantResolveAlts (map fst ns))
299 i <- getIState
299 i <- getIState
300− margs <- case lookup n (idris_metavars i) of
300+ margs <- case lookup fname (idris_metavars i) of
301 Just (_, arity, _, _) -> return arity
301 Just (_, arity, _, _) -> return arity
302 _ -> return (-1)
302 _ -> return (-1)
@@ -308,7 +308,7 @@ makeLemma fn updatefile l n
308 let lem = show n ++ " : " ++
308 let lem = show n ++ " : " ++
309 constraints i classes mty ++
309 constraints i classes mty ++
310 showTmOpts (defaultPPOption { ppopt_pinames = True })
310 showTmOpts (defaultPPOption { ppopt_pinames = True })
311− (stripMNBind skip (delab i mty))
311+ (stripMNBind skip margs (delab i mty))
312 let lem_app = show n ++ appArgs skip margs mty
312 let lem_app = show n ++ appArgs skip margs mty
314 if updatefile then
314 if updatefile then
@@ -351,12 +351,13 @@ makeLemma fn updatefile l n
351 appArgs skip i (Bind _ (Pi _ _ _) sc) = appArgs skip (i - 1) sc
351 appArgs skip i (Bind _ (Pi _ _ _) sc) = appArgs skip (i - 1) sc
352 appArgs skip i _ = ""
352 appArgs skip i _ = ""
354+ stripMNBind _ args t | args <= 0 = t
354− stripMNBind skip (PPi b n@(UN c) _ ty sc)
355+ stripMNBind skip args (PPi b n@(UN c) _ ty sc)
355− | (thead c /= '_' && n `notElem` skip) ||
356+ | n `notElem` skip ||
356 take 4 (str c) == "__pi" -- keep in type, but not in app
357 take 4 (str c) == "__pi" -- keep in type, but not in app
357− = PPi b n NoFC ty (stripMNBind skip sc)
358+ = PPi b n NoFC ty (stripMNBind skip (args - 1) sc)
358− stripMNBind skip (PPi b _ _ ty sc) = stripMNBind skip sc
359+ stripMNBind skip args (PPi b _ _ ty sc) = stripMNBind skip (args - 1) sc
359− stripMNBind skip t = t
360+ stripMNBind skip args t = t
361 constraints :: IState -> [Name] -> Type -> String
362 constraints :: IState -> [Name] -> Type -> String
362 constraints i [] ty = ""
363 constraints i [] ty = ""
@@ -374,13 +375,23 @@ makeLemma fn updatefile l n
374 -- or at the top level themselves.
375 -- or at the top level themselves.
375 -- Also, make type class instances implicit
376 -- Also, make type class instances implicit
376 guessImps :: IState -> Context -> Term -> [Name]
377 guessImps :: IState -> Context -> Term -> [Name]
378+ -- machine names aren't lifted
379+ guessImps ist ctxt (Bind n@(MN _ _) (Pi _ ty _) sc)
380+ = n : guessImps ist ctxt sc
377 guessImps ist ctxt (Bind n (Pi _ ty _) sc)
381 guessImps ist ctxt (Bind n (Pi _ ty _) sc)
378 | guarded ctxt n (substV (P Bound n Erased) sc)
382 | guarded ctxt n (substV (P Bound n Erased) sc)
379 = n : guessImps ist ctxt sc
383 = n : guessImps ist ctxt sc
380 | isClass ist ty
384 | isClass ist ty
381 = n : guessImps ist ctxt sc
385 = n : guessImps ist ctxt sc
386+ | TType _ <- ty = n : guessImps ist ctxt sc
387+ | ignoreName n = n : guessImps ist ctxt sc
382 | otherwise = guessImps ist ctxt sc
388 | otherwise = guessImps ist ctxt sc
383 guessImps ist ctxt _ = []
389 guessImps ist ctxt _ = []
391+ -- TMP HACK unusable name so don't lift
392+ ignoreName n = case show n of
385 guessClasses :: IState -> Context -> Term -> [Name]
396 guessClasses :: IState -> Context -> Term -> [Name]
386 guessClasses ist ctxt (Bind n (Pi _ ty _) sc)
397 guessClasses ist ctxt (Bind n (Pi _ ty _) sc)