aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockUtil.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/HaddockUtil.hs')
-rw-r--r--src/HaddockUtil.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/HaddockUtil.hs b/src/HaddockUtil.hs
index 58033edc..27595f33 100644
--- a/src/HaddockUtil.hs
+++ b/src/HaddockUtil.hs
@@ -9,7 +9,7 @@ module HaddockUtil (
-- * Misc utilities
nameOfQName, collectNames, declBinders, declMainBinder, splitTyConApp,
- restrictTo, declDoc, parseModuleHeader,
+ restrictTo, declDoc, parseModuleHeader, freeTyCons,
-- * Filename utilities
basename, dirname, splitFilename3,
@@ -76,6 +76,16 @@ splitTyConApp t = split t []
split (HsTyCon t) ts = (t,ts)
split _ _ = error "splitTyConApp"
+freeTyCons :: HsType -> [HsQName]
+freeTyCons ty = go ty []
+ where go (HsForAllType _ _ t) r = go t r
+ go (HsTyApp t u) r = go t (go u r)
+ go (HsTyCon c) r = c : r
+ go (HsTyFun f a) r = go f (go a r)
+ go (HsTyTuple b ts) r = foldr go r ts
+ go (HsTyVar v) r = r
+ go (HsTyDoc t _) r = go t r
+
-- ---------------------------------------------------------------------------
-- Making abstract declarations