@@ -82,7 +82,7 @@ elabType' norm info syn doc argDocs fc opts n ty' = {- let ty' = piBind (params
8282
8383 logLvl 3 $ show n ++ " pre-type " ++ showTmImpls ty'
8484 ty' <- addUsingConstraints syn fc ty'
85− ty' <- implicit syn n ty'
85+ ty' <- implicit info syn n ty'
8686
8787 let ty = addImpl i ty'
8888 logLvl 3 $ show n ++ " type " ++ showTmImpls ty
@@ -204,7 +204,8 @@ elabData info syn doc argDocs fc opts (PLaterdecl n t_in)
204204 checkUndefined fc n
205205 ctxt <- getContext
206206 i <- getIState
207− t_in <- implicit syn n t_in
207+ -- TODO think: something more in info?
208+ t_in <- implicit info syn n t_in
208209 let t = addImpl i t_in
209210 ((t', defer, is), log) <- tclift $ elaborate ctxt n (TType (UVal 0)) []
210211 (erun fc (build i info False [] n t))
@@ -222,7 +223,7 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
222223 undef <- isUndefined fc n
223224 ctxt <- getContext
224225 i <- getIState
225− t_in <- implicit syn n t_in
226+ t_in <- implicit info syn n t_in
226227 let t = addImpl i t_in
227228 ((t', defer, is), log) <-
228229 tclift $ elaborate ctxt n (TType (UVal 0)) []
@@ -238,7 +239,8 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
238239 logLvl 2 $ "---> " ++ show cty
239240 -- temporary, to check cons
240241 when undef $ updateContext (addTyDecl n (TCon 0 0) cty)
241− cons <- mapM (elabCon info syn n codata) dcons
242+ let cnameinfo = cinfo info (map cname dcons)
243+ cons <- mapM (elabCon cnameinfo syn n codata) dcons
242244 ttag <- getName
243245 i <- getIState
244246 let as = map (const Nothing) (getArgTys cty)
@@ -321,6 +323,21 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
321323 | otherwise = count n ts
322324 mParam args (_ : rest) = Nothing : mParam args rest
323325
326+ cname (_, _, n, _, _, _) = n
327+
328+ -- Abuse of ElabInfo.
329+ -- TODO Contemplate whether the ElabInfo type needs modification.
330+ cinfo :: ElabInfo -> [Name] -> ElabInfo
331+ cinfo info ds
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,
337+ inblock = newb,
338+ liftname = id -- Is this appropriate?
339+ }
340+
324341type EliminatorState = StateT (Map.Map String Int) Idris
325342
326343-- 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 ->
730747 PTerm -> Docstring -> Name -> PTerm -> Idris ()
731748elabRecord info syn doc fc tyn ty cdoc cn cty
732749 = do elabData info syn doc [] fc [] (PDatadecl tyn ty [(cdoc, [], cn, cty, fc, [])])
733− cty' <- implicit syn cn cty
750+ -- TODO think: something more in info?
751+ cty' <- implicit info syn cn cty
734752 i <- getIState
735753 cty <- case lookupTy cn (tt_ctxt i) of
736754 [t] -> return (delab i t)
@@ -752,7 +770,7 @@ elabRecord info syn doc fc tyn ty cdoc cn cty
752770 where
753771-- syn = syn_in { syn_namespace = show (nsroot tyn) : syn_namespace syn_in }
754772
755− isNonImp (PExp _ _ _, a) = Just a
773+ isNonImp (PExp _ _ _ _, a) = Just a
756774 isNonImp _ = Nothing
757775
758776 tryElabDecl info (fn, ty, val)
@@ -841,7 +859,7 @@ elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
841859 = do checkUndefined fc n
842860 ctxt <- getContext
843861 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)
845863 let t = addImpl i t_in
846864 logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ show t
847865 ((t', defer, is), log) <-
@@ -875,7 +893,7 @@ elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
875893
876894 mkLazy (PPi pl n ty sc)
877895 = let ty' = if getTyName ty
878− then PApp fc (PRef fc (sUN "Lazy'"))
896+ then PApp fc (PRef fc (sUN "Lazy'"))
879897 [pexp (PRef fc (sUN "LazyCodata")),
880898 pexp ty]
881899 else ty in
@@ -1292,7 +1310,7 @@ checkPossible info fc tcgen fname lhs_in
12921310 ((P _ x _, _), (P _ y _, _)) -> x == y
12931311 _ -> False
12941312
1295−getFixedInType i env (PExp _ _ _ : is) (Bind n (Pi t) sc)
1313+getFixedInType i env (PExp _ _ _ _ : is) (Bind n (Pi t) sc)
12961314 = getFixedInType i (n : env) is (instantiate (P Bound n t) sc)
12971315getFixedInType i env (_ : is) (Bind n (Pi t) sc)
12981316 = 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)
14231441 -- Elaborate where block
14241442 ist <- getIState
14251443 windex <- getName
1426− let winfo = pinfo (pvars ist lhs_tm) whereblock windex
14271444 let decls = nub (concatMap declared whereblock)
14281445 let defs = nub (decls ++ concatMap defined whereblock)
14291446 let newargs = pvars ist lhs_tm
1447+ let winfo = pinfo info newargs defs windex
14301448 let wb = map (expandParamsD False ist decorate newargs defs) whereblock
14311449
14321450 -- 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)
14351453 let (wbefore, wafter) = sepBlocks wb
14361454
14371455 logLvl 2 $ "Where block:\n " ++ show wbefore ++ "\n" ++ show wafter
1438− mapM_ (elabDecl' EAll info) wbefore
1456+ mapM_ (elabDecl' EAll winfo) wbefore
14391457 -- Now build the RHS, using the type of the LHS as the goal.
14401458 i <- getIState -- new implicits from where block
14411459 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)
14501468 mapM_ setinj (nub (params ++ inj))
14511469 setNextName
14521470 (_, _, 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))
14541472 errAt "right hand side of " fname
14551473 (erun fc $ psolve lhs_tm)
14561474 hs <- get_holes
@@ -1478,8 +1496,8 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
14781496 -- Now the remaining deferred (i.e. no type declarations) clauses
14791497 -- from the where block
14801498
1481− mapM_ (elabDecl' EAll info) wafter
1482− mapM_ (elabCaseBlock info opts) is
1499+ mapM_ (elabDecl' EAll winfo) wafter
1500+ mapM_ (elabCaseBlock winfo opts) is
14831501
14841502 ctxt <- getContext
14851503 logLvl 5 $ "Rechecking"
@@ -1509,6 +1527,19 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
15091527 addErrRev (crhs, clhs)
15101528 return $ (Right (clhs, crhs), lhs)
15111529 where
1530+ pinfo :: ElabInfo -> [(Name, PTerm)] -> [Name] -> Int -> ElabInfo
1531+ pinfo info ns ds i
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,
1537+ inblock = newb,
1538+ liftname = id -- (\n -> case lookupCtxt n newb of
1539+ -- Nothing -> n
1540+ -- _ -> MN i (show n)) . l
1541+ }
1542+
15121543 mkLHSapp t@(PRef _ _) = trace ("APP " ++ show t) $ PApp fc t []
15131544 mkLHSapp t = t
15141545
@@ -1531,19 +1562,6 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
15311562 (b : bf, af)
15321563 sepBlocks' ns [] = ([], [])
15331564
1534− pinfo ns ps i
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,
1541− inblock = newb,
1542− liftname = id -- (\n -> case lookupCtxt n newb of
1543− -- Nothing -> n
1544− -- _ -> MN i (show n)) . l
1545− }
1546−
15471565
15481566 -- if a hole is just an argument/result of a case block, treat it as
15491567 -- the unit type. Hack to help elaborate case in do blocks.
@@ -1808,7 +1826,7 @@ elabClass info syn doc fc constraints tn ps ds
18081826
18091827 getMName (PTy _ _ _ _ _ n _) = nsroot n
18101828 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
18121830 logLvl 5 $ "Method " ++ show n ++ " : " ++ showTmImpls t'
18131831 return ( (n, (toExp (map fst ps) Exp t')),
18141832 (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
20122030 -- TODO: largely based upon elabType' - should try to abstract
20132031 elabFindOverlapping i ci iname syn t
20142032 = do ty' <- addUsingConstraints syn fc t
2015− ty' <- implicit syn iname ty'
2033+ -- TODO think: something more in info?
2034+ ty' <- implicit info syn iname ty'
20162035 let ty = addImpl i ty'
20172036 ctxt <- getContext
20182037 ((tyT, _, _), _) <-
@@ -2050,9 +2069,9 @@ elabInstance info syn what fc cs n ps t expn ds = do
20502069 methArgs i (PPi (Imp _ _ _) n ty sc)
20512070 = PImp 0 True [] n (PRef fc (sMN i "meth")) : methArgs (i+1) sc
20522071 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
20542073 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
20562075 methArgs i _ = []
20572076
20582077 papp fc f [] = f