@@ -38,8 +38,9 @@ checkDef fc ns = do ctxt <- getContext
3838 mapM (\(n, t) -> do (t', _) <- recheckC fc [] t
3939 return (n, t')) ns
4040
41−elabType :: ElabInfo -> SyntaxInfo -> FC -> FnOpts -> Name -> PTerm -> Idris ()
42−elabType info syn fc opts n ty' = {- let ty' = piBind (params info) ty_in
41+elabType :: ElabInfo -> SyntaxInfo -> String ->
42+ FC -> FnOpts -> Name -> PTerm -> Idris ()
43+elabType info syn doc fc opts n ty' = {- let ty' = piBind (params info) ty_in
4344 n = liftname info n_in in -}
4445 do checkUndefined fc n
4546 ctxt <- getContext
@@ -75,8 +76,8 @@ elabType info syn fc opts n ty' = {- let ty' = piBind (params info) ty_in
7576 when corec $ do setAccessibility n Frozen
7677 addIBC (IBCAccess n Frozen)
7778
78−elabData :: ElabInfo -> SyntaxInfo -> FC -> Bool -> PData -> Idris ()
79−elabData info syn fc codata (PLaterdecl n t_in)
79+elabData :: ElabInfo -> SyntaxInfo -> String -> FC -> Bool -> PData -> Idris ()
80+elabData info syn doc fc codata (PLaterdecl n t_in)
8081 = do iLOG (show fc)
8182 checkUndefined fc n
8283 ctxt <- getContext
@@ -92,7 +93,7 @@ elabData info syn fc codata (PLaterdecl n t_in)
9293 logLvl 2 $ "---> " ++ show cty
9394 updateContext (addTyDecl n cty) -- temporary, to check cons
9495
95−elabData info syn fc codata (PDatadecl n t_in dcons)
96+elabData info syn doc fc codata (PDatadecl n t_in dcons)
9697 = do iLOG (show fc)
9798 undef <- isUndefined fc n
9899 ctxt <- getContext
@@ -119,10 +120,10 @@ elabData info syn fc codata (PDatadecl n t_in dcons)
119120 updateContext (addDatatype (Data n ttag cty cons))
120121 mapM_ (checkPositive n) cons
121122
122−elabRecord :: ElabInfo -> SyntaxInfo -> FC -> Name ->
123− PTerm -> Name -> PTerm -> Idris ()
124−elabRecord info syn fc tyn ty cn cty
125− = do elabData info syn fc False (PDatadecl tyn ty [(cn, cty, fc)])
123+elabRecord :: ElabInfo -> SyntaxInfo -> String -> FC -> Name ->
124+ PTerm -> String -> Name -> PTerm -> Idris ()
125+elabRecord info syn doc fc tyn ty cdoc cn cty
126+ = do elabData info syn doc fc False (PDatadecl tyn ty [(cdoc, cn, cty, fc)])
126127 cty' <- implicit syn cn cty
127128 i <- get
128129 cty <- case lookupTy Nothing cn (tt_ctxt i) of
@@ -145,7 +146,7 @@ elabRecord info syn fc tyn ty cn cty
145146 where
146147-- syn = syn_in { syn_namespace = show (nsroot tyn) : syn_namespace syn_in }
147148
148− isNonImp (PExp _ _ _, a) = Just a
149+ isNonImp (PExp _ _ _ _, a) = Just a
149150 isNonImp _ = Nothing
150151
151152 tryElabDecl info (fn, ty, val)
@@ -157,15 +158,15 @@ elabRecord info syn fc tyn ty cn cty
157158 show fn ++ " (" ++ show ty ++ ")"
158159 put i)
159160
160− getImplB k (PPi (Imp l s) n Placeholder sc)
161+ getImplB k (PPi (Imp l s _) n Placeholder sc)
161162 = getImplB k sc
162− getImplB k (PPi (Imp l s) n ty sc)
163− = getImplB (\x -> k (PPi (Imp l s) n ty x)) sc
163+ getImplB k (PPi (Imp l s d) n ty sc)
164+ = getImplB (\x -> k (PPi (Imp l s d) n ty x)) sc
164165 getImplB k (PPi _ n ty sc)
165166 = getImplB k sc
166167 getImplB k _ = k
167168
168− renameBs (PImp _ _ _ _ : ps) (PPi p n ty s)
169+ renameBs (PImp _ _ _ _ _ : ps) (PPi p n ty s)
169170 = PPi p (mkImp n) ty (renameBs ps (substMatch n (PRef fc (mkImp n)) s))
170171 renameBs (_:ps) (PPi p n ty s) = PPi p n ty (renameBs ps s)
171172 renameBs _ t = t
@@ -192,7 +193,7 @@ elabRecord info syn fc tyn ty cn cty
192193
193194 mkProj recty substs cimp ((pn_in, pty), pos)
194195 = do let pn = expandNS syn pn_in
195− let pfnTy = PTy defaultSyntax fc [] pn
196+ let pfnTy = PTy "" defaultSyntax fc [] pn
196197 (PPi expl rec recty
197198 (substMatches substs pty))
198199 let pls = repeat Placeholder
@@ -213,7 +214,7 @@ elabRecord info syn fc tyn ty cn cty
213214 let valname = MN 0 "updateval"
214215 let pt = k (PPi expl pn pty
215216 (PPi expl rec recty recty))
216− let pfnTy = PTy defaultSyntax fc [] setname pt
217+ let pfnTy = PTy "" defaultSyntax fc [] setname pt
217218 let pls = map (\x -> PRef fc (MN x "field")) [0..num-1]
218219 let lhsArgs = pls
219220 let rhsArgs = take pos pls ++ (PRef fc valname) :
@@ -228,8 +229,9 @@ elabRecord info syn fc tyn ty cn cty
228229 (map pexp rhsArgs)) []
229230 return (pn, pfnTy, PClauses fc [] setname [pclause])
230231
231−elabCon :: ElabInfo -> SyntaxInfo -> Name -> Bool -> (Name, PTerm, FC) -> Idris (Name, Type)
232−elabCon info syn tn codata (n, t_in, fc)
232+elabCon :: ElabInfo -> SyntaxInfo -> Name -> Bool ->
233+ (String, Name, PTerm, FC) -> Idris (Name, Type)
234+elabCon info syn tn codata (doc, n, t_in, fc)
233235 = do checkUndefined fc n
234236 ctxt <- getContext
235237 i <- get
@@ -620,10 +622,10 @@ elabClause info tcgen (PWith fc fname lhs_in withs wval_in withblock)
620622
621623data MArgTy = IA | EA | CA deriving Show
622624
623−elabClass :: ElabInfo -> SyntaxInfo ->
625+elabClass :: ElabInfo -> SyntaxInfo -> String ->
624626 FC -> [PTerm] ->
625627 Name -> [(Name, PTerm)] -> [PDecl] -> Idris ()
626−elabClass info syn fc constraints tn ps ds
628+elabClass info syn doc fc constraints tn ps ds
627629 = do let cn = UN ("instance" ++ show tn) -- MN 0 ("instance" ++ show tn)
628630 let tty = pibind ps PSet
629631 let constraint = PApp fc (PRef fc tn)
@@ -635,12 +637,14 @@ elabClass info syn fc constraints tn ps ds
635637 ims <- mapM (tdecl mnames) mdecls
636638 defs <- mapM (defdecl (map (\ (x,y,z) -> z) ims) constraint)
637639 (filter clause ds)
638− let (methods, imethods) = unzip (map (\ (x,y,z) -> (x, y)) ims)
639− let cty = impbind ps $ conbind constraints $ pibind methods constraint
640− let cons = [(cn, cty, fc)]
640+ let (methods, imethods)
641+ = unzip (map (\ ( x,y,z) -> (x, y)) ims)
642+ let cty = impbind ps $ conbind constraints
643+ $ pibind methods constraint
644+ let cons = [("", cn, cty, fc)]
641645 let ddecl = PDatadecl tn tty cons
642646 logLvl 5 $ "Class data " ++ showDImp True ddecl
643− elabData info (syn { no_imp = no_imp syn ++ mnames }) fc False ddecl
647+ elabData info (syn { no_imp = no_imp syn ++ mnames }) doc fc False ddecl
644648 -- for each constraint, build a top level function to chase it
645649 logLvl 5 $ "Building functions"
646650 let usyn = syn { using = ps ++ using syn }
@@ -653,9 +657,10 @@ elabClass info syn fc constraints tn ps ds
653657 mapM_ (elabDecl EAll info) (concat (map (snd.snd) defs))
654658 i <- get
655659 let defaults = map (\ (x, (y, z)) -> (x,y)) defs
656− addClass tn (CI cn imethods defaults (map fst ps) [])
660+ addClass tn (CI cn (map nodoc imethods) defaults (map fst ps) [])
657661 addIBC (IBCClass tn)
658662 where
663+ nodoc (n, (_, o, t)) = (n, (o, t))
659664 pibind [] x = x
660665 pibind ((n, ty): ns) x = PPi expl n ty (pibind ns x)
661666 impbind [] x = x
@@ -663,12 +668,12 @@ elabClass info syn fc constraints tn ps ds
663668 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
664669 conbind [] x = x
665670
666− getMName (PTy _ _ _ n _) = nsroot n
667− tdecl allmeths (PTy syn _ o n t)
671+ getMName (PTy _ _ _ _ n _) = nsroot n
672+ tdecl allmeths (PTy doc syn _ o n t)
668673 = do t' <- implicit' syn allmeths n t
669674 logLvl 5 $ "Method " ++ show n ++ " : " ++ showImp True t'
670675 return ( (n, (toExp (map fst ps) Exp t')),
671− (n, (o, (toExp (map fst ps) Imp t'))),
676+ (n, (doc, o, (toExp (map fst ps) Imp t'))),
672677 (n, (syn, o, t) ) )
673678 tdecl _ _ = fail "Not allowed in a class declaration"
674679
@@ -677,7 +682,7 @@ elabClass info syn fc constraints tn ps ds
677682 case lookup n mtys of
678683 Just (syn, o, ty) -> do let ty' = insertConstraint c ty
679684 let ds = map (decorateid defaultdec)
680− [PTy syn fc [] n ty',
685+ [PTy "" syn fc [] n ty',
681686 PClauses fc (TCGen:o ++ opts) n cs]
682687 iLOG (show ds)
683688 return (n, ((defaultdec n, ds!!1), ds))
@@ -687,7 +692,7 @@ elabClass info syn fc constraints tn ps ds
687692 defaultdec (UN n) = UN ("default#" ++ n)
688693 defaultdec (NS n ns) = NS (defaultdec n) ns
689694
690− tydecl (PTy _ _ _ _ _) = True
695+ tydecl (PTy _ _ _ _ _ _) = True
691696 tydecl _ = False
692697 clause (PClauses _ _ _ _) = True
693698 clause _ = False
@@ -711,10 +716,10 @@ elabClass info syn fc constraints tn ps ds
711716 addInstance False conn' cfn
712717 addIBC (IBCInstance False conn' cfn)
713718-- iputStrLn ("Added " ++ show (conn, cfn, ty))
714− return [PTy syn fc [] cfn ty,
719+ return [PTy "" syn fc [] cfn ty,
715720 PClauses fc [Inlinable,TCGen] cfn [PClause fc cfn lhs [] rhs []]]
716721
717− tfun cn c syn all (m, (o, ty))
722+ tfun cn c syn all (m, (doc, o, ty))
718723 = do let ty' = insertConstraint c ty
719724 let mnames = take (length all) $ map (\x -> MN x "meth") [0..]
720725 let capp = PApp fc (PRef fc cn) (map (pexp . PRef fc) mnames)
@@ -725,12 +730,12 @@ elabClass info syn fc constraints tn ps ds
725730 iLOG (showImp True ty)
726731 iLOG (show (m, ty', capp, margs))
727732 iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
728− return [PTy syn fc o m ty',
733+ return [PTy doc syn fc o m ty',
729734 PClauses fc [Inlinable,TCGen] m [PClause fc m lhs [] rhs []]]
730735
731− getMArgs (PPi (Imp _ _) n ty sc) = IA : getMArgs sc
732− getMArgs (PPi (Exp _ _) n ty sc) = EA : getMArgs sc
733− getMArgs (PPi (Constraint _ _) n ty sc) = CA : getMArgs sc
736+ getMArgs (PPi (Imp _ _ _) n ty sc) = IA : getMArgs sc
737+ getMArgs (PPi (Exp _ _ _) n ty sc) = EA : getMArgs sc
738+ getMArgs (PPi (Constraint _ _ _) n ty sc) = CA : getMArgs sc
734739 getMArgs _ = []
735740
736741 getMeth (m:ms) (a:as) x | x == a = PRef fc m
@@ -746,14 +751,14 @@ elabClass info syn fc constraints tn ps ds
746751 rhsArgs (CA : xs) ns = pconst (PResolveTC fc) : rhsArgs xs ns
747752 rhsArgs [] _ = []
748753
749− insertConstraint c (PPi p@(Imp _ _) n ty sc)
754+ insertConstraint c (PPi p@(Imp _ _ _) n ty sc)
750755 = PPi p n ty (insertConstraint c sc)
751756 insertConstraint c sc = PPi constraint (MN 0 "c") c sc
752757
753758 -- make arguments explicit and don't bind class parameters
754− toExp ns e (PPi (Imp l s) n ty sc)
759+ toExp ns e (PPi (Imp l s _) n ty sc)
755760 | n `elem` ns = toExp ns e sc
756− | otherwise = PPi (e l s) n ty (toExp ns e sc)
761+ | otherwise = PPi (e l s "") n ty (toExp ns e sc)
757762 toExp ns e (PPi p n ty sc) = PPi p n ty (toExp ns e sc)
758763 toExp ns e sc = sc
759764
@@ -778,7 +783,7 @@ elabInstance info syn fc cs n ps t expn ds
778783 Nothing -> do mapM_ (checkNotOverlapping i t) (class_instances ci)
779784 addInstance intInst n iname
780785 Just _ -> addInstance intInst n iname
781− elabType info syn fc [] iname t
786+ elabType info syn "" fc [] iname t
782787 let ips = zip (class_params ci) ps
783788 let ns = case n of
784789 NS n ns' -> ns'
@@ -836,17 +841,19 @@ elabInstance info syn fc cs n ps t expn ds
836841 getRetType (PPi _ _ _ sc) = getRetType sc
837842 getRetType t = t
838843
839− mkMethApp (n, _, _, ty) = lamBind 0 ty (papp fc (PRef fc n) (methArgs 0 ty))
840− lamBind i (PPi (Constraint _ _) _ _ sc) sc'
841− = PLam (MN i "meth") Placeholder (lamBind (i+1) sc sc')
842− lamBind i (PPi _ n ty sc) sc' = PLam (MN i "meth") Placeholder (lamBind (i+1) sc sc')
844+ mkMethApp (n, _, _, ty)
845+ = lamBind 0 ty (papp fc (PRef fc n) (methArgs 0 ty))
846+ lamBind i (PPi (Constraint _ _ _) _ _ sc) sc'
847+ = PLam (MN i "meth") Placeholder (lamBind (i+1) sc sc')
848+ lamBind i (PPi _ n ty sc) sc'
849+ = PLam (MN i "meth") Placeholder (lamBind (i+1) sc sc')
843850 lamBind i _ sc = sc
844− methArgs i (PPi (Imp _ _) n ty sc)
845− = PImp 0 False n (PRef fc (MN i "meth")) : methArgs (i+1) sc
846− methArgs i (PPi (Exp _ _) n ty sc)
847− = PExp 0 False (PRef fc (MN i "meth")) : methArgs (i+1) sc
848− methArgs i (PPi (Constraint _ _) n ty sc)
849− = PConstraint 0 False (PResolveTC fc) : methArgs (i+1) sc
851+ methArgs i (PPi (Imp _ _ _) n ty sc)
852+ = PImp 0 False n (PRef fc (MN i "meth")) "" : methArgs (i+1) sc
853+ methArgs i (PPi (Exp _ _ _) n ty sc)
854+ = PExp 0 False (PRef fc (MN i "meth")) "" : methArgs (i+1) sc
855+ methArgs i (PPi (Constraint _ _ _) n ty sc)
856+ = PConstraint 0 False (PResolveTC fc) "" : methArgs (i+1) sc
850857 methArgs i _ = []
851858
852859 papp fc f [] = f
@@ -865,12 +872,12 @@ elabInstance info syn fc cs n ps t expn ds
865872 decorate ns iname (UN n) = NS (UN ('!':n)) ns
866873 decorate ns iname (NS (UN n) s) = NS (UN ('!':n)) ns
867874
868− mkTyDecl (n, op, t, _) = PTy syn fc op n t
875+ mkTyDecl (n, op, t, _) = PTy "" syn fc op n t
869876
870877 conbind (ty : ns) x = PPi constraint (MN 0 "c") ty (conbind ns x)
871878 conbind [] x = x
872879
873− coninsert cs (PPi p@(Imp _ _) n t sc) = PPi p n t (coninsert cs sc)
880+ coninsert cs (PPi p@(Imp _ _ _) n t sc) = PPi p n t (coninsert cs sc)
874881 coninsert cs sc = conbind cs sc
875882
876883 insertDefaults :: IState -> Name ->
@@ -903,7 +910,7 @@ elabInstance info syn fc cs n ps t expn ds
903910 = decorate ns iname m == decorate ns iname m'
904911 clauseFor m iname ns _ = False
905912
906−decorateid decorate (PTy s f o n t) = PTy s f o (decorate n) t
913+decorateid decorate (PTy doc s f o n t) = PTy doc s f o (decorate n) t
907914decorateid decorate (PClauses f o n cs)
908915 = PClauses f o (decorate n) (map dc cs)
909916 where dc (PClause fc n t as w ds) = PClause fc (decorate n) (dappname t) as w ds
@@ -947,17 +954,17 @@ elabDecl' _ info (PFix _ _ _)
947954 = return () -- nothing to elaborate
948955elabDecl' _ info (PSyntax _ p)
949956 = return () -- nothing to elaborate
950−elabDecl' what info (PTy s f o n ty)
957+elabDecl' what info (PTy doc s f o n ty)
951958 | what /= EDefns
952959 = do iLOG $ "Elaborating type decl " ++ show n ++ show o
953− elabType info s f o n ty
954−elabDecl' what info (PData s f co d)
960+ elabType info s doc f o n ty
961+elabDecl' what info (PData doc s f co d)
955962 | what /= ETypes
956963 = do iLOG $ "Elaborating " ++ show (d_name d)
957− elabData info s f co d
964+ elabData info s doc f co d
958965 | otherwise
959966 = do iLOG $ "Elaborating [type of] " ++ show (d_name d)
960− elabData info s f co (PLaterdecl (d_name d) (d_tcon d))
967+ elabData info s doc f co (PLaterdecl (d_name d) (d_tcon d))
961968elabDecl' what info d@(PClauses f o n ps)
962969 | what /= ETypes
963970 = do iLOG $ "Elaborating clause " ++ show n
@@ -988,18 +995,18 @@ elabDecl' what info (PNamespace n ps) = mapM_ (elabDecl' what ninfo) ps
988995 ninfo = case namespace info of
989996 Nothing -> info { namespace = Just [n] }
990997 Just ns -> info { namespace = Just (n:ns) }
991−elabDecl' what info (PClass s f cs n ps ds)
998+elabDecl' what info (PClass doc s f cs n ps ds)
992999 | what /= EDefns
9931000 = do iLOG $ "Elaborating class " ++ show n
994− elabClass info s f cs n ps ds
1001+ elabClass info s doc f cs n ps ds
9951002elabDecl' what info (PInstance s f cs n ps t expn ds)
9961003 | what /= ETypes
9971004 = do iLOG $ "Elaborating instance " ++ show n
9981005 elabInstance info s f cs n ps t expn ds
999−elabDecl' what info (PRecord s f tyn ty cn cty)
1006+elabDecl' what info (PRecord doc s f tyn ty cdoc cn cty)
10001007 | what /= EDefns
10011008 = do iLOG $ "Elaborating record " ++ show tyn
1002− elabRecord info s f tyn ty cn cty
1009+ elabRecord info s doc f tyn ty cdoc cn cty
10031010elabDecl' _ info (PDSL n dsl)
10041011 = do i <- get
10051012 put (i { idris_dsls = addDef n dsl (idris_dsls i) })