aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2009-09-04 22:56:20 +0000
committerDavid Waern <david.waern@gmail.com>2009-09-04 22:56:20 +0000
commitcf2cda2fb9981e45d09e4eb0a8794ca489e09ffb (patch)
treedfc8e2878902f343025277b1e778e11c7ae0b6e5 /src/Haddock
parenta5b7d1c5b0e7f1a6148d34b3cf706acb693c7f6d (diff)
Clean up tyThingToHsSynSig a little
Factor out noLoc and use the case construct. Also rename the function to tyThingToLHsDecl, since it doesn't just create type signatures.
Diffstat (limited to 'src/Haddock')
-rw-r--r--src/Haddock/Convert.hs57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/Haddock/Convert.hs b/src/Haddock/Convert.hs
index f05bd4bd..edc3705e 100644
--- a/src/Haddock/Convert.hs
+++ b/src/Haddock/Convert.hs
@@ -25,38 +25,37 @@ import Bag ( emptyBag )
import SrcLoc ( Located, noLoc )
-- the main function here! yay!
-tyThingToHsSynSig :: TyThing -> LHsDecl Name
--- ids (functions and zero-argument a.k.a. CAFs) get a type signature.
--- Including built-in functions like seq.
--- foreign-imported functions could be represented with ForD
--- instead of SigD if we wanted...
-tyThingToHsSynSig (AnId i) = noLoc $
+tyThingToLHsDecl :: TyThing -> LHsDecl Name
+tyThingToLHsDecl t = noLoc $ case t of
+ -- ids (functions and zero-argument a.k.a. CAFs) get a type signature.
+ -- Including built-in functions like seq.
+ -- foreign-imported functions could be represented with ForD
+ -- instead of SigD if we wanted...
+ --
-- in a future code version we could turn idVarDetails = foreign-call
-- into a ForD instead of a SigD if we wanted. Haddock doesn't
-- need to care.
- SigD (synifyIdSig ImplicitizeForAll i)
--- type-constructors (e.g. Maybe) are complicated, put the definition
--- later in the file (also it's used for class associated-types too.)
-tyThingToHsSynSig (ATyCon tc) = noLoc $
- TyClD (synifyTyCon tc)
--- a data-constructor alone just gets rendered as a function:
-tyThingToHsSynSig (ADataCon dc) = noLoc $
- SigD (TypeSig (synifyName dc)
- (synifyType ImplicitizeForAll (dataConUserType dc)))
--- classes are just a little tedious
-tyThingToHsSynSig (AClass cl) = noLoc $
- TyClD $ ClassDecl
- (synifyCtx (classSCTheta cl))
- (synifyName cl)
- (synifyTyVars (classTyVars cl))
- (map (\ (l,r) -> noLoc
- (map getName l, map getName r) ) $
- snd $ classTvsFds cl)
- (map (\i -> noLoc $ synifyIdSig DeleteTopLevelQuantification i)
- (classMethods cl))
- emptyBag --ignore default method definitions, they don't affect signature
- (map synifyClassAT (classATs cl))
- [] --we don't have any docs at this point
+ AnId i -> SigD (synifyIdSig ImplicitizeForAll i)
+ -- type-constructors (e.g. Maybe) are complicated, put the definition
+ -- later in the file (also it's used for class associated-types too.)
+ ATyCon tc -> TyClD (synifyTyCon tc)
+ -- a data-constructor alone just gets rendered as a function:
+ ADataCon dc -> SigD (TypeSig (synifyName dc)
+ (synifyType ImplicitizeForAll (dataConUserType dc)))
+ -- classes are just a little tedious
+ AClass cl ->
+ TyClD $ ClassDecl
+ (synifyCtx (classSCTheta cl))
+ (synifyName cl)
+ (synifyTyVars (classTyVars cl))
+ (map (\ (l,r) -> noLoc
+ (map getName l, map getName r) ) $
+ snd $ classTvsFds cl)
+ (map (\i -> noLoc $ synifyIdSig DeleteTopLevelQuantification i)
+ (classMethods cl))
+ emptyBag --ignore default method definitions, they don't affect signature
+ (map synifyClassAT (classATs cl))
+ [] --we don't have any docs at this point
-- class associated-types are a subset of TyCon
-- (mainly only type/data-families)