@@ -554,15 +554,20 @@ elabClass info syn fc constraints tn ps ds
554 let constraint = PApp fc (PRef fc tn)
554 let constraint = PApp fc (PRef fc tn)
555 (map (pexp . PRef fc) (map fst ps))
555 (map (pexp . PRef fc) (map fst ps))
556 -- build data declaration
556 -- build data declaration
557− ims <- mapM tdecl (filter tydecl ds)
557+ let mdecls = filter tydecl ds -- method declarations
558+ let mnames = map getMName mdecls
559+ logLvl 2 $ "Building methods " ++ show mnames
560+ ims <- mapM (tdecl mnames) mdecls
558 defs <- mapM (defdecl (map (\ (x,y,z) -> z) ims) constraint)
561 defs <- mapM (defdecl (map (\ (x,y,z) -> z) ims) constraint)
559 (filter clause ds)
562 (filter clause ds)
560 let (methods, imethods) = unzip (map (\ (x,y,z) -> (x, y)) ims)
563 let (methods, imethods) = unzip (map (\ (x,y,z) -> (x, y)) ims)
561 let cty = impbind ps $ conbind constraints $ pibind methods constraint
564 let cty = impbind ps $ conbind constraints $ pibind methods constraint
562 let cons = [(cn, cty, fc)]
565 let cons = [(cn, cty, fc)]
563− let ddecl = PData syn fc (PDatadecl tn tty cons)
566+ let ddecl = PDatadecl tn tty cons
564− elabDecl info ddecl
567+ logLvl 5 $ "Class data " ++ showDImp True ddecl
568+ elabData info (syn { no_imp = no_imp syn ++ mnames }) fc ddecl
565 -- for each constraint, build a top level function to chase it
569 -- for each constraint, build a top level function to chase it
570+ logLvl 5 $ "Building functions"
566 let usyn = syn { using = ps ++ using syn }
571 let usyn = syn { using = ps ++ using syn }
567 fns <- mapM (cfun cn constraint usyn (map fst imethods)) constraints
572 fns <- mapM (cfun cn constraint usyn (map fst imethods)) constraints
568 mapM_ (elabDecl info) (concat fns)
573 mapM_ (elabDecl info) (concat fns)
@@ -583,11 +588,14 @@ elabClass info syn fc constraints tn ps ds
583 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
588 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
584 conbind [] x = x
589 conbind [] x = x
591+ getMName (PTy _ _ _ n _) = nsroot n
586− tdecl (PTy syn _ o n t) = do t' <- implicit syn n t
592+ tdecl allmeths (PTy syn _ o n t)
593+ = do t' <- implicit' syn allmeths n t
594+ logLvl 5 $ "Method " ++ show n ++ " : " ++ showImp True t'
587− return ( (n, (toExp (map fst ps) Exp t')),
595+ return ( (n, (toExp (map fst ps) Exp t')),
588− (n, (o, (toExp (map fst ps) Imp t'))),
596+ (n, (o, (toExp (map fst ps) Imp t'))),
589− (n, (syn, o, t) ) )
597+ (n, (syn, o, t) ) )
590− tdecl _ = fail "Not allowed in a class declaration"
598+ tdecl _ _ = fail "Not allowed in a class declaration"
592 -- Create default definitions
600 -- Create default definitions
593 defdecl mtys c d@(PClauses fc opts n cs) =
601 defdecl mtys c d@(PClauses fc opts n cs) =