From a2bcbcffde1e78a6031132bdf4a1a605978352a8 Mon Sep 17 00:00:00 2001 From: Henning Thielemann Date: Sun, 1 Apr 2012 13:03:07 +0200 Subject: add QualOption type for distinction between qualification argument given by the user and the actual qualification for a concrete module --- src/Haddock/Types.hs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/Haddock/Types.hs') diff --git a/src/Haddock/Types.hs b/src/Haddock/Types.hs index 22d2f6ae..de0cc3d9 100644 --- a/src/Haddock/Types.hs +++ b/src/Haddock/Types.hs @@ -374,12 +374,34 @@ data DocOption -- | Option controlling how to qualify names +data QualOption + = OptNoQual -- ^ Never qualify any names. + | OptFullQual -- ^ Qualify all names fully. + | OptLocalQual -- ^ Qualify all imported names fully. + | OptRelativeQual -- ^ Like local, but strip module prefix + -- from modules in the same hierarchy. + data Qualification - = NoQual -- ^ Never qualify any names. - | FullQual -- ^ Qualify all names fully. - | LocalQual (Maybe Module) -- ^ Qualify all imported names fully. - | RelativeQual (Maybe Module) -- ^ Like local, but strip module prefix. - -- from modules in the same hierarchy. + = NoQual + | FullQual + | LocalQual Module + | RelativeQual Module + -- ^ @Maybe Module@ contains the current module. + -- This way we can distinguish imported and local identifiers. + +makeContentsQual :: QualOption -> Qualification +makeContentsQual qual = + case qual of + OptNoQual -> NoQual + _ -> FullQual + +makeModuleQual :: QualOption -> Module -> Qualification +makeModuleQual qual mdl = + case qual of + OptLocalQual -> LocalQual mdl + OptRelativeQual -> RelativeQual mdl + OptFullQual -> FullQual + OptNoQual -> NoQual ----------------------------------------------------------------------------- -- cgit v1.2.3