@@ -76,7 +76,7 @@ elabType info syn fc opts n ty' = {- let ty' = piBind (params info) ty_in
7676 addIBC (IBCAccess n Frozen)
7777
7878elabData :: 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)
8080 = do iLOG (show fc)
8181 checkUndefined fc n
8282 ctxt <- getContext
@@ -91,6 +91,23 @@ elabData info syn fc codata (PDatadecl n t_in dcons)
9191 (cty, _) <- recheckC fc [] t'
9292 logLvl 2 $ "---> " ++ show cty
9393 updateContext (addTyDecl n cty) -- temporary, to check cons
94+
95+elabData info syn fc codata (PDatadecl n t_in dcons)
96+ = do iLOG (show fc)
97+ undef <- isUndefined fc n
98+ ctxt <- getContext
99+ i <- get
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
105+ addDeferred def'
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)
94111 cons <- mapM (elabCon info syn n codata) dcons
95112 ttag <- getName
96113 i <- get
@@ -123,7 +140,7 @@ elabRecord info syn fc tyn ty cn cty
123140 let nonImp = mapMaybe isNonImp (zip cimp ptys_u)
124141 let implBinds = getImplB id cty'
125142 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)
127144 mapM_ (tryElabDecl info) (update_decls)
128145 where
129146-- 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)
542559 -- ==> fname' ps wpat [rest], match pats against toplevel for ps
543560 wb <- mapM (mkAuxC wname lhs (map fst bargs)) withblock
544561 logLvl 5 ("with block " ++ show wb)
545− mapM_ (elabDecl info) wb
562+ mapM_ (elabDecl EAll info) wb
546563
547564 -- rhs becomes: fname' ps wval
548565 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
628645 logLvl 5 $ "Building functions"
629646 let usyn = syn { using = ps ++ using syn }
630647 fns <- mapM (cfun cn constraint usyn (map fst imethods)) constraints
631− mapM_ (elabDecl info) (concat fns)
648+ mapM_ (elabDecl EAll info) (concat fns)
632649 -- for each method, build a top level function
633650 fns <- mapM (tfun cn constraint usyn (map fst imethods)) imethods
634− mapM_ (elabDecl info) (concat fns)
651+ mapM_ (elabDecl EAll info) (concat fns)
635652 -- add the default definitions
636− mapM_ (elabDecl info) (concat (map (snd.snd) defs))
653+ mapM_ (elabDecl EAll info) (concat (map (snd.snd) defs))
637654 i <- get
638655 let defaults = map (\ (x, (y, z)) -> (x,y)) defs
639656 addClass tn (CI cn imethods defaults (map fst ps) [])
@@ -795,7 +812,7 @@ elabInstance info syn fc cs n ps t expn ds
795812 let idecls = [PClauses fc [Inlinable, TCGen] iname
796813 [PClause fc iname lhs [] rhs wb]]
797814 iLOG (show idecls)
798− mapM (elabDecl info) idecls
815+ mapM (elabDecl EAll info) idecls
799816 addIBC (IBCInstance intInst n iname)
800817 where
801818 intInst = case ps of
@@ -915,11 +932,16 @@ pvars ist _ = []
915932data ElabWhat = ETypes | EDefns | EAll
916933 deriving (Show, Eq)
917934
918−elabDecl :: ElabInfo -> PDecl -> Idris ()
919−elabDecl info d = idrisCatch (elabDecl' EAll info d)
920− (\e -> do let msg = show e
921− setErrLine (getErrLine msg)
922− iputStrLn msg)
935+elabDecls :: ElabInfo -> [PDecl] -> Idris ()
936+elabDecls info ds = do mapM_ (elabDecl EAll info) ds
937+-- mapM_ (elabDecl EDefns info) ds
938+
939+elabDecl :: ElabWhat -> ElabInfo -> PDecl -> Idris ()
940+elabDecl what info d
941+ = idrisCatch (elabDecl' what info d)
942+ (\e -> do let msg = show e
943+ setErrLine (getErrLine msg)
944+ iputStrLn msg)
923945
924946elabDecl' _ info (PFix _ _ _)
925947 = return () -- nothing to elaborate
@@ -965,7 +987,7 @@ elabDecl' what info (PClass s f cs n ps ds)
965987 = do iLOG $ "Elaborating class " ++ show n
966988 elabClass info s f cs n ps ds
967989elabDecl' what info (PInstance s f cs n ps t expn ds)
968− | what /= EDefns
990+ | what /= ETypes
969991 = do iLOG $ "Elaborating instance " ++ show n
970992 elabInstance info s f cs n ps t expn ds
971993elabDecl' what info (PRecord s f tyn ty cn cty)