@@ -82,7 +82,7 @@ elabType' norm info syn doc argDocs fc opts n ty' = {- let ty' = piBind (params
83 logLvl 3 $ show n ++ " pre-type " ++ showTmImpls ty'
83 logLvl 3 $ show n ++ " pre-type " ++ showTmImpls ty'
84 ty' <- addUsingConstraints syn fc ty'
84 ty' <- addUsingConstraints syn fc ty'
85− ty' <- implicit syn n ty'
85+ ty' <- implicit info syn n ty'
87 let ty = addImpl i ty'
87 let ty = addImpl i ty'
88 logLvl 3 $ show n ++ " type " ++ showTmImpls ty
88 logLvl 3 $ show n ++ " type " ++ showTmImpls ty
@@ -204,7 +204,8 @@ elabData info syn doc argDocs fc opts (PLaterdecl n t_in)
204 checkUndefined fc n
204 checkUndefined fc n
205 ctxt <- getContext
205 ctxt <- getContext
206 i <- getIState
206 i <- getIState
207+ -- TODO think: something more in info?
207− t_in <- implicit syn n t_in
208+ t_in <- implicit info syn n t_in
208 let t = addImpl i t_in
209 let t = addImpl i t_in
209 ((t', defer, is), log) <- tclift $ elaborate ctxt n (TType (UVal 0)) []
210 ((t', defer, is), log) <- tclift $ elaborate ctxt n (TType (UVal 0)) []
210 (erun fc (build i info False [] n t))
211 (erun fc (build i info False [] n t))
@@ -222,7 +223,7 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
222 undef <- isUndefined fc n
223 undef <- isUndefined fc n
223 ctxt <- getContext
224 ctxt <- getContext
224 i <- getIState
225 i <- getIState
225− t_in <- implicit syn n t_in
226+ t_in <- implicit info syn n t_in
226 let t = addImpl i t_in
227 let t = addImpl i t_in
227 ((t', defer, is), log) <-
228 ((t', defer, is), log) <-
228 tclift $ elaborate ctxt n (TType (UVal 0)) []
229 tclift $ elaborate ctxt n (TType (UVal 0)) []
@@ -238,7 +239,8 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
238 logLvl 2 $ "---> " ++ show cty
239 logLvl 2 $ "---> " ++ show cty
239 -- temporary, to check cons
240 -- temporary, to check cons
240 when undef $ updateContext (addTyDecl n (TCon 0 0) cty)
241 when undef $ updateContext (addTyDecl n (TCon 0 0) cty)
242+ let cnameinfo = cinfo info (map cname dcons)
241− cons <- mapM (elabCon info syn n codata) dcons
243+ cons <- mapM (elabCon cnameinfo syn n codata) dcons
242 ttag <- getName
244 ttag <- getName
243 i <- getIState
245 i <- getIState
244 let as = map (const Nothing) (getArgTys cty)
246 let as = map (const Nothing) (getArgTys cty)
@@ -321,6 +323,21 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
321 | otherwise = count n ts
323 | otherwise = count n ts
322 mParam args (_ : rest) = Nothing : mParam args rest
324 mParam args (_ : rest) = Nothing : mParam args rest
326+ cname (_, _, n, _, _, _) = n
328+ -- Abuse of ElabInfo.
329+ -- TODO Contemplate whether the ElabInfo type needs modification.
330+ cinfo :: ElabInfo -> [Name] -> ElabInfo
332+ = let newps = params info
333+ dsParams = map (\n -> (n, [])) ds
334+ newb = addAlist dsParams (inblock info)
335+ l = liftname info in
336+ info { params = newps,
338+ liftname = id -- Is this appropriate?
324type EliminatorState = StateT (Map.Map String Int) Idris
341type EliminatorState = StateT (Map.Map String Int) Idris
326-- TODO: Use uniqueName for generating names, rewrite everything to use idris_implicits instead of manual splitting, generally just rewrite
343-- TODO: Use uniqueName for generating names, rewrite everything to use idris_implicits instead of manual splitting, generally just rewrite
@@ -730,7 +747,8 @@ elabRecord :: ElabInfo -> SyntaxInfo -> Docstring -> FC -> Name ->
730 PTerm -> Docstring -> Name -> PTerm -> Idris ()
747 PTerm -> Docstring -> Name -> PTerm -> Idris ()
731elabRecord info syn doc fc tyn ty cdoc cn cty
748elabRecord info syn doc fc tyn ty cdoc cn cty
732 = do elabData info syn doc [] fc [] (PDatadecl tyn ty [(cdoc, [], cn, cty, fc, [])])
749 = do elabData info syn doc [] fc [] (PDatadecl tyn ty [(cdoc, [], cn, cty, fc, [])])
750+ -- TODO think: something more in info?
733− cty' <- implicit syn cn cty
751+ cty' <- implicit info syn cn cty
734 i <- getIState
752 i <- getIState
735 cty <- case lookupTy cn (tt_ctxt i) of
753 cty <- case lookupTy cn (tt_ctxt i) of
736 [t] -> return (delab i t)
754 [t] -> return (delab i t)
@@ -752,7 +770,7 @@ elabRecord info syn doc fc tyn ty cdoc cn cty
753-- syn = syn_in { syn_namespace = show (nsroot tyn) : syn_namespace syn_in }
771-- syn = syn_in { syn_namespace = show (nsroot tyn) : syn_namespace syn_in }
755− isNonImp (PExp _ _ _, a) = Just a
773+ isNonImp (PExp _ _ _ _, a) = Just a
756 isNonImp _ = Nothing
774 isNonImp _ = Nothing
758 tryElabDecl info (fn, ty, val)
776 tryElabDecl info (fn, ty, val)
@@ -841,7 +859,7 @@ elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
841 = do checkUndefined fc n
859 = do checkUndefined fc n
842 ctxt <- getContext
860 ctxt <- getContext
843 i <- getIState
861 i <- getIState
844− t_in <- implicit syn n (if codata then mkLazy t_in else t_in)
862+ t_in <- implicit info syn n (if codata then mkLazy t_in else t_in)
845 let t = addImpl i t_in
863 let t = addImpl i t_in
846 logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ show t
864 logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ show t
847 ((t', defer, is), log) <-
865 ((t', defer, is), log) <-
@@ -875,7 +893,7 @@ elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
876 mkLazy (PPi pl n ty sc)
894 mkLazy (PPi pl n ty sc)
877 = let ty' = if getTyName ty
895 = let ty' = if getTyName ty
878− then PApp fc (PRef fc (sUN "Lazy'"))
896+ then PApp fc (PRef fc (sUN "Lazy'"))
879 [pexp (PRef fc (sUN "LazyCodata")),
897 [pexp (PRef fc (sUN "LazyCodata")),
881 else ty in
899 else ty in
@@ -1292,7 +1310,7 @@ checkPossible info fc tcgen fname lhs_in
1292 ((P _ x _, _), (P _ y _, _)) -> x == y
1310 ((P _ x _, _), (P _ y _, _)) -> x == y
1293 _ -> False
1311 _ -> False
1295−getFixedInType i env (PExp _ _ _ : is) (Bind n (Pi t) sc)
1313+getFixedInType i env (PExp _ _ _ _ : is) (Bind n (Pi t) sc)
1296 = getFixedInType i (n : env) is (instantiate (P Bound n t) sc)
1314 = getFixedInType i (n : env) is (instantiate (P Bound n t) sc)
1297getFixedInType i env (_ : is) (Bind n (Pi t) sc)
1315getFixedInType i env (_ : is) (Bind n (Pi t) sc)
1298 = getFixedInType i (n : env) is (instantiate (P Bound n t) sc)
1316 = getFixedInType i (n : env) is (instantiate (P Bound n t) sc)
@@ -1423,10 +1441,10 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1423 -- Elaborate where block
1441 -- Elaborate where block
1424 ist <- getIState
1442 ist <- getIState
1425 windex <- getName
1443 windex <- getName
1426− let winfo = pinfo (pvars ist lhs_tm) whereblock windex
1427 let decls = nub (concatMap declared whereblock)
1444 let decls = nub (concatMap declared whereblock)
1428 let defs = nub (decls ++ concatMap defined whereblock)
1445 let defs = nub (decls ++ concatMap defined whereblock)
1429 let newargs = pvars ist lhs_tm
1446 let newargs = pvars ist lhs_tm
1447+ let winfo = pinfo info newargs defs windex
1430 let wb = map (expandParamsD False ist decorate newargs defs) whereblock
1448 let wb = map (expandParamsD False ist decorate newargs defs) whereblock
1432 -- Split the where block into declarations with a type, and those
1450 -- Split the where block into declarations with a type, and those
@@ -1435,7 +1453,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1435 let (wbefore, wafter) = sepBlocks wb
1453 let (wbefore, wafter) = sepBlocks wb
1437 logLvl 2 $ "Where block:\n " ++ show wbefore ++ "\n" ++ show wafter
1455 logLvl 2 $ "Where block:\n " ++ show wbefore ++ "\n" ++ show wafter
1438− mapM_ (elabDecl' EAll info) wbefore
1456+ mapM_ (elabDecl' EAll winfo) wbefore
1439 -- Now build the RHS, using the type of the LHS as the goal.
1457 -- Now build the RHS, using the type of the LHS as the goal.
1440 i <- getIState -- new implicits from where block
1458 i <- getIState -- new implicits from where block
1441 logLvl 5 (showTmImpls (expandParams decorate newargs defs (defs \\ decls) rhs_in))
1459 logLvl 5 (showTmImpls (expandParams decorate newargs defs (defs \\ decls) rhs_in))
@@ -1450,7 +1468,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1450 mapM_ setinj (nub (params ++ inj))
1468 mapM_ setinj (nub (params ++ inj))
1451 setNextName
1469 setNextName
1452 (_, _, is) <- errAt "right hand side of " fname
1470 (_, _, is) <- errAt "right hand side of " fname
1453− (erun fc (build i info False opts fname rhs))
1471+ (erun fc (build i winfo False opts fname rhs))
1454 errAt "right hand side of " fname
1472 errAt "right hand side of " fname
1455 (erun fc $ psolve lhs_tm)
1473 (erun fc $ psolve lhs_tm)
1456 hs <- get_holes
1474 hs <- get_holes
@@ -1478,8 +1496,8 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1478 -- Now the remaining deferred (i.e. no type declarations) clauses
1496 -- Now the remaining deferred (i.e. no type declarations) clauses
1479 -- from the where block
1497 -- from the where block
1481− mapM_ (elabDecl' EAll info) wafter
1499+ mapM_ (elabDecl' EAll winfo) wafter
1482− mapM_ (elabCaseBlock info opts) is
1500+ mapM_ (elabCaseBlock winfo opts) is
1484 ctxt <- getContext
1502 ctxt <- getContext
1485 logLvl 5 $ "Rechecking"
1503 logLvl 5 $ "Rechecking"
@@ -1509,6 +1527,19 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1509 addErrRev (crhs, clhs)
1527 addErrRev (crhs, clhs)
1510 return $ (Right (clhs, crhs), lhs)
1528 return $ (Right (clhs, crhs), lhs)
1530+ pinfo :: ElabInfo -> [(Name, PTerm)] -> [Name] -> Int -> ElabInfo
1532+ = let newps = params info ++ ns
1533+ dsParams = map (\n -> (n, map fst newps)) ds
1534+ newb = addAlist dsParams (inblock info)
1535+ l = liftname info in
1536+ info { params = newps,
1538+ liftname = id -- (\n -> case lookupCtxt n newb of
1540+ -- _ -> MN i (show n)) . l
1512 mkLHSapp t@(PRef _ _) = trace ("APP " ++ show t) $ PApp fc t []
1543 mkLHSapp t@(PRef _ _) = trace ("APP " ++ show t) $ PApp fc t []
1513 mkLHSapp t = t
1544 mkLHSapp t = t
@@ -1531,19 +1562,6 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
1531 (b : bf, af)
1562 (b : bf, af)
1532 sepBlocks' ns [] = ([], [])
1563 sepBlocks' ns [] = ([], [])
1535− = let ds = concatMap declared ps
1536− newps = params info ++ ns
1537− dsParams = map (\n -> (n, map fst newps)) ds
1538− newb = addAlist dsParams (inblock info)
1539− l = liftname info in
1540− info { params = newps,
1542− liftname = id -- (\n -> case lookupCtxt n newb of
1544− -- _ -> MN i (show n)) . l
1548 -- if a hole is just an argument/result of a case block, treat it as
1566 -- if a hole is just an argument/result of a case block, treat it as
1549 -- the unit type. Hack to help elaborate case in do blocks.
1567 -- the unit type. Hack to help elaborate case in do blocks.
@@ -1808,7 +1826,7 @@ elabClass info syn doc fc constraints tn ps ds
1809 getMName (PTy _ _ _ _ _ n _) = nsroot n
1827 getMName (PTy _ _ _ _ _ n _) = nsroot n
1810 tdecl allmeths (PTy doc _ syn _ o n t)
1828 tdecl allmeths (PTy doc _ syn _ o n t)
1811− = do t' <- implicit' syn allmeths n t
1829+ = do t' <- implicit' info syn allmeths n t
1812 logLvl 5 $ "Method " ++ show n ++ " : " ++ showTmImpls t'
1830 logLvl 5 $ "Method " ++ show n ++ " : " ++ showTmImpls t'
1813 return ( (n, (toExp (map fst ps) Exp t')),
1831 return ( (n, (toExp (map fst ps) Exp t')),
1814 (n, (doc, o, (toExp (map fst ps) Imp t'))),
1832 (n, (doc, o, (toExp (map fst ps) Imp t'))),
@@ -2012,7 +2030,8 @@ elabInstance info syn what fc cs n ps t expn ds = do
2012 -- TODO: largely based upon elabType' - should try to abstract
2030 -- TODO: largely based upon elabType' - should try to abstract
2013 elabFindOverlapping i ci iname syn t
2031 elabFindOverlapping i ci iname syn t
2014 = do ty' <- addUsingConstraints syn fc t
2032 = do ty' <- addUsingConstraints syn fc t
2033+ -- TODO think: something more in info?
2015− ty' <- implicit syn iname ty'
2034+ ty' <- implicit info syn iname ty'
2016 let ty = addImpl i ty'
2035 let ty = addImpl i ty'
2017 ctxt <- getContext
2036 ctxt <- getContext
2018 ((tyT, _, _), _) <-
2037 ((tyT, _, _), _) <-
@@ -2050,9 +2069,9 @@ elabInstance info syn what fc cs n ps t expn ds = do
2050 methArgs i (PPi (Imp _ _ _) n ty sc)
2069 methArgs i (PPi (Imp _ _ _) n ty sc)
2051 = PImp 0 True [] n (PRef fc (sMN i "meth")) : methArgs (i+1) sc
2070 = PImp 0 True [] n (PRef fc (sMN i "meth")) : methArgs (i+1) sc
2052 methArgs i (PPi (Exp _ _ _) n ty sc)
2071 methArgs i (PPi (Exp _ _ _) n ty sc)
2053− = PExp 0 [] (PRef fc (sMN i "meth")) : methArgs (i+1) sc
2072+ = PExp 0 [] (sMN 0 "marg") (PRef fc (sMN i "meth")) : methArgs (i+1) sc
2054 methArgs i (PPi (Constraint _ _) n ty sc)
2073 methArgs i (PPi (Constraint _ _) n ty sc)
2055− = PConstraint 0 [] (PResolveTC fc) : methArgs (i+1) sc
2074+ = PConstraint 0 [] (sMN 0 "marg") (PResolveTC fc) : methArgs (i+1) sc
2056 methArgs i _ = []
2075 methArgs i _ = []
2058 papp fc f [] = f
2077 papp fc f [] = f