aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Dupree <id@isaac.cedarswampstudios.org>2009-08-16 19:58:05 +0000
committerIsaac Dupree <id@isaac.cedarswampstudios.org>2009-08-16 19:58:05 +0000
commit76c1ea564e7cf37f73be8a6a740a89bcdcf99be6 (patch)
tree971bd031940e3b8df44c416c21a4ddea7fa16ecd
parentd62ac71e92c8d13b311e4e5d5c72114810534eb8 (diff)
make cross-package list types look nicer
-rw-r--r--src/Haddock/Convert.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Haddock/Convert.hs b/src/Haddock/Convert.hs
index f5a200a9..36c9f51f 100644
--- a/src/Haddock/Convert.hs
+++ b/src/Haddock/Convert.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE PatternGuards #-}
-- This functionality may be moved into GHC at some point, and then
-- we can use the GHC version (#if GHC version is new enough).
@@ -17,6 +18,7 @@ import DataCon
import Id
import BasicTypes
import TysPrim ( alphaTyVars )
+import TysWiredIn ( listTyConName )
import Bag ( emptyBag )
import SrcLoc ( Located, noLoc )
import Maybe
@@ -239,12 +241,11 @@ synifyType _ (PredTy{}) = --should never happen.
synifyType _ (TyVarTy tv) = noLoc $ HsTyVar (getName tv)
synifyType _ (TyConApp tc tys)
-- Use non-prefix tuple syntax where possible, because it looks nicer.
- | isTupleTyCon tc && tyConArity tc == length tys =
- let sTys = map (synifyType WithinType) tys
- in noLoc $
- HsTupleTy (tupleTyConBoxity tc) sTys
- -- We could do the same for list types if we knew how to determine
- -- whether the constructor was the list-constructor....
+ | isTupleTyCon tc, tyConArity tc == length tys =
+ noLoc $ HsTupleTy (tupleTyConBoxity tc) (map (synifyType WithinType) tys)
+ -- ditto for lists
+ | getName tc == listTyConName, [ty] <- tys =
+ noLoc $ HsListTy (synifyType WithinType ty)
-- Most TyCons:
| otherwise =
foldl (\t1 t2 -> noLoc (HsAppTy t1 t2))