@@ -76,7 +76,7 @@ elabType info syn fc opts n ty' = {- let ty' = piBind (params info) ty_in
76 addIBC (IBCAccess n Frozen)
76 addIBC (IBCAccess n Frozen)
78elabData :: ElabInfo -> SyntaxInfo -> FC -> Bool -> PData -> Idris ()
78elabData :: ElabInfo -> SyntaxInfo -> FC -> Bool -> PData -> Idris ()
79−elabData info syn fc codata (PDatadecl n t_in dcons)
79+elabData info syn fc codata (PLaterdecl n t_in)
80 = do iLOG (show fc)
80 = do iLOG (show fc)
81 checkUndefined fc n
81 checkUndefined fc n
82 ctxt <- getContext
82 ctxt <- getContext
@@ -91,6 +91,23 @@ elabData info syn fc codata (PDatadecl n t_in dcons)
91 (cty, _) <- recheckC fc [] t'
91 (cty, _) <- recheckC fc [] t'
92 logLvl 2 $ "---> " ++ show cty
92 logLvl 2 $ "---> " ++ show cty
93 updateContext (addTyDecl n cty) -- temporary, to check cons
93 updateContext (addTyDecl n cty) -- temporary, to check cons
95+elabData info syn fc codata (PDatadecl n t_in dcons)
97+ undef <- isUndefined fc n
100+ t_in <- implicit syn n t_in
101+ let t = addImpl i t_in
102+ ((t', defer, is), log) <- tclift $ elaborate ctxt n (Set (UVal 0)) []
103+ (erun fc (build i info False n t))
104+ def' <- checkDef fc defer
106+ mapM_ (elabCaseBlock info) is
107+ (cty, _) <- recheckC fc [] t'
108+ logLvl 2 $ "---> " ++ show cty
109+ -- temporary, to check cons
110+ when undef $ updateContext (addTyDecl n cty)
94 cons <- mapM (elabCon info syn n codata) dcons
111 cons <- mapM (elabCon info syn n codata) dcons
95 ttag <- getName
112 ttag <- getName
@@ -123,7 +140,7 @@ elabRecord info syn fc tyn ty cn cty
123 let nonImp = mapMaybe isNonImp (zip cimp ptys_u)
140 let nonImp = mapMaybe isNonImp (zip cimp ptys_u)
124 let implBinds = getImplB id cty'
141 let implBinds = getImplB id cty'
125 update_decls <- mapM (mkUpdate recty implBinds (length nonImp)) (zip nonImp [0..])
142 update_decls <- mapM (mkUpdate recty implBinds (length nonImp)) (zip nonImp [0..])
126− mapM_ (elabDecl info) (concat proj_decls)
143+ mapM_ (elabDecl EAll info) (concat proj_decls)
127 mapM_ (tryElabDecl info) (update_decls)
144 mapM_ (tryElabDecl info) (update_decls)
129-- syn = syn_in { syn_namespace = show (nsroot tyn) : syn_namespace syn_in }
146-- syn = syn_in { syn_namespace = show (nsroot tyn) : syn_namespace syn_in }
@@ -542,7 +559,7 @@ elabClause info tcgen (PWith fc fname lhs_in withs wval_in withblock)
542 -- ==> fname' ps wpat [rest], match pats against toplevel for ps
559 -- ==> fname' ps wpat [rest], match pats against toplevel for ps
543 wb <- mapM (mkAuxC wname lhs (map fst bargs)) withblock
560 wb <- mapM (mkAuxC wname lhs (map fst bargs)) withblock
544 logLvl 5 ("with block " ++ show wb)
561 logLvl 5 ("with block " ++ show wb)
545− mapM_ (elabDecl info) wb
562+ mapM_ (elabDecl EAll info) wb
547 -- rhs becomes: fname' ps wval
564 -- rhs becomes: fname' ps wval
548 let rhs = PApp fc (PRef fc wname) (map (pexp . (PRef fc) . fst) bargs ++
565 let rhs = PApp fc (PRef fc wname) (map (pexp . (PRef fc) . fst) bargs ++
@@ -628,12 +645,12 @@ elabClass info syn fc constraints tn ps ds
628 logLvl 5 $ "Building functions"
645 logLvl 5 $ "Building functions"
629 let usyn = syn { using = ps ++ using syn }
646 let usyn = syn { using = ps ++ using syn }
630 fns <- mapM (cfun cn constraint usyn (map fst imethods)) constraints
647 fns <- mapM (cfun cn constraint usyn (map fst imethods)) constraints
631− mapM_ (elabDecl info) (concat fns)
648+ mapM_ (elabDecl EAll info) (concat fns)
632 -- for each method, build a top level function
649 -- for each method, build a top level function
633 fns <- mapM (tfun cn constraint usyn (map fst imethods)) imethods
650 fns <- mapM (tfun cn constraint usyn (map fst imethods)) imethods
634− mapM_ (elabDecl info) (concat fns)
651+ mapM_ (elabDecl EAll info) (concat fns)
635 -- add the default definitions
652 -- add the default definitions
636− mapM_ (elabDecl info) (concat (map (snd.snd) defs))
653+ mapM_ (elabDecl EAll info) (concat (map (snd.snd) defs))
638 let defaults = map (\ (x, (y, z)) -> (x,y)) defs
655 let defaults = map (\ (x, (y, z)) -> (x,y)) defs
639 addClass tn (CI cn imethods defaults (map fst ps) [])
656 addClass tn (CI cn imethods defaults (map fst ps) [])
@@ -795,7 +812,7 @@ elabInstance info syn fc cs n ps t expn ds
795 let idecls = [PClauses fc [Inlinable, TCGen] iname
812 let idecls = [PClauses fc [Inlinable, TCGen] iname
796 [PClause fc iname lhs [] rhs wb]]
813 [PClause fc iname lhs [] rhs wb]]
797 iLOG (show idecls)
814 iLOG (show idecls)
798− mapM (elabDecl info) idecls
815+ mapM (elabDecl EAll info) idecls
799 addIBC (IBCInstance intInst n iname)
816 addIBC (IBCInstance intInst n iname)
801 intInst = case ps of
818 intInst = case ps of
@@ -915,11 +932,16 @@ pvars ist _ = []
915data ElabWhat = ETypes | EDefns | EAll
932data ElabWhat = ETypes | EDefns | EAll
916 deriving (Show, Eq)
933 deriving (Show, Eq)
935+elabDecls :: ElabInfo -> [PDecl] -> Idris ()
936+elabDecls info ds = do mapM_ (elabDecl EAll info) ds
937+-- mapM_ (elabDecl EDefns info) ds
918−elabDecl :: ElabInfo -> PDecl -> Idris ()
939+elabDecl :: ElabWhat -> ElabInfo -> PDecl -> Idris ()
919−elabDecl info d = idrisCatch (elabDecl' EAll info d)
941+ = idrisCatch (elabDecl' what info d)
920− (\e -> do let msg = show e
942+ (\e -> do let msg = show e
921− setErrLine (getErrLine msg)
943+ setErrLine (getErrLine msg)
922− iputStrLn msg)
944+ iputStrLn msg)
924elabDecl' _ info (PFix _ _ _)
946elabDecl' _ info (PFix _ _ _)
925 = return () -- nothing to elaborate
947 = return () -- nothing to elaborate
@@ -965,7 +987,7 @@ elabDecl' what info (PClass s f cs n ps ds)
965 = do iLOG $ "Elaborating class " ++ show n
987 = do iLOG $ "Elaborating class " ++ show n
966 elabClass info s f cs n ps ds
988 elabClass info s f cs n ps ds
967elabDecl' what info (PInstance s f cs n ps t expn ds)
989elabDecl' what info (PInstance s f cs n ps t expn ds)
968− | what /= EDefns
990+ | what /= ETypes
969 = do iLOG $ "Elaborating instance " ++ show n
991 = do iLOG $ "Elaborating instance " ++ show n
970 elabInstance info s f cs n ps t expn ds
992 elabInstance info s f cs n ps t expn ds
971elabDecl' what info (PRecord s f tyn ty cn cty)
993elabDecl' what info (PRecord s f tyn ty cn cty)