aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2010-05-13 19:44:21 +0000
committerDavid Waern <david.waern@gmail.com>2010-05-13 19:44:21 +0000
commit35151a79934a5ca14338ef76bfa9cc2cd0e72d9b (patch)
tree5227985efa76cf1fd676e4ae323a642c6c890309 /src/Haddock
parent4491882688176b7b587f07513ab2a3c492ab5fdb (diff)
Newlines in Convert
Diffstat (limited to 'src/Haddock')
-rw-r--r--src/Haddock/Convert.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Haddock/Convert.hs b/src/Haddock/Convert.hs
index 3e339e82..f8720641 100644
--- a/src/Haddock/Convert.hs
+++ b/src/Haddock/Convert.hs
@@ -16,6 +16,7 @@ module Haddock.Convert where
-- Some other functions turned out to be useful for converting
-- instance heads, which aren't TyThings, so just export everything.
+
import HsSyn
import TcType ( tcSplitSigmaTy )
import TypeRep
@@ -35,6 +36,7 @@ import TysWiredIn ( listTyConName )
import Bag ( emptyBag )
import SrcLoc ( Located, noLoc, unLoc )
+
-- the main function here! yay!
tyThingToLHsDecl :: TyThing -> LHsDecl Name
tyThingToLHsDecl t = noLoc $ case t of
@@ -68,11 +70,13 @@ tyThingToLHsDecl t = noLoc $ case t of
(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)
synifyClassAT :: TyCon -> LTyClDecl Name
synifyClassAT = noLoc . synifyTyCon
+
synifyTyCon :: TyCon -> TyClDecl Name
synifyTyCon tc
| isFunTyCon tc || isPrimTyCon tc =
@@ -148,6 +152,7 @@ synifyTyCon tc
then TySynonym name tyvars typats syn_type
else TyData alg_nd alg_ctx name tyvars typats alg_kindSig alg_cons alg_deriv
+
-- User beware: it is your responsibility to pass True (use_gadt_syntax)
-- for any constructor that would be misrepresented by omitting its
-- result-type.
@@ -202,9 +207,11 @@ synifyDataCon use_gadt_syntax dc = noLoc $
qvars ctx tys res_ty Nothing
False --we don't want any "deprecated GADT syntax" warnings!
+
synifyName :: NamedThing n => n -> Located Name
synifyName = noLoc . getName
+
synifyIdSig :: SynifyTypeState -> Id -> Sig Name
synifyIdSig s i = TypeSig (synifyName i) (synifyType s (varType i))
@@ -212,6 +219,7 @@ synifyIdSig s i = TypeSig (synifyName i) (synifyType s (varType i))
synifyCtx :: [PredType] -> LHsContext Name
synifyCtx = noLoc . map synifyPred
+
synifyPred :: PredType -> LHsPred Name
synifyPred (ClassP cls tys) =
let sTys = map (synifyType WithinType) tys
@@ -229,6 +237,7 @@ synifyPred (EqPred ty1 ty2) =
in noLoc $
HsEqualP s1 s2
+
synifyTyVars :: [TyVar] -> [LHsTyVarBndr Name]
synifyTyVars = map synifyTyVar
where
@@ -243,6 +252,7 @@ synifyTyVars = map synifyTyVar
#endif
else KindedTyVar name kind
+
--states of what to do with foralls:
data SynifyTypeState
= WithinType
@@ -258,6 +268,7 @@ data SynifyTypeState
-- but we want to restore things to the source-syntax situation where
-- the defining class gets to quantify all its functions for free!
+
synifyType :: SynifyTypeState -> Type -> LHsType Name
synifyType _ (PredTy{}) = --should never happen.
error "synifyType: PredTys are not, in themselves, source-level types."
@@ -297,6 +308,7 @@ synifyType s forallty@(ForAllTy _tv _ty) =
in noLoc $
HsForAllTy forallPlicitness sTvs sCtx sTau
+
synifyInstHead :: ([TyVar], [PredType], Class, [Type]) ->
([HsPred Name], Name, [HsType Name])
synifyInstHead (_, preds, cls, ts) =