From 76c1ea564e7cf37f73be8a6a740a89bcdcf99be6 Mon Sep 17 00:00:00 2001 From: Isaac Dupree Date: Sun, 16 Aug 2009 19:58:05 +0000 Subject: make cross-package list types look nicer --- src/Haddock/Convert.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Haddock/Convert.hs') 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)) -- cgit v1.2.3