on master help sign in
Merge branch 'master' of github.com:idris-lang/Idris-dev
e23ebdaEdwin Brady
libs/prelude/Prelude/List.idr−1
@@ -532,7 +532,6 @@ break : (a -> Bool) -> List a -> (List a, List a)
532break p = span (not . p)
532break p = span (not . p)
533
533
534split : (a -> Bool) -> List a -> List (List a)
534split : (a -> Bool) -> List a -> List (List a)
535−split p [] = []
536split p xs =
535split p xs =
537 case break p xs of
536 case break p xs of
538 (chunk, []) => [chunk]
537 (chunk, []) => [chunk]
src/Idris/Docs.hs+19−13
@@ -29,6 +29,7 @@ data Docs = FunDoc FunDoc
29 [FunDoc] -- method docs
29 [FunDoc] -- method docs
30 [(Name, Maybe Docstring)] -- parameters and their docstrings
30 [(Name, Maybe Docstring)] -- parameters and their docstrings
31 [PTerm] -- instances
31 [PTerm] -- instances
32+ [PTerm] -- superclasses
32 deriving Show
33 deriving Show
33
34
34showDoc d | nullDocstring d = empty
35showDoc d | nullDocstring d = empty
@@ -77,7 +78,7 @@ pprintDocs ist (DataDoc t args)
77 if null args then text "No constructors."
78 if null args then text "No constructors."
78 else nest 4 (text "Constructors:" <> line <>
79 else nest 4 (text "Constructors:" <> line <>
79 vsep (map (pprintFD ist) args))
80 vsep (map (pprintFD ist) args))
80−pprintDocs ist (ClassDoc n doc meths params instances)
81+pprintDocs ist (ClassDoc n doc meths params instances superclasses)
81 = nest 4 (text "Type class" <+> prettyName (ppopt_impl ppo) [] n <>
82 = nest 4 (text "Type class" <+> prettyName (ppopt_impl ppo) [] n <>
82 if nullDocstring doc then empty else line <> renderDocstring doc)
83 if nullDocstring doc then empty else line <> renderDocstring doc)
83 <> line <$>
84 <> line <$>
@@ -90,9 +91,13 @@ pprintDocs ist (ClassDoc n doc meths params instances)
90 vsep (if null instances' then [text "<no instances>"]
91 vsep (if null instances' then [text "<no instances>"]
91 else map dumpInstance instances'))
92 else map dumpInstance instances'))
92 <>
93 <>
93− if null subclasses then empty
94+ (if null subclasses then empty
94− else line <$> nest 4 (text "Subclasses:" <$>
95+ else line <$> nest 4 (text "Subclasses:" <$>
95− vsep (map (dumpInstance . prettifySubclasses) subclasses))
96+ vsep (map (dumpInstance . prettifySubclasses) subclasses)))
97+ <>
98+ (if null superclasses then empty
99+ else line <$> nest 4 (text "Default superclass instances:" <$>
100+ vsep (map dumpInstance superclasses)))
96 where
101 where
97 params' = zip pNames (repeat False)
102 params' = zip pNames (repeat False)
98
103
@@ -119,11 +124,11 @@ pprintDocs ist (ClassDoc n doc meths params instances)
119 updateRef nm (PRef fc _) = PRef fc nm
124 updateRef nm (PRef fc _) = PRef fc nm
120 updateRef _ pt = pt
125 updateRef _ pt = pt
121
126
122− hasConstraint (PPi (Constraint _ _) _ _ _) = True
127+ isSubclass (PPi (Constraint _ _) _ (PApp _ _ args) (PApp _ (PRef _ nm) args')) = nm == n && map getTm args == map getTm args'
123− hasConstraint (PPi _ _ _ pt) = hasConstraint pt
128+ isSubclass (PPi _ _ _ pt) = isSubclass pt
124− hasConstraint _ = False
129+ isSubclass _ = False
125
130
126− (subclasses, instances') = partition hasConstraint instances
131+ (subclasses, instances') = partition isSubclass instances
127
132
128 prettyParameters = if any (isJust . snd) params
133 prettyParameters = if any (isJust . snd) params
129 then vsep (map (\(nm,md) -> prettyName False params' nm <+> maybe empty showDoc md) params)
134 then vsep (map (\(nm,md) -> prettyName False params' nm <+> maybe empty showDoc md) params)
@@ -152,8 +157,12 @@ docClass n ci
152 docstr = maybe emptyDocstring fst docStrings
157 docstr = maybe emptyDocstring fst docStrings
153 params = map (\pn -> (pn, docStrings >>= (lookup pn . snd))) (class_params ci)
158 params = map (\pn -> (pn, docStrings >>= (lookup pn . snd))) (class_params ci)
154 instances = map (delabTy i) (class_instances ci)
159 instances = map (delabTy i) (class_instances ci)
160+ superclasses = catMaybes $ map getDInst (class_default_superclasses ci)
155− mdocs <- mapM (docFun .fst) (class_methods ci)
161+ mdocs <- mapM (docFun . fst) (class_methods ci)
156− return $ ClassDoc n docstr mdocs params instances
162+ return $ ClassDoc n docstr mdocs params instances superclasses
163+ where
164+ getDInst (PInstance _ _ _ _ _ t _ _) = Just t
165+ getDInst _ = Nothing
157
166
158docFun :: Name -> Idris FunDoc
167docFun :: Name -> Idris FunDoc
159docFun n
168docFun n
@@ -192,6 +201,3 @@ pprintConstDocs ist c str = text "Primitive" <+> text (if constIsType c then "ty
192 t (Str _) = PConstant StrType
201 t (Str _) = PConstant StrType
193 t (Ch c) = PConstant $ AType (ATInt ITChar)
202 t (Ch c) = PConstant $ AType (ATInt ITChar)
194 t _ = PType
203 t _ = PType
195−
196−
197−
src/Idris/IdrisDoc.hs+9−9
@@ -157,9 +157,9 @@ removeOrphans list =
157 let children = S.fromList $ concatMap (names . (\(_, d, _) -> d)) list
157 let children = S.fromList $ concatMap (names . (\(_, d, _) -> d)) list
158 in filter ((`S.notMember` children) . (\(n, _, _) -> n)) list
158 in filter ((`S.notMember` children) . (\(n, _, _) -> n)) list
159
159
160− where names (Just (DataDoc _ fds)) = map (\(FD n _ _ _ _) -> n) fds
160+ where names (Just (DataDoc _ fds)) = map (\(FD n _ _ _ _) -> n) fds
161− names (Just (ClassDoc _ _ fds _ _)) = map (\(FD n _ _ _ _) -> n) fds
161+ names (Just (ClassDoc _ _ fds _ _ _)) = map (\(FD n _ _ _ _) -> n) fds
162− names _ = []
162+ names _ = []
163
163
164-- | Whether a Name names something which should be documented
164-- | Whether a Name names something which should be documented
165filterName :: Name -- ^ Name to check
165filterName :: Name -- ^ Name to check
@@ -207,11 +207,11 @@ referredNss (n, Just d, _) =
207 names = concatMap (extractPTermNames) ts
207 names = concatMap (extractPTermNames) ts
208 in S.map getNs $ S.fromList names
208 in S.map getNs $ S.fromList names
209
209
210− where getFunDocs (FunDoc f) = [f]
210+ where getFunDocs (FunDoc f) = [f]
211− getFunDocs (DataDoc f fs) = f:fs
211+ getFunDocs (DataDoc f fs) = f:fs
212− getFunDocs (ClassDoc _ _ fs _ _) = fs
212+ getFunDocs (ClassDoc _ _ fs _ _ _) = fs
213− types (FD _ _ args t _) = t:(map second args)
213+ types (FD _ _ args t _) = t:(map second args)
214− second (_, x, _, _) = x
214+ second (_, x, _, _) = x
215
215
216
216
217-- | Returns an NsDict of containing all known namespaces and their contents
217-- | Returns an NsDict of containing all known namespaces and their contents
@@ -555,7 +555,7 @@ createOtherDoc :: IState -- ^ Needed to determine the types of names
555 -> H.Html -- ^ Resulting HTML
555 -> H.Html -- ^ Resulting HTML
556createOtherDoc ist (FunDoc fd) = createFunDoc ist fd
556createOtherDoc ist (FunDoc fd) = createFunDoc ist fd
557
557
558−createOtherDoc ist (ClassDoc n docstring fds _ _) = do
558+createOtherDoc ist (ClassDoc n docstring fds _ _ _) = do
559 H.dt ! (A.id $ toValue $ show n) $ do
559 H.dt ! (A.id $ toValue $ show n) $ do
560 H.span ! class_ "word" $ do "class"; nbsp
560 H.span ! class_ "word" $ do "class"; nbsp
561 H.span ! class_ "name type"
561 H.span ! class_ "name type"