haddock 2.27.0 → 2.28.0
raw patch · 25 files changed
+750/−386 lines, 25 filesdep ~basedep ~ghcdep ~haddock-api
Dependency ranges changed: base, ghc, haddock-api
Files
- doc/common-errors.rst +1/−1
- doc/markup.rst +3/−10
- haddock-api/src/Haddock.hs +1/−1
- haddock-api/src/Haddock/Backends/Hoogle.hs +8/−14
- haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs +2/−2
- haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs +3/−3
- haddock-api/src/Haddock/Backends/LaTeX.hs +18/−17
- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +29/−24
- haddock-api/src/Haddock/Convert.hs +81/−72
- haddock-api/src/Haddock/GhcUtils.hs +20/−19
- haddock-api/src/Haddock/Interface/AttachInstances.hs +2/−2
- haddock-api/src/Haddock/Interface/Create.hs +13/−13
- haddock-api/src/Haddock/Interface/Rename.hs +35/−23
- haddock-api/src/Haddock/InterfaceFile.hs +2/−2
- haddock-api/src/Haddock/Types.hs +16/−3
- haddock.cabal +5/−5
- html-test/ref/Bug1004.html +20/−28
- html-test/ref/Bug923.html +7/−7
- html-test/ref/FunArgs.html +1/−1
- html-test/ref/Instances.html +10/−6
- hypsrc-test/ref/src/Records.html +26/−84
- hypsrc-test/ref/src/TemplateHaskellQuasiquotes.html +325/−47
- hypsrc-test/ref/src/TemplateHaskellSplices.html +112/−2
- hypsrc-test/src/TemplateHaskellQuasiquotes.hs +6/−0
- hypsrc-test/src/TemplateHaskellSplices.hs +4/−0
doc/common-errors.rst view
@@ -7,7 +7,7 @@ This is probably caused by the ``-- | xxx`` comment not following a declaration. I.e. use ``-- xxx`` instead. See :ref:`top-level-declaration`. ``parse error on input ‘-- $ xxx’``-----------------------------------+----------------------------------- You've probably commented out code like::
doc/markup.rst view
@@ -591,14 +591,7 @@ import C (a, b) then Haddock behaves as if the set of entities re-exported from ``B``-and ``C`` had been listed explicitly in the export list [#notImplemented]_.--.. Comment: was this ever implemented? Perhaps this part of the docs- should just be removed until it is implemented?--.. [#notImplemented] This is not implemented at the time of writing- (Haddock version 2.17.3 with GHC 8.0.2). At the moment, Haddock- always inserts a module cross-reference.+and ``C`` had been listed explicitly in the export list. The exception to this rule is when the re-exported module is declared with the ``hide`` attribute (see :ref:`module-attrs`), in which@@ -950,8 +943,8 @@ -- | A prefix operator @'(++)'@ and an infix identifier @'`elem`'@. -Emphasis, Bold and Monospaced styled Text-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+Emphasis, Bold and Monospaced Styled Text+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Text can be emphasized, made bold (strong) or monospaced (typewriter font) by surrounding it with slashes, double-underscores or at-symbols: ::
haddock-api/src/Haddock.hs view
@@ -582,7 +582,7 @@ let extra_opts | needHieFiles = [Opt_WriteHie, Opt_Haddock] | otherwise = [Opt_Haddock] dynflags' = (foldl' gopt_set dynflags extra_opts)- { backend = NoBackend+ { backend = noBackend , ghcMode = CompManager , ghcLink = NoLink }
haddock-api/src/Haddock/Backends/Hoogle.hs view
@@ -18,8 +18,7 @@ ppHoogle ) where -import GHC.Types.Basic ( OverlapFlag(..), OverlapMode(..),- PromotionFlag(..), TopLevelFlag(..) )+import GHC.Types.Basic ( OverlapFlag(..), OverlapMode(..), TopLevelFlag(..) ) import GHC.Types.SourceText import GHC.Core.InstEnv (ClsInst(..)) import Documentation.Haddock.Markup@@ -32,9 +31,11 @@ import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic import GHC.Unit.State+import GHC.Hs.Decls (ppDataDefnHeader, pp_vanilla_decl_head) import Data.Char-import Data.List (intercalate, isPrefixOf)+import Data.Foldable (toList)+import Data.List (dropWhileEnd, intercalate, isPrefixOf) import Data.Maybe import Data.Version @@ -219,17 +220,10 @@ ppSynonym dflags x = [out dflags x] ppData :: DynFlags -> TyClDecl GhcRn -> [(Name, DocForDecl Name)] -> [String]-ppData dflags decl@(DataDecl { tcdDataDefn = defn }) subdocs- = showData decl{ tcdDataDefn = defn { dd_cons=[],dd_derivs=[] }} :+ppData dflags decl@DataDecl { tcdLName = name, tcdTyVars = tvs, tcdFixity = fixity, tcdDataDefn = defn } subdocs+ = out dflags (ppDataDefnHeader (pp_vanilla_decl_head name tvs fixity) defn) : concatMap (ppCtor dflags decl subdocs . unLoc) (dd_cons defn) where-- -- GHC gives out "data Bar =", we want to delete the equals.- -- There's no need to worry about parenthesizing infix data type names,- -- since this Outputable instance for TyClDecl gets this right already.- showData d = unwords $ if last xs == "=" then init xs else xs- where- xs = words $ out dflags d ppData _ _ _ = panic "ppData" -- | for constructors, and named-fields...@@ -258,7 +252,7 @@ -- We print the constructors as comma-separated list. See GHC -- docs for con_names on why it is a list to begin with.- name = commaSeparate dflags . map unL $ getConNames con+ name = commaSeparate dflags . toList $ unL <$> getConNames con tyVarArg (UserTyVar _ _ n) = HsTyVar noAnn NotPromoted n tyVarArg (KindedTyVar _ _ n lty) = HsKindSig noAnn (reL (HsTyVar noAnn NotPromoted n)) lty@@ -276,7 +270,7 @@ = concatMap (lookupCon dflags subdocs) names ++ [typeSig] where typeSig = operator name ++ " :: " ++ outHsSigType dflags con_sig_ty- name = out dflags $ map unL names+ name = out dflags $ unL <$> names con_sig_ty = HsSig noExtField outer_bndrs theta_ty where theta_ty = case mcxt of Just theta -> noLocA (HsQualTy { hst_xqual = noExtField, hst_ctxt = theta, hst_body = tau_ty })
haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs view
@@ -14,7 +14,7 @@ import GHC.Types.SourceText import GHC.Driver.Session import GHC.Driver.Config.Diagnostic-import GHC.Utils.Error ( pprLocMsgEnvelope )+import GHC.Utils.Error ( pprLocMsgEnvelopeDefault ) import GHC.Data.FastString ( mkFastString ) import GHC.Parser.Errors.Ppr () import qualified GHC.Types.Error as E@@ -45,7 +45,7 @@ PFailed pst -> let err:_ = bagToList (E.getMessages $ getPsErrorMessages pst) in panic $ showSDoc dflags $- text "Hyperlinker parse error:" $$ pprLocMsgEnvelope err+ text "Hyperlinker parse error:" $$ pprLocMsgEnvelopeDefault err where initState = initParserState pflags buf start
haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs view
@@ -22,7 +22,7 @@ import GHC.Iface.Type import GHC.Types.Name ( getOccFS, getOccString ) import GHC.Driver.Ppr ( showSDoc )-import GHC.Types.Var ( VarBndr(..) )+import GHC.Types.Var ( VarBndr(..), visArg, invisArg, TypeOrConstraint(..) ) import System.FilePath.Posix ((</>), (<.>)) @@ -129,8 +129,8 @@ go (HLitTy l) = IfaceLitTy l go (HForAllTy ((n,k),af) t) = let b = (getOccFS n, k) in IfaceForAllTy (Bndr (IfaceTvBndr b) af) t- go (HFunTy w a b) = IfaceFunTy VisArg w a b- go (HQualTy con b) = IfaceFunTy InvisArg many_ty con b+ go (HFunTy w a b) = IfaceFunTy (visArg TypeLike) w a b -- t1 -> t2+ go (HQualTy con b) = IfaceFunTy (invisArg TypeLike) many_ty con b -- c => t go (HCastTy a) = a go HCoercionTy = IfaceTyVar "<coercion type>" go (HTyConApp a xs) = IfaceTyConApp a (hieToIfaceArgs xs)
haddock-api/src/Haddock/Backends/LaTeX.hs view
@@ -24,14 +24,12 @@ import GHC.Utils.Ppr hiding (Doc, quote) import qualified GHC.Utils.Ppr as Pretty -import GHC.Types.Basic ( PromotionFlag(..), isPromoted ) import GHC hiding (fromMaybeContext ) import GHC.Types.Name.Occurrence import GHC.Types.Name ( nameOccName ) import GHC.Types.Name.Reader ( rdrNameOcc ) import GHC.Core.Type ( Specificity(..) ) import GHC.Data.FastString ( unpackFS )-import GHC.Utils.Panic ( panic) import qualified Data.Map as Map import System.Directory@@ -40,7 +38,8 @@ import Control.Monad import Data.Maybe import Data.List ( sort )-import Data.Void ( absurd )+import Data.List.NonEmpty ( NonEmpty (..) )+import Data.Foldable ( toList ) import Prelude hiding ((<>)) import Haddock.Doc (combineDocumentation)@@ -696,8 +695,8 @@ ClassInst ctx _ _ _ -> keyword "instance" <+> ppContextNoLocs ctx unicode <+> typ TypeInst rhs -> keyword "type" <+> keyword "instance" <+> typ <+> tibody rhs DataInst dd ->- let nd = dd_ND (tcdDataDefn dd)- pref = case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" }+ let cons = dd_cons (tcdDataDefn dd)+ pref = case cons of { NewTypeCon _ -> keyword "newtype"; DataTypeCons _ _ -> keyword "data" } in pref <+> keyword "instance" <+> typ where typ = ppAppNameTypes ihdClsName ihdTypes unicode@@ -729,7 +728,6 @@ where cons = dd_cons (tcdDataDefn dataDecl)- resTy = (unLoc . head) cons body = catMaybes [doc >>= documentationToLaTeX, constrBit,patternBit] @@ -737,8 +735,8 @@ | null cons , null pats = (empty,[]) | null cons = (text "where", repeat empty)- | otherwise = case resTy of- ConDeclGADT{} -> (text "where", repeat empty)+ | otherwise = case toList cons of+ L _ ConDeclGADT{} : _ -> (text "where", repeat empty) _ -> (empty, (decltt (text "=") : repeat (decltt (text "|")))) constrBit@@ -746,7 +744,7 @@ | otherwise = Just $ text "\\enspace" <+> emph (text "Constructors") <> text "\\par" $$ text "\\haddockbeginconstrs" $$- vcat (zipWith (ppSideBySideConstr subdocs unicode) leaders cons) $$+ vcat (zipWith (ppSideBySideConstr subdocs unicode) leaders (toList cons)) $$ text "\\end{tabulary}\\par" patternBit@@ -792,9 +790,9 @@ where -- Find the name of a constructors in the decl (`getConName` always returns -- a non-empty list)- aConName = unLoc (head (getConNamesI con))+ L _ aConName :| _ = getConNamesI con - occ = map (nameOccName . getName . unLoc) $ getConNamesI con+ occ = toList $ nameOccName . getName . unLoc <$> getConNamesI con ppOcc = cat (punctuate comma (map ppBinder occ)) ppOccInfix = cat (punctuate comma (map ppBinderInfix occ))@@ -879,8 +877,7 @@ -- don't use "con_doc con", in case it's reconstructed from a .hi file, -- or also because we want Haddock to do the doc-parsing, not GHC. mbDoc = case getConNamesI con of- [] -> panic "empty con_names"- (cn:_) -> lookup (unLoc cn) subdocs >>=+ cn:|_ -> lookup (unLoc cn) subdocs >>= fmap _doc . combineDocumentation . fst @@ -929,9 +926,13 @@ -- Currently doesn't handle 'data instance' decls or kind signatures ppDataHeader :: TyClDecl DocNameI -> Bool -> LaTeX ppDataHeader (DataDecl { tcdLName = L _ name, tcdTyVars = tyvars- , tcdDataDefn = HsDataDefn { dd_ND = nd, dd_ctxt = ctxt } }) unicode+ , tcdDataDefn = HsDataDefn { dd_cons = cons, dd_ctxt = ctxt } }) unicode = -- newtype or data- (case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" }) <+>+ (case cons of+ { NewTypeCon _ -> keyword "newtype"+ ; DataTypeCons False _ -> keyword "data"+ ; DataTypeCons True _ -> keyword "type" <+> keyword "data"+ }) <+> -- context ppLContext ctxt unicode <+> -- T a b c ..., or a :+: b@@ -1120,7 +1121,7 @@ ppr_mono_ty (HsKindSig _ ty kind) u = parens (ppr_mono_lty ty u <+> dcolon u <+> ppLKind u kind) ppr_mono_ty (HsListTy _ ty) u = brackets (ppr_mono_lty ty u) ppr_mono_ty (HsIParamTy _ (L _ n) ty) u = ppIPName n <+> dcolon u <+> ppr_mono_lty ty u-ppr_mono_ty (HsSpliceTy v _) _ = absurd v+ppr_mono_ty (HsSpliceTy v _) _ = dataConCantHappen v ppr_mono_ty (HsRecTy {}) _ = text "{..}" ppr_mono_ty (XHsType {}) _ = error "ppr_mono_ty HsCoreTy" ppr_mono_ty (HsExplicitListTy _ IsPromoted tys) u = Pretty.quote $ brackets $ hsep $ punctuate comma $ map (ppLType u) tys@@ -1156,7 +1157,7 @@ ppr_mono_ty (HsStarTy _ isUni) unicode = starSymbol (isUni || unicode) -ppr_tylit :: HsTyLit -> Bool -> LaTeX+ppr_tylit :: HsTyLit DocNameI -> Bool -> LaTeX ppr_tylit (HsNumTy _ n) _ = integer n ppr_tylit (HsStrTy _ s) _ = text (show s) ppr_tylit (HsCharTy _ c) _ = text (show c)
haddock-api/src/Haddock/Backends/Xhtml/Decl.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE LambdaCase #-} ----------------------------------------------------------------------------- -- |@@ -29,16 +30,16 @@ import Haddock.Types import Haddock.Doc (combineDocumentation) +import Data.Foldable ( toList ) import Data.List ( intersperse, sort )+import Data.List.NonEmpty ( NonEmpty (..) ) import qualified Data.Map as Map import Data.Maybe-import Data.Void ( absurd ) import Text.XHtml hiding ( name, title, p, quote ) import GHC.Core.Type ( Specificity(..) )-import GHC.Types.Basic (PromotionFlag(..), isPromoted) import GHC hiding (LexicalFixity(..), fromMaybeContext)-import GHC.Exts+import GHC.Exts hiding (toList) import GHC.Types.Name import GHC.Data.BooleanFormula import GHC.Types.Name.Reader ( rdrNameOcc )@@ -610,7 +611,7 @@ ] -- Minimal complete definition- minimalBit = case [ s | MinimalSig _ _ (L _ s) <- sigs ] of+ minimalBit = case [ s | MinimalSig _ (L _ s) <- sigs ] of -- Miminal complete definition = every shown method And xs : _ | sort [getName n | L _ (Var (L _ n)) <- xs] == sort [getName n | ClassOpSig _ _ ns _ <- sigs, L _ n <- ns]@@ -701,8 +702,8 @@ , mdoc , [subFamInstDetails iid pdecl mname]) where- nd = dd_ND (tcdDataDefn dd)- pref = case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" }+ cons = dd_cons (tcdDataDefn dd)+ pref = case cons of { NewTypeCon _ -> keyword "newtype"; DataTypeCons _ _ -> keyword "data" } pdata = pref <+> typ pdecl = pdata <+> ppShortDataDecl False True dd [] unicode qual where@@ -759,18 +760,18 @@ -> Unicode -> Qualification -> Html ppShortDataDecl summary dataInst dataDecl pats unicode qual - | [] <- cons+ | [] <- toList cons , [] <- pats = dataHeader - | [lcon] <- cons, [] <- pats, isH98,+ | [lcon] <- toList cons, [] <- pats, isH98, (cHead,cBody,cFoot) <- ppShortConstrParts summary dataInst (unLoc lcon) unicode qual = (dataHeader <+> equals <+> cHead) +++ cBody +++ cFoot | [] <- pats, isH98 = dataHeader- +++ shortSubDecls dataInst (zipWith doConstr ('=':repeat '|') cons ++ pats1)+ +++ shortSubDecls dataInst (zipWith doConstr ('=':repeat '|') (toList cons) ++ pats1) | otherwise = (dataHeader <+> keyword "where")- +++ shortSubDecls dataInst (map doGADTConstr cons ++ pats1)+ +++ shortSubDecls dataInst (map doGADTConstr (toList cons) ++ pats1) where dataHeader@@ -780,7 +781,7 @@ doGADTConstr con = ppShortConstr summary (unLoc con) unicode qual cons = dd_cons (tcdDataDefn dataDecl)- isH98 = case unLoc (head cons) of+ isH98 = flip any (unLoc <$> cons) $ \ case ConDeclH98 {} -> True ConDeclGADT{} -> False @@ -813,7 +814,7 @@ docname = tcdNameI dataDecl curname = Just $ getName docname cons = dd_cons (tcdDataDefn dataDecl)- isH98 = case unLoc (head cons) of+ isH98 = flip any (unLoc <$> cons) $ \ case ConDeclH98 {} -> True ConDeclGADT{} -> False @@ -825,14 +826,14 @@ whereBit | null cons , null pats = noHtml- | null cons = keyword "where"- | otherwise = if isH98 then noHtml else keyword "where"+ | isH98 = noHtml+ | otherwise = keyword "where" constrBit = subConstructors pkg qual [ ppSideBySideConstr subdocs subfixs unicode pkg qual c- | c <- cons+ | c <- toList cons , let subfixs = filter (\(n,_) -> any (\cn -> cn == n)- (map unL (getConNamesI (unLoc c)))) fixities+ (unL <$> getConNamesI (unLoc c))) fixities ] patternBit = subPatterns pkg qual@@ -899,7 +900,7 @@ ) where- occ = map (nameOccName . getName . unL) $ getConNamesI con+ occ = toList $ nameOccName . getName . unL <$> getConNamesI con ppOcc = hsep (punctuate comma (map (ppBinder summary) occ)) ppOccInfix = hsep (punctuate comma (map (ppBinderInfix summary) occ)) @@ -916,10 +917,10 @@ ) where -- Find the name of a constructors in the decl (`getConName` always returns a non-empty list)- aConName = unL (head (getConNamesI con))+ L _ aConName :| _ = getConNamesI con fixity = ppFixities fixities qual- occ = map (nameOccName . getName . unL) $ getConNamesI con+ occ = toList $ nameOccName . getName . unL <$> getConNamesI con ppOcc = hsep (punctuate comma (map (ppBinder False) occ)) ppOccInfix = hsep (punctuate comma (map (ppBinderInfix False) occ))@@ -998,7 +999,7 @@ -- don't use "con_doc con", in case it's reconstructed from a .hi file, -- or also because we want Haddock to do the doc-parsing, not GHC.- mbDoc = lookup (unL $ head $ getConNamesI con) subdocs >>=+ mbDoc = lookup aConName subdocs >>= combineDocumentation . fst @@ -1083,14 +1084,18 @@ -- Currently doesn't handle 'data instance' decls or kind signatures ppDataHeader :: Bool -> TyClDecl DocNameI -> Unicode -> Qualification -> Html ppDataHeader summary (DataDecl { tcdDataDefn =- HsDataDefn { dd_ND = nd+ HsDataDefn { dd_cons = cons , dd_ctxt = ctxt , dd_kindSig = ks } , tcdLName = L _ name , tcdTyVars = tvs }) unicode qual = -- newtype or data- (case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" })+ (case cons of+ { NewTypeCon _ -> keyword "newtype"+ ; DataTypeCons False _ -> keyword "data"+ ; DataTypeCons True _ -> keyword "type" <+> keyword "data"+ }) <+> -- context ppLContext ctxt unicode qual HideEmptyContexts <+>@@ -1263,7 +1268,7 @@ ppr_mono_ty (HsListTy _ ty) u q _ = brackets (ppr_mono_lty ty u q HideEmptyContexts) ppr_mono_ty (HsIParamTy _ (L _ n) ty) u q _ = ppIPName n <+> dcolon u <+> ppr_mono_lty ty u q HideEmptyContexts-ppr_mono_ty (HsSpliceTy v _) _ _ _ = absurd v+ppr_mono_ty (HsSpliceTy v _) _ _ _ = dataConCantHappen v ppr_mono_ty (HsRecTy {}) _ _ _ = toHtml "{..}" -- Can now legally occur in ConDeclGADT, the output here is to provide a -- placeholder in the signature, which is followed by the field@@ -1301,7 +1306,7 @@ ppr_mono_ty (HsWildCardTy _) _ _ _ = char '_' ppr_mono_ty (HsTyLit _ n) _ _ _ = ppr_tylit n -ppr_tylit :: HsTyLit -> Html+ppr_tylit :: HsTyLit DocNameI -> Html ppr_tylit (HsNumTy _ n) = toHtml (show n) ppr_tylit (HsStrTy _ s) = toHtml (show s) ppr_tylit (HsCharTy _ c) = toHtml (show c)
haddock-api/src/Haddock/Convert.hs view
@@ -20,25 +20,25 @@ ) where import GHC.Data.Bag ( emptyBag )-import GHC.Types.Basic ( TupleSort(..), PromotionFlag(..), DefMethSpec(..), TopLevelFlag(..) )+import GHC.Types.Basic ( TupleSort(..), DefMethSpec(..), TopLevelFlag(..) ) import GHC.Types.SourceText (SourceText(..)) import GHC.Types.Fixity (LexicalFixity(..)) import GHC.Core.Class import GHC.Core.Coercion.Axiom import GHC.Core.ConLike-import Data.Either (lefts, rights) import GHC.Core.DataCon import GHC.Core.FamInstEnv+import GHC.Core.PatSyn+import GHC.Core.TyCon+import GHC.Core.Type+import GHC.Core.TyCo.Rep+import GHC.Core.TyCo.Compare( eqTypes )+ import GHC.Hs import GHC.Types.TyThing import GHC.Types.Name import GHC.Types.Name.Set ( emptyNameSet ) import GHC.Types.Name.Reader ( mkVarUnqual )-import GHC.Core.PatSyn-import GHC.Tc.Utils.TcType-import GHC.Core.TyCon-import GHC.Core.Type-import GHC.Core.TyCo.Rep import GHC.Builtin.Types.Prim ( alphaTyVars ) import GHC.Builtin.Types ( eqTyConName, listTyConName, liftedTypeKindTyConName , unitTy, promotedNilDataCon, promotedConsDataCon )@@ -52,11 +52,15 @@ import GHC.Types.Var.Set import GHC.Types.SrcLoc +import Language.Haskell.Syntax.Basic (FieldLabelString(..))+ import Haddock.Types import Haddock.Interface.Specialize import Haddock.GhcUtils ( orderedFVs, defaultRuntimeRepVars, mkEmptySigType ) +import Data.Either (lefts, rights) import Data.Maybe ( catMaybes, mapMaybe, maybeToList )+import Data.Either ( partitionEithers ) -- | Whether or not to default 'RuntimeRep' variables to 'LiftedRep'. Check@@ -97,7 +101,7 @@ -- | Convert a LHsTyVarBndr to an equivalent LHsType. hsLTyVarBndrToType :: LHsTyVarBndr flag GhcRn -> LHsType GhcRn- hsLTyVarBndrToType = mapLoc cvt+ hsLTyVarBndrToType = fmap cvt extractFamDefDecl :: FamilyDecl GhcRn -> Type -> TyFamDefltDecl GhcRn extractFamDefDecl fd rhs =@@ -125,13 +129,14 @@ in withErrs (lefts atTyClDecls) . TyClD noExtField $ ClassDecl { tcdCtxt = Just $ synifyCtx (classSCTheta cl)+ , tcdLayout = NoLayoutInfo , tcdLName = synifyNameN cl , tcdTyVars = synifyTyVars vs , tcdFixity = synifyFixity cl , tcdFDs = map (\ (l,r) -> noLocA (FunDep noAnn (map (noLocA . getName) l) (map (noLocA . getName) r)) ) $ snd $ classTvsFds cl- , tcdSigs = noLocA (MinimalSig noAnn NoSourceText . noLocA . fmap noLocA $ classMinimalDef cl) :+ , tcdSigs = noLocA (MinimalSig (noAnn, NoSourceText) . noLocA . fmap noLocA $ classMinimalDef cl) : [ noLocA tcdSig | clsOp <- classOpItems cl , tcdSig <- synifyTcIdSig vs clsOp ]@@ -198,7 +203,7 @@ -> TyCon -- ^ type constructor to convert -> Either ErrMsg (TyClDecl GhcRn) synifyTyCon prr _coax tc- | isFunTyCon tc || isPrimTyCon tc+ | isPrimTyCon tc = return $ DataDecl { tcdLName = synifyNameN tc , tcdTyVars = HsQTvs { hsq_ext = [] -- No kind polymorphism@@ -210,13 +215,12 @@ , tcdFixity = synifyFixity tc , tcdDataDefn = HsDataDefn { dd_ext = noExtField- , dd_ND = DataType -- arbitrary lie, they are neither+ , dd_cons = DataTypeCons False [] -- No constructors; arbitrary lie, they are neither -- algebraic data nor newtype: , dd_ctxt = Nothing , dd_cType = Nothing , dd_kindSig = synifyDataTyConReturnKind tc -- we have their kind accurately:- , dd_cons = [] -- No constructors , dd_derivs = [] } , tcdDExt = DataDeclRn False emptyNameSet } where@@ -246,7 +250,7 @@ DataFamilyTyCon {} -> mkFamDecl DataFamily where- resultVar = famTcResVar tc+ resultVar = tyConFamilyResVar_maybe tc mkFamDecl i = return $ FamDecl noExtField $ FamilyDecl { fdExt = noAnn , fdInfo = i@@ -268,52 +272,52 @@ , tcdTyVars = synifyTyVars (tyConVisibleTyVars tc) , tcdFixity = synifyFixity tc , tcdRhs = synifyType WithinType [] ty }- | otherwise =+ | otherwise = do -- (closed) newtype and data- let- alg_nd = if isNewTyCon tc then NewType else DataType- alg_ctx = synifyCtx (tyConStupidTheta tc)- name = case coax of- Just a -> synifyNameN a -- Data families are named according to their+ let alg_ctx = synifyCtx (tyConStupidTheta tc)+ name = case coax of+ Just a -> synifyNameN a -- Data families are named according to their -- CoAxioms, not their TyCons- _ -> synifyNameN tc- tyvars = synifyTyVars (tyConVisibleTyVars tc)- kindSig = synifyDataTyConReturnKind tc- -- The data constructors.- --- -- Any data-constructors not exported from the module that *defines* the- -- type will not (cannot) be included.- --- -- Very simple constructors, Haskell98 with no existentials or anything,- -- probably look nicer in non-GADT syntax. In source code, all constructors- -- must be declared with the same (GADT vs. not) syntax, and it probably- -- is less confusing to follow that principle for the documentation as well.- --- -- There is no sensible infix-representation for GADT-syntax constructor- -- declarations. They cannot be made in source code, but we could end up- -- with some here in the case where some constructors use existentials.- -- That seems like an acceptable compromise (they'll just be documented- -- in prefix position), since, otherwise, the logic (at best) gets much more- -- complicated. (would use dataConIsInfix.)- use_gadt_syntax = isGadtSyntaxTyCon tc- consRaw = map (synifyDataCon use_gadt_syntax) (tyConDataCons tc)- cons = rights consRaw- -- "deriving" doesn't affect the signature, no need to specify any.- alg_deriv = []- defn = HsDataDefn { dd_ext = noExtField- , dd_ND = alg_nd+ _ -> synifyNameN tc+ tyvars = synifyTyVars (tyConVisibleTyVars tc)+ kindSig = synifyDataTyConReturnKind tc+ -- The data constructors.+ --+ -- Any data-constructors not exported from the module that *defines* the+ -- type will not (cannot) be included.+ --+ -- Very simple constructors, Haskell98 with no existentials or anything,+ -- probably look nicer in non-GADT syntax. In source code, all constructors+ -- must be declared with the same (GADT vs. not) syntax, and it probably+ -- is less confusing to follow that principle for the documentation as well.+ --+ -- There is no sensible infix-representation for GADT-syntax constructor+ -- declarations. They cannot be made in source code, but we could end up+ -- with some here in the case where some constructors use existentials.+ -- That seems like an acceptable compromise (they'll just be documented+ -- in prefix position), since, otherwise, the logic (at best) gets much more+ -- complicated. (would use dataConIsInfix.)+ use_gadt_syntax = isGadtSyntaxTyCon tc+ consRaw <- case partitionEithers $ synifyDataCon use_gadt_syntax <$> tyConDataCons tc of+ ([], consRaw) -> Right consRaw+ (errs, _) -> Left (unlines errs)+ cons <- case (isNewTyCon tc, consRaw) of+ (False, cons) -> Right (DataTypeCons False cons)+ (True, [con]) -> Right (NewTypeCon con)+ (True, _) -> Left "Newtype hasn't 1 constructor"++ let -- "deriving" doesn't affect the signature, no need to specify any.+ alg_deriv = []+ defn = HsDataDefn { dd_ext = noExtField , dd_ctxt = Just alg_ctx , dd_cType = Nothing , dd_kindSig = kindSig , dd_cons = cons , dd_derivs = alg_deriv }- in case lefts consRaw of- [] -> return $- DataDecl { tcdLName = name, tcdTyVars = tyvars+ pure DataDecl { tcdLName = name, tcdTyVars = tyvars , tcdFixity = synifyFixity name , tcdDataDefn = defn , tcdDExt = DataDeclRn False emptyNameSet }- dataConErrs -> Left $ unlines dataConErrs -- | In this module, every TyCon being considered has come from an interface -- file. This means that when considering a data type constructor such as:@@ -387,7 +391,7 @@ field_tys = zipWith con_decl_field (dataConFieldLabels dc) linear_tys con_decl_field fl synTy = noLocA $- ConDeclField noAnn [noLocA $ FieldOcc (flSelector fl) (noLocA $ mkVarUnqual $ flLabel fl)] synTy+ ConDeclField noAnn [noLocA $ FieldOcc (flSelector fl) (noLocA $ mkVarUnqual $ field_label $ flLabel fl)] synTy Nothing mk_h98_arg_tys :: Either ErrMsg (HsConDeclH98Details GhcRn)@@ -410,7 +414,8 @@ let hat = mk_gadt_arg_tys return $ noLocA $ ConDeclGADT { con_g_ext = noAnn- , con_names = [name]+ , con_names = pure name+ , con_dcolon = noHsUniTok , con_bndrs = noLocA outer_bndrs , con_mb_cxt = ctx , con_g_args = hat@@ -422,7 +427,7 @@ { con_ext = noAnn , con_name = name , con_forall = False- , con_ex_tvs = map (synifyTyVarBndr . (mkTyCoVarBinder InferredSpec)) ex_tvs+ , con_ex_tvs = map (synifyTyVarBndr . (mkForAllTyBinder InferredSpec)) ex_tvs , con_mb_cxt = ctx , con_args = hat , con_doc = Nothing }@@ -511,7 +516,7 @@ tyConArgsPolyKinded :: TyCon -> [Bool] tyConArgsPolyKinded tc = map (is_poly_ty . tyVarKind) tc_vis_tvs- ++ map (is_poly_ty . tyCoBinderType) tc_res_kind_vis_bndrs+ ++ map (is_poly_ty . piTyBinderType) tc_res_kind_vis_bndrs ++ repeat True where is_poly_ty :: Type -> Bool@@ -523,8 +528,8 @@ tc_vis_tvs :: [TyVar] tc_vis_tvs = tyConVisibleTyVars tc - tc_res_kind_vis_bndrs :: [TyCoBinder]- tc_res_kind_vis_bndrs = filter isVisibleBinder $ fst $ splitPiTys $ tyConResKind tc+ tc_res_kind_vis_bndrs :: [PiTyBinder]+ tc_res_kind_vis_bndrs = filter isVisiblePiTyBinder $ fst $ splitPiTys $ tyConResKind tc --states of what to do with foralls: data SynifyTypeState@@ -657,15 +662,18 @@ ty_head' = synifyType WithinType vs ty_head ty_args' = map (synifyType WithinType vs) $ filterOut isCoercionTy $- filterByList (map isVisibleArgFlag $ appTyArgFlags ty_head ty_args)+ filterByList (map isVisibleForAllTyFlag $ appTyForAllTyFlags ty_head ty_args) ty_args in foldl (\t1 t2 -> noLocA $ HsAppTy noExtField t1 t2) ty_head' ty_args'-synifyType s vs funty@(FunTy InvisArg _ _ _) = synifySigmaType s vs funty-synifyType _ vs (FunTy VisArg w t1 t2) = let- s1 = synifyType WithinType vs t1- s2 = synifyType WithinType vs t2- w' = synifyMult vs w- in noLocA $ HsFunTy noAnn w' s1 s2++synifyType s vs funty@(FunTy af w t1 t2)+ | isInvisibleFunArg af = synifySigmaType s vs funty+ | otherwise = noLocA $ HsFunTy noAnn w' s1 s2+ where+ s1 = synifyType WithinType vs t1+ s2 = synifyType WithinType vs t2+ w' = synifyMult vs w+ synifyType s vs forallty@(ForAllTy (Bndr _ argf) _ty) = case argf of Required -> synifyVisForAllType vs forallty@@ -799,8 +807,8 @@ synifyMult :: [TyVar] -> Mult -> HsArrow GhcRn synifyMult vs t = case t of- One -> HsLinearArrow (HsPct1 noHsTok noHsUniTok)- Many -> HsUnrestrictedArrow noHsUniTok+ OneTy -> HsLinearArrow (HsPct1 noHsTok noHsUniTok)+ ManyTy -> HsUnrestrictedArrow noHsUniTok ty -> HsExplicitMult noHsTok (synifyType WithinType vs ty) noHsUniTok @@ -820,9 +828,9 @@ in implicitForAll ts [] (univ_tvs ++ ex_tvs) req_theta' (\vs -> implicitForAll ts vs [] prov_theta (synifyType WithinType))- (mkVisFunTys arg_tys res_ty)+ (mkScaledFunTys arg_tys res_ty) -synifyTyLit :: TyLit -> HsTyLit+synifyTyLit :: TyLit -> HsTyLit GhcRn synifyTyLit (NumTyLit n) = HsNumTy NoSourceText n synifyTyLit (StrTyLit s) = HsStrTy NoSourceText s synifyTyLit (CharTyLit c) = HsCharTy NoSourceText c@@ -921,7 +929,7 @@ -- | See Note [Invariant: Never expand type synonyms] tcSplitSomeForAllTysPreserveSynonyms ::- (ArgFlag -> Bool) -> Type -> ([TyCoVarBinder], Type)+ (ForAllTyFlag -> Bool) -> Type -> ([ForAllTyBinder], Type) tcSplitSomeForAllTysPreserveSynonyms argf_pred ty = split ty ty [] where split _ (ForAllTy tvb@(Bndr _ argf) ty') tvs@@ -931,12 +939,12 @@ -- | See Note [Invariant: Never expand type synonyms] tcSplitForAllTysReqPreserveSynonyms :: Type -> ([ReqTVBinder], Type) tcSplitForAllTysReqPreserveSynonyms ty =- let (all_bndrs, body) = tcSplitSomeForAllTysPreserveSynonyms isVisibleArgFlag ty+ let (all_bndrs, body) = tcSplitSomeForAllTysPreserveSynonyms isVisibleForAllTyFlag ty req_bndrs = mapMaybe mk_req_bndr_maybe all_bndrs in assert ( req_bndrs `equalLength` all_bndrs) (req_bndrs, body) where- mk_req_bndr_maybe :: TyCoVarBinder -> Maybe ReqTVBinder+ mk_req_bndr_maybe :: ForAllTyBinder -> Maybe ReqTVBinder mk_req_bndr_maybe (Bndr tv argf) = case argf of Required -> Just $ Bndr tv () Invisible _ -> Nothing@@ -944,12 +952,12 @@ -- | See Note [Invariant: Never expand type synonyms] tcSplitForAllTysInvisPreserveSynonyms :: Type -> ([InvisTVBinder], Type) tcSplitForAllTysInvisPreserveSynonyms ty =- let (all_bndrs, body) = tcSplitSomeForAllTysPreserveSynonyms isInvisibleArgFlag ty+ let (all_bndrs, body) = tcSplitSomeForAllTysPreserveSynonyms isInvisibleForAllTyFlag ty inv_bndrs = mapMaybe mk_inv_bndr_maybe all_bndrs in assert ( inv_bndrs `equalLength` all_bndrs) (inv_bndrs, body) where- mk_inv_bndr_maybe :: TyCoVarBinder -> Maybe InvisTVBinder+ mk_inv_bndr_maybe :: ForAllTyBinder -> Maybe InvisTVBinder mk_inv_bndr_maybe (Bndr tv argf) = case argf of Invisible s -> Just $ Bndr tv s Required -> Nothing@@ -967,5 +975,6 @@ -- | See Note [Invariant: Never expand type synonyms] tcSplitPredFunTyPreserveSynonyms_maybe :: Type -> Maybe (PredType, Type)-tcSplitPredFunTyPreserveSynonyms_maybe (FunTy InvisArg _ arg res) = Just (arg, res)+tcSplitPredFunTyPreserveSynonyms_maybe (FunTy af _ arg res)+ | isInvisibleFunArg af = Just (arg, res) tcSplitPredFunTyPreserveSynonyms_maybe _ = Nothing
haddock-api/src/Haddock/GhcUtils.hs view
@@ -5,6 +5,8 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE MonadComprehensions #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} {-# OPTIONS_HADDOCK hide #-}@@ -25,6 +27,8 @@ import Control.Arrow import Data.Char ( isSpace )+import Data.Foldable ( toList )+import Data.List.NonEmpty ( NonEmpty ) import Data.Maybe ( mapMaybe, fromMaybe ) import Haddock.Types( DocName, DocNameI, XRecCond )@@ -37,10 +41,9 @@ import GHC.Unit.Module import GHC import GHC.Driver.Session-import GHC.Types.Basic import GHC.Types.SrcLoc ( advanceSrcLoc ) import GHC.Types.Var ( Specificity, VarBndr(..), TyVarBinder- , tyVarKind, updateTyVarKind, isInvisibleArgFlag )+ , tyVarKind, updateTyVarKind, isInvisibleForAllTyFlag ) import GHC.Types.Var.Set ( VarSet, emptyVarSet ) import GHC.Types.Var.Env ( TyVarEnv, extendVarEnv, elemVarEnv, emptyVarEnv ) import GHC.Core.TyCo.Rep ( Type(..) )@@ -76,7 +79,7 @@ case filter (p . unLoc) ns of [] -> Nothing filtered -> Just (FixSig noAnn (FixitySig noExtField filtered ty))-filterSigNames _ orig@(MinimalSig _ _ _) = Just orig+filterSigNames _ orig@(MinimalSig _ _) = Just orig filterSigNames p (TypeSig _ ns ty) = case filter (p . unLoc) ns of [] -> Nothing@@ -127,8 +130,8 @@ hsLTyVarNameI :: LHsTyVarBndr flag DocNameI -> DocName hsLTyVarNameI = hsTyVarNameI . unLoc -getConNamesI :: ConDecl DocNameI -> [LocatedN DocName]-getConNamesI ConDeclH98 {con_name = name} = [name]+getConNamesI :: ConDecl DocNameI -> NonEmpty (LocatedN DocName)+getConNamesI ConDeclH98 {con_name = name} = pure name getConNamesI ConDeclGADT {con_names = names} = names hsSigTypeI :: LHsSigType DocNameI -> LHsType DocNameI@@ -255,21 +258,19 @@ _ -> decl restrictDataDefn :: [Name] -> HsDataDefn GhcRn -> HsDataDefn GhcRn-restrictDataDefn names defn@(HsDataDefn { dd_ND = new_or_data, dd_cons = cons })- | DataType <- new_or_data- = defn { dd_cons = restrictCons names cons }- | otherwise -- Newtype- = case restrictCons names cons of- [] -> defn { dd_ND = DataType, dd_cons = [] }- [con] -> defn { dd_cons = [con] }- _ -> error "Should not happen"+restrictDataDefn names d = d { dd_cons = restrictDataDefnCons names (dd_cons d) } -restrictCons :: [Name] -> [LConDecl GhcRn] -> [LConDecl GhcRn]-restrictCons names decls = [ L p d | L p (Just d) <- map (fmap keep) decls ]+restrictDataDefnCons :: [Name] -> DataDefnCons (LConDecl GhcRn) -> DataDefnCons (LConDecl GhcRn)+restrictDataDefnCons names = \ case+ DataTypeCons is_type_data cons -> DataTypeCons is_type_data (restrictCons names cons)+ NewTypeCon con -> maybe (DataTypeCons False []) NewTypeCon $ restrictCons names (Just con)++restrictCons :: MonadFail m => [Name] -> m (LConDecl GhcRn) -> m (LConDecl GhcRn)+restrictCons names decls = [ L p d | L p (Just d) <- fmap keep <$> decls ] where keep :: ConDecl GhcRn -> Maybe (ConDecl GhcRn) keep d- | any (\n -> n `elem` names) (map unLoc $ getConNames d) =+ | any (`elem` names) (unLoc <$> getConNames d) = case d of ConDeclH98 { con_args = con_args' } -> case con_args' of PrefixCon {} -> Just d@@ -471,7 +472,7 @@ instance Parent (TyClDecl GhcRn) where children d- | isDataDecl d = map unLoc $ concatMap (getConNames . unLoc)+ | isDataDecl d = map unLoc $ concatMap (toList . getConNames . unLoc) $ (dd_cons . tcdDataDefn) d | isClassDecl d = map (unLoc . fdLName . unLoc) (tcdATs d) ++@@ -485,7 +486,7 @@ familyConDecl :: ConDecl GHC.GhcRn -> [(Name, [Name])]-familyConDecl d = zip (map unLoc (getConNames d)) (repeat $ children d)+familyConDecl d = zip (toList $ unLoc <$> getConNames d) (repeat $ children d) -- | A mapping from the parent (main-binder) to its children and from each -- child to its grand-children, recursively.@@ -724,7 +725,7 @@ go :: TyVarEnv () -> Type -> Type go subs (ForAllTy (Bndr var flg) ty) | isRuntimeRepVar var- , isInvisibleArgFlag flg+ , isInvisibleForAllTyFlag flg = let subs' = extendVarEnv subs var () in go subs' ty | otherwise
haddock-api/src/Haddock/Interface/AttachInstances.hs view
@@ -40,7 +40,7 @@ import GHC.Types.SrcLoc import GHC.Core.TyCon import GHC.Core.TyCo.Rep-import GHC.Builtin.Types.Prim( funTyConName )+import GHC.Builtin.Types( unrestrictedFunTyConName ) import GHC.Types.Var hiding (varName) import GHC.HsToCore.Docs @@ -209,7 +209,7 @@ argCount _ = 0 simplify :: Type -> SimpleType-simplify (FunTy _ _ t1 t2) = SimpleType (SName funTyConName) [simplify t1, simplify t2]+simplify (FunTy _ _ t1 t2) = SimpleType (SName unrestrictedFunTyConName) [simplify t1, simplify t2] simplify (ForAllTy _ t) = simplify t simplify (AppTy t1 t2) = SimpleType s (ts ++ maybeToList (simplify_maybe t2)) where (SimpleType s ts) = simplify t1
haddock-api/src/Haddock/Interface/Create.hs view
@@ -43,6 +43,7 @@ import Control.Monad.Reader (MonadReader (..), ReaderT, asks, runReaderT) import Control.Monad.Writer.Strict hiding (tell) import Data.Bitraversable (bitraverse)+import Data.Foldable (toList) import Data.List (find, foldl') import qualified Data.IntMap as IM import Data.IntMap (IntMap)@@ -63,7 +64,6 @@ import GHC.Tc.Utils.Monad (finalSafeMode) import GHC.Types.Avail hiding (avail) import qualified GHC.Types.Avail as Avail-import GHC.Types.Basic (PromotionFlag (..)) import GHC.Types.Name (getOccString, getSrcSpan, isDataConName, isValName, nameIsLocalOrFrom, nameOccName, emptyOccEnv) import GHC.Types.Name.Env (lookupNameEnv) import GHC.Types.Name.Reader (GlobalRdrEnv, greMangledName, lookupGlobalRdrEnv)@@ -380,12 +380,12 @@ ] isInteresting idecl =- case ideclHiding idecl of+ case ideclImportList idecl of -- i) no subset selected Nothing -> True -- ii) an import with a hiding clause -- without any names- Just (True, L _ []) -> True+ Just (EverythingBut, L _ []) -> True -- iii) any other case of qualification _ -> False @@ -442,7 +442,7 @@ opts <- case mbOpts of Just opts -> case words $ replace ',' ' ' opts of [] -> tell ["No option supplied to DOC_OPTION/doc_option"] >> return []- xs -> liftM catMaybes (mapM parseOption xs)+ xs -> fmap catMaybes (mapM parseOption xs) Nothing -> return [] pure (foldl go opts flags) where@@ -651,7 +651,7 @@ fullModuleContents is_sig modMap pkgName thisMod semMod warnings gre exportedNames decls maps fixMap splices instIfaceMap dflags allExports- Just exports -> liftM concat $ mapM lookupExport exports+ Just exports -> fmap concat $ mapM lookupExport exports where lookupExport (IEGroup _ lev docStr, _) = liftErrMsg $ do doc <- processDocString dflags gre (hsDocString . unLoc $ docStr)@@ -754,7 +754,7 @@ L loc (TyClD _ ClassDecl {..}) -> do mdef <- minimalDef t- let sig = maybeToList $ fmap (noLocA . MinimalSig noAnn NoSourceText . noLocA . fmap noLocA) mdef+ let sig = maybeToList $ fmap (noLocA . MinimalSig (noAnn, NoSourceText) . noLocA . fmap noLocA) mdef availExportDecl avail (L loc $ TyClD noExtField ClassDecl { tcdSigs = sig ++ tcdSigs, .. }) docs_ @@ -1100,8 +1100,8 @@ , tcdDataDefn = HsDataDefn { dd_cons = dataCons } } -> do let ty_args = lHsQTyVarsToTypes (tyClDeclTyVars d) lsig <- if isDataConName name- then extractPatternSyn name dataNm ty_args dataCons- else extractRecSel name dataNm ty_args dataCons+ then extractPatternSyn name dataNm ty_args (toList dataCons)+ else extractRecSel name dataNm ty_args (toList dataCons) pure (SigD noExtField <$> lsig) TyClD _ FamDecl {}@@ -1113,12 +1113,12 @@ , feqn_pats = tys , feqn_rhs = defn }))) -> if isDataConName name- then fmap (SigD noExtField) <$> extractPatternSyn name n tys (dd_cons defn)- else fmap (SigD noExtField) <$> extractRecSel name n tys (dd_cons defn)+ then fmap (SigD noExtField) <$> extractPatternSyn name n tys (toList $ dd_cons defn)+ else fmap (SigD noExtField) <$> extractRecSel name n tys (toList $ dd_cons defn) InstD _ (ClsInstD _ ClsInstDecl { cid_datafam_insts = insts }) | isDataConName name -> let matches = [ d' | L _ d'@(DataFamInstDecl (FamEqn { feqn_rhs = dd })) <- insts- , name `elem` map unLoc (concatMap (getConNames . unLoc) (dd_cons dd))+ , name `elem` map unLoc (concatMap (toList . getConNames . unLoc) (dd_cons dd)) ] in case matches of [d0] -> extractDecl declMap name (noLocA (InstD noExtField (DataFamInstD noExtField d0)))@@ -1126,8 +1126,8 @@ | otherwise -> let matches = [ d' | L _ d'@(DataFamInstDecl d ) <- insts- -- , L _ ConDecl { con_details = RecCon rec } <- dd_cons (feqn_rhs d)- , Just rec <- map (getRecConArgs_maybe . unLoc) (dd_cons (feqn_rhs d))+ -- , L _ ConDecl { con_details = RecCon rec } <- toList $ dd_cons (feqn_rhs d)+ , Just rec <- toList $ getRecConArgs_maybe . unLoc <$> dd_cons (feqn_rhs d) , ConDeclField { cd_fld_names = ns } <- map unLoc (unLoc rec) , L _ n <- ns , foExt n == name
haddock-api/src/Haddock/Interface/Rename.hs view
@@ -308,33 +308,29 @@ doc' <- renameLDocHsSyn doc return (HsDocTy noAnn ty' doc') - HsTyLit _ x -> return (HsTyLit noAnn x)+ HsTyLit _ x -> return (HsTyLit noAnn (renameTyLit x)) HsRecTy _ a -> HsRecTy noAnn <$> mapM renameConDeclFieldField a XHsType a -> pure (XHsType a) HsExplicitListTy _ a b -> HsExplicitListTy noAnn a <$> mapM renameLType b HsExplicitTupleTy _ b -> HsExplicitTupleTy noAnn <$> mapM renameLType b- HsSpliceTy _ s -> renameHsSpliceTy s+ HsSpliceTy (HsUntypedSpliceTop _ st) _ -> renameType (unLoc st)+ HsSpliceTy (HsUntypedSpliceNested _) _ -> error "renameType: not an top level type splice" HsWildCardTy _ -> pure (HsWildCardTy noAnn) +renameTyLit :: HsTyLit GhcRn -> HsTyLit DocNameI+renameTyLit t = case t of+ HsNumTy _ v -> HsNumTy noExtField v+ HsStrTy _ v -> HsStrTy noExtField v+ HsCharTy _ v -> HsCharTy noExtField v + renameSigType :: HsSigType GhcRn -> RnM (HsSigType DocNameI) renameSigType (HsSig { sig_bndrs = bndrs, sig_body = body }) = do bndrs' <- renameOuterTyVarBndrs bndrs body' <- renameLType body pure $ HsSig { sig_ext = noExtField, sig_bndrs = bndrs', sig_body = body' } --- | Rename splices, but _only_ those that turn out to be for types.--- I think this is actually safe for our possible inputs:------ * the input is from after GHC's renamer, so should have an 'HsSpliced'--- * the input is typechecked, and only 'HsSplicedTy' should get through that----renameHsSpliceTy :: HsSplice GhcRn -> RnM (HsType DocNameI)-renameHsSpliceTy (HsSpliced _ _ (HsSplicedTy t)) = renameType t-renameHsSpliceTy (HsSpliced _ _ _) = error "renameHsSpliceTy: not an HsSplicedTy"-renameHsSpliceTy _ = error "renameHsSpliceTy: not an HsSpliced"- renameLHsQTyVars :: LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI) renameLHsQTyVars (HsQTvs { hsq_explicit = tvs }) = do { tvs' <- mapM renameLTyVarBndr tvs@@ -432,7 +428,8 @@ return (DataDecl { tcdDExt = noExtField, tcdLName = lname', tcdTyVars = tyvars' , tcdFixity = fixity, tcdDataDefn = defn' }) - ClassDecl { tcdCtxt = lcontext, tcdLName = lname, tcdTyVars = ltyvars, tcdFixity = fixity+ ClassDecl { tcdLayout = layout+ , tcdCtxt = lcontext, tcdLName = lname, tcdTyVars = ltyvars, tcdFixity = fixity , tcdFDs = lfundeps, tcdSigs = lsigs, tcdATs = ats, tcdATDefs = at_defs } -> do lcontext' <- traverse renameLContext lcontext lname' <- renameL lname@@ -442,10 +439,12 @@ ats' <- mapM (renameLThing renameFamilyDecl) ats at_defs' <- mapM (mapM renameTyFamDefltD) at_defs -- we don't need the default methods or the already collected doc entities- return (ClassDecl { tcdCtxt = lcontext', tcdLName = lname', tcdTyVars = ltyvars'+ return (ClassDecl { tcdCExt = noExtField+ , tcdLayout = renameLayoutInfo layout+ , tcdCtxt = lcontext', tcdLName = lname', tcdTyVars = ltyvars' , tcdFixity = fixity , tcdFDs = lfundeps', tcdSigs = lsigs', tcdMeths= emptyBag- , tcdATs = ats', tcdATDefs = at_defs', tcdDocs = [], tcdCExt = noExtField })+ , tcdATs = ats', tcdATDefs = at_defs', tcdDocs = [] }) where renameLFunDep :: LHsFunDep GhcRn -> RnM (LHsFunDep DocNameI)@@ -456,6 +455,11 @@ renameLSig (L loc sig) = return . L (locA loc) =<< renameSig sig +renameLayoutInfo :: LayoutInfo GhcRn -> LayoutInfo DocNameI+renameLayoutInfo (ExplicitBraces ob cb) = ExplicitBraces ob cb+renameLayoutInfo (VirtualBraces n) = VirtualBraces n+renameLayoutInfo NoLayoutInfo = NoLayoutInfo+ renameFamilyDecl :: FamilyDecl GhcRn -> RnM (FamilyDecl DocNameI) renameFamilyDecl (FamilyDecl { fdInfo = info, fdLName = lname , fdTyVars = ltyvars@@ -492,14 +496,14 @@ ; return $ ClosedTypeFamily eqns' } renameDataDefn :: HsDataDefn GhcRn -> RnM (HsDataDefn DocNameI)-renameDataDefn (HsDataDefn { dd_ND = nd, dd_ctxt = lcontext, dd_cType = cType+renameDataDefn (HsDataDefn { dd_ctxt = lcontext, dd_cType = cType , dd_kindSig = k, dd_cons = cons }) = do lcontext' <- traverse renameLContext lcontext k' <- renameMaybeLKind k cons' <- mapM (mapMA renameCon) cons -- I don't think we need the derivings, so we return Nothing return (HsDataDefn { dd_ext = noExtField- , dd_ND = nd, dd_ctxt = lcontext', dd_cType = cType+ , dd_ctxt = lcontext', dd_cType = cType , dd_kindSig = k', dd_cons = cons' , dd_derivs = [] }) @@ -519,6 +523,7 @@ , con_args = details', con_doc = mbldoc' }) renameCon ConDeclGADT { con_names = lnames, con_bndrs = bndrs+ , con_dcolon = dcol , con_mb_cxt = lcontext, con_g_args = details , con_res_ty = res_ty , con_doc = mbldoc } = do@@ -529,7 +534,8 @@ res_ty' <- renameLType res_ty mbldoc' <- mapM renameLDocHsSyn mbldoc return (ConDeclGADT- { con_g_ext = noExtField, con_names = lnames', con_bndrs = bndrs'+ { con_g_ext = noExtField, con_names = lnames'+ , con_dcolon = dcol, con_bndrs = bndrs' , con_mb_cxt = lcontext', con_g_args = details' , con_res_ty = res_ty', con_doc = mbldoc' }) @@ -584,9 +590,9 @@ FixSig _ (FixitySig _ lnames fixity) -> do lnames' <- mapM renameL lnames return $ FixSig noExtField (FixitySig noExtField lnames' fixity)- MinimalSig _ src (L l s) -> do+ MinimalSig _ (L l s) -> do s' <- traverse (traverse lookupRnNoWarn) s- return $ MinimalSig noExtField src (L l s')+ return $ MinimalSig noExtField (L l s') -- we have filtered out all other kinds of signatures in Interface.Create _ -> error "expected TypeSig" @@ -595,11 +601,17 @@ renameForD (ForeignImport _ lname ltype x) = do lname' <- renameL lname ltype' <- renameLSigType ltype- return (ForeignImport noExtField lname' ltype' x)+ return (ForeignImport noExtField lname' ltype' (renameForI x)) renameForD (ForeignExport _ lname ltype x) = do lname' <- renameL lname ltype' <- renameLSigType ltype- return (ForeignExport noExtField lname' ltype' x)+ return (ForeignExport noExtField lname' ltype' (renameForE x))++renameForI :: ForeignImport GhcRn -> ForeignImport DocNameI+renameForI (CImport _ cconv safety mHeader spec) = CImport noExtField cconv safety mHeader spec++renameForE :: ForeignExport GhcRn -> ForeignExport DocNameI+renameForE (CExport _ spec) = CExport noExtField spec renameInstD :: InstDecl GhcRn -> RnM (InstDecl DocNameI)
haddock-api/src/Haddock/InterfaceFile.hs view
@@ -123,8 +123,8 @@ -- (2) set `binaryInterfaceVersionCompatibility` to [binaryInterfaceVersion] -- binaryInterfaceVersion :: Word16-#if MIN_VERSION_ghc(9,4,0) && !MIN_VERSION_ghc(9,5,0)-binaryInterfaceVersion = 41+#if MIN_VERSION_ghc(9,6,0) && !MIN_VERSION_ghc(9,7,0)+binaryInterfaceVersion = 42 binaryInterfaceVersionCompatibility :: [Word16] binaryInterfaceVersionCompatibility = [binaryInterfaceVersion]
haddock-api/src/Haddock/Types.hs view
@@ -44,9 +44,7 @@ import Data.Typeable (Typeable) import Data.Map (Map) import Data.Data (Data)-import Data.Void (Void) import Documentation.Haddock.Types-import GHC.Types.Basic (PromotionFlag(..)) import GHC.Types.Fixity (Fixity(..)) import GHC.Types.Var (Specificity) @@ -322,6 +320,7 @@ instance CollectPass DocNameI where collectXXPat _ ext = dataConCantHappen ext collectXXHsBindsLR ext = dataConCantHappen ext+ collectXSplicePat _ ext = dataConCantHappen ext instance NamedThing DocName where getName (Documented name _) = name@@ -750,7 +749,7 @@ type instance XParTy DocNameI = EpAnn AnnParen type instance XIParamTy DocNameI = EpAnn [AddEpAnn] type instance XKindSig DocNameI = EpAnn [AddEpAnn]-type instance XSpliceTy DocNameI = Void -- see `renameHsSpliceTy`+type instance XSpliceTy DocNameI = DataConCantHappen type instance XDocTy DocNameI = EpAnn [AddEpAnn] type instance XBangTy DocNameI = EpAnn [AddEpAnn] type instance XRecTy DocNameI = EpAnn [AddEpAnn]@@ -760,6 +759,11 @@ type instance XWildCardTy DocNameI = EpAnn [AddEpAnn] type instance XXType DocNameI = HsCoreTy +type instance XNumTy DocNameI = NoExtField+type instance XStrTy DocNameI = NoExtField+type instance XCharTy DocNameI = NoExtField+type instance XXTyLit DocNameI = DataConCantHappen+ type instance XHsForAllVis DocNameI = NoExtField type instance XHsForAllInvis DocNameI = NoExtField type instance XXHsForAllTelescope DocNameI = DataConCantHappen@@ -780,6 +784,13 @@ type instance XForeignExport DocNameI = NoExtField type instance XForeignImport DocNameI = NoExtField++type instance XCImport DocNameI = NoExtField+type instance XCExport DocNameI = NoExtField++type instance XXForeignImport DocNameI = DataConCantHappen+type instance XXForeignExport DocNameI = DataConCantHappen+ type instance XConDeclGADT DocNameI = NoExtField type instance XConDeclH98 DocNameI = NoExtField type instance XXConDecl DocNameI = DataConCantHappen@@ -831,6 +842,8 @@ type instance XXPat DocNameI = DataConCantHappen type instance XXHsBindsLR DocNameI a = DataConCantHappen++type instance XSplicePat DocNameI = DataConCantHappen type instance XCInjectivityAnn DocNameI = NoExtField
haddock.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: haddock-version: 2.27.0+version: 2.28.0 synopsis: A documentation-generation tool for Haskell libraries description: This is Haddock, a tool for automatically generating documentation@@ -35,7 +35,7 @@ copyright: (c) Simon Marlow, David Waern category: Documentation build-type: Simple-tested-with: GHC==9.4.*+tested-with: GHC==9.6.* extra-source-files: CHANGES.md@@ -68,7 +68,7 @@ -- haddock typically only supports a single GHC major version build-depends:- base ^>= 4.13.0.0 || ^>= 4.14.0.0 || ^>= 4.15.0.0 || ^>= 4.16.0.0 || ^>= 4.17.0.0+ base ^>= 4.13.0.0 || ^>= 4.14.0.0 || ^>= 4.15.0.0 || ^>= 4.16.0.0 || ^>= 4.17.0.0 || ^>= 4.18.0.0 || ^>= 4.19.0.0 if flag(in-ghc-tree) hs-source-dirs: haddock-api/src, haddock-library/src@@ -83,7 +83,7 @@ xhtml >= 3000.2 && < 3000.3, ghc-boot, ghc-boot-th,- ghc == 9.4.*,+ ghc == 9.6.*, bytestring, parsec, text,@@ -150,7 +150,7 @@ else -- in order for haddock's advertised version number to have proper meaning, -- we pin down to a single haddock-api version.- build-depends: haddock-api == 2.27.0+ build-depends: haddock-api == 2.28.0 test-suite html-test type: exitcode-stdio-1.0
html-test/ref/Bug1004.html view
@@ -1688,14 +1688,12 @@ ><span class="inst-left" ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Read:19" ></span- > (<a href="#" title="Data.Functor.Classes"- >Read1</a- > f, <a href="#" title="Data.Functor.Classes"- >Read1</a- > g, <a href="#" title="Text.Read"+ > (<a href="#" title="Text.Read" >Read</a- > a) => <a href="#" title="Text.Read"+ > (f a), <a href="#" title="Text.Read" >Read</a+ > (g a)) => <a href="#" title="Text.Read"+ >Read</a > (<a href="#" title="Bug1004" >Product</a > f g a)</span@@ -1703,7 +1701,7 @@ ><td class="doc" ><p ><em- >Since: base-4.9.0.0</em+ >Since: base-4.18.0.0</em ></p ></td ></tr@@ -1770,14 +1768,12 @@ ><span class="inst-left" ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Show:20" ></span- > (<a href="#" title="Data.Functor.Classes"- >Show1</a- > f, <a href="#" title="Data.Functor.Classes"- >Show1</a- > g, <a href="#" title="Text.Show"+ > (<a href="#" title="Text.Show" >Show</a- > a) => <a href="#" title="Text.Show"+ > (f a), <a href="#" title="Text.Show" >Show</a+ > (g a)) => <a href="#" title="Text.Show"+ >Show</a > (<a href="#" title="Bug1004" >Product</a > f g a)</span@@ -1785,7 +1781,7 @@ ><td class="doc" ><p ><em- >Since: base-4.9.0.0</em+ >Since: base-4.18.0.0</em ></p ></td ></tr@@ -1842,14 +1838,12 @@ ><span class="inst-left" ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Eq:21" ></span- > (<a href="#" title="Data.Functor.Classes"- >Eq1</a- > f, <a href="#" title="Data.Functor.Classes"- >Eq1</a- > g, <a href="#" title="Data.Eq"+ > (<a href="#" title="Data.Eq" >Eq</a- > a) => <a href="#" title="Data.Eq"+ > (f a), <a href="#" title="Data.Eq" >Eq</a+ > (g a)) => <a href="#" title="Data.Eq"+ >Eq</a > (<a href="#" title="Bug1004" >Product</a > f g a)</span@@ -1857,7 +1851,7 @@ ><td class="doc" ><p ><em- >Since: base-4.9.0.0</em+ >Since: base-4.18.0.0</em ></p ></td ></tr@@ -1906,14 +1900,12 @@ ><span class="inst-left" ><span class="instance details-toggle-control details-toggle" data-details-id="i:id:Product:Ord:22" ></span- > (<a href="#" title="Data.Functor.Classes"- >Ord1</a- > f, <a href="#" title="Data.Functor.Classes"- >Ord1</a- > g, <a href="#" title="Data.Ord"+ > (<a href="#" title="Data.Ord" >Ord</a- > a) => <a href="#" title="Data.Ord"+ > (f a), <a href="#" title="Data.Ord" >Ord</a+ > (g a)) => <a href="#" title="Data.Ord"+ >Ord</a > (<a href="#" title="Bug1004" >Product</a > f g a)</span@@ -1921,7 +1913,7 @@ ><td class="doc" ><p ><em- >Since: base-4.9.0.0</em+ >Since: base-4.18.0.0</em ></p ></td ></tr
html-test/ref/Bug923.html view
@@ -66,7 +66,7 @@ >T</a > :: a -> <a href="#" title="Bug923" >T</a- > ('<a href="#" title="GHC.Tuple"+ > ('<a href="#" title="GHC.Tuple.Prim" >(,)</a > a)</li ></ul@@ -102,7 +102,7 @@ >T</a > :: a -> <a href="#" title="Bug923" >T</a- > ('<a href="#" title="GHC.Tuple"+ > ('<a href="#" title="GHC.Tuple.Prim" >(,)</a > a)</td ><td class="doc empty"@@ -128,7 +128,7 @@ >Eq</a > (<a href="#" title="Bug923" >T</a- > ('<a href="#" title="GHC.Tuple"+ > ('<a href="#" title="GHC.Tuple.Prim" >(,)</a > a :: <a href="#" title="Data.Kind" >Type</a@@ -162,11 +162,11 @@ >(==)</a > :: <a href="#" title="Bug923" >T</a- > ('<a href="#" title="GHC.Tuple"+ > ('<a href="#" title="GHC.Tuple.Prim" >(,)</a > a) -> <a href="#" title="Bug923" >T</a- > ('<a href="#" title="GHC.Tuple"+ > ('<a href="#" title="GHC.Tuple.Prim" >(,)</a > a) -> <a href="#" title="Data.Bool" >Bool</a@@ -178,11 +178,11 @@ >(/=)</a > :: <a href="#" title="Bug923" >T</a- > ('<a href="#" title="GHC.Tuple"+ > ('<a href="#" title="GHC.Tuple.Prim" >(,)</a > a) -> <a href="#" title="Bug923" >T</a- > ('<a href="#" title="GHC.Tuple"+ > ('<a href="#" title="GHC.Tuple.Prim" >(,)</a > a) -> <a href="#" title="Data.Bool" >Bool</a
html-test/ref/FunArgs.html view
@@ -232,7 +232,7 @@ >forall</span > a (b :: ()) d. d <a href="#" title="Data.Type.Equality" >~</a- > '<a href="#" title="GHC.Tuple"+ > '<a href="#" title="GHC.Tuple.Prim" >()</a ></td ><td class="doc empty"
html-test/ref/Instances.html view
@@ -262,7 +262,9 @@ ></span > <a href="#" title="Instances" >Foo</a- > []</span+ > <a href="#" title="GHC.List"+ >List</a+ ></span > <a href="#" class="selflink" >#</a ></td@@ -438,7 +440,7 @@ >Foo</a > f) => <a href="#" title="Instances" >Foo</a- > (<a href="#" title="GHC.Tuple"+ > (<a href="#" title="GHC.Tuple.Prim" >(,)</a > (f a))</span > <a href="#" class="selflink"@@ -550,7 +552,7 @@ ></span > <a href="#" title="Instances" >Foo</a- > (<a href="#" title="GHC.Tuple"+ > (<a href="#" title="GHC.Tuple.Prim" >(,,)</a > a a)</span > <a href="#" class="selflink"@@ -900,7 +902,9 @@ ></span > <a href="#" title="Instances" >Bar</a- > [] (a, a)</span+ > <a href="#" title="GHC.List"+ >List</a+ > (a, a)</span > <a href="#" class="selflink" >#</a ></td@@ -1150,11 +1154,11 @@ ></span > <a href="#" title="Instances" >Foo</a- > (<a href="#" title="GHC.Tuple"+ > (<a href="#" title="GHC.Tuple.Prim" >(,,)</a > a b) => <a href="#" title="Instances" >Bar</a- > (<a href="#" title="GHC.Tuple"+ > (<a href="#" title="GHC.Tuple.Prim" >(,,)</a > a b) (a, b, a)</span > <a href="#" class="selflink"
hypsrc-test/ref/src/Records.html view
@@ -862,10 +862,7 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >x :: Int-</span- ><a href="Records.html#x"+ ><a href="Records.html#x" ><span class="hs-identifier hs-var" >x</span ></a@@ -877,10 +874,7 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >Point -> Int-</span- ><a href="Records.html#x"+ ><a href="Records.html#x" ><span class="hs-identifier hs-var" >x</span ></a@@ -888,32 +882,22 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >Point-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >p</span ></a ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int -> Int -> Int-forall a. Num a => a -> a -> a-</span- ><span class="hs-operator hs-var"+ ><span class="hs-operator hs-type" >+</span ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >d</span ></a ></span@@ -985,10 +969,7 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >y :: Int-</span- ><a href="Records.html#y"+ ><a href="Records.html#y" ><span class="hs-identifier hs-var" >y</span ></a@@ -1000,10 +981,7 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >Point -> Int-</span- ><a href="Records.html#y"+ ><a href="Records.html#y" ><span class="hs-identifier hs-var" >y</span ></a@@ -1011,32 +989,22 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >Point-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >p</span ></a ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int -> Int -> Int-forall a. Num a => a -> a -> a-</span- ><span class="hs-operator hs-var"+ ><span class="hs-operator hs-type" >+</span ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >d</span ></a ></span@@ -1337,10 +1305,7 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >x :: Int-</span- ><a href="Records.html#x"+ ><a href="Records.html#x" ><span class="hs-identifier hs-var" >x</span ></a@@ -1352,32 +1317,22 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >Int-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >x</span ></a ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int -> Int -> Int-forall a. Num a => a -> a -> a-</span- ><span class="hs-operator hs-var"+ ><span class="hs-operator hs-type" >+</span ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >dx</span ></a ></span@@ -1386,10 +1341,7 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >y :: Int-</span- ><a href="Records.html#y"+ ><a href="Records.html#y" ><span class="hs-identifier hs-var" >y</span ></a@@ -1401,32 +1353,22 @@ ><span > </span ><span class="annot"- ><span class="annottext"- >Int-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >y</span ></a ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int -> Int -> Int-forall a. Num a => a -> a -> a-</span- ><span class="hs-operator hs-var"+ ><span class="hs-operator hs-type" >+</span ></span ><span > </span ><span class="annot"- ><span class="annottext"- >Int-</span- ><a href="#"- ><span class="hs-identifier hs-var"+ ><a href="#"+ ><span class="hs-identifier hs-type" >dy</span ></a ></span
hypsrc-test/ref/src/TemplateHaskellQuasiquotes.html view
@@ -110,8 +110,12 @@ ></span ><span > </span- ><span class="hs-identifier"- >bar</span+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-type"+ >bar</span+ ></a+ ></span ><span > </span ><span class="hs-glyph"@@ -120,8 +124,15 @@ > </span ><span class="hs-special" >$</span- ><span class="hs-identifier"- >aType</span+ ><span class="annot"+ ><span class="annottext"+ >TypeQ+</span+ ><a href="TemplateHaskellQuasiquotes.html#aType"+ ><span class="hs-identifier hs-var"+ >aType</span+ ></a+ ></span ><span > </span ><span class="hs-glyph"@@ -134,14 +145,18 @@ > </span ><span class="hs-special" >(</span- ><span class="hs-identifier"- >Int</span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >Int</span+ ></span ><span class="hs-special" >,</span ><span > </span- ><span class="hs-identifier"- >String</span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >String</span+ ></span ><span class="hs-special" >)</span ><span@@ -155,14 +170,27 @@ ></span ><span > </span- ><span class="hs-identifier"- >bar</span+ ><span id=""+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-var hs-var"+ >bar</span+ ></a+ ></span+ ></span ><span > </span ><span class="hs-special" >$</span- ><span class="hs-identifier"- >aPattern</span+ ><span class="annot"+ ><span class="annottext"+ >PatQ+</span+ ><a href="TemplateHaskellQuasiquotes.html#aPattern"+ ><span class="hs-identifier hs-var"+ >aPattern</span+ ></a+ ></span ><span > </span ><span class="hs-glyph"@@ -171,8 +199,15 @@ > </span ><span class="hs-special" >$</span- ><span class="hs-identifier"- >anExpression</span+ ><span class="annot"+ ><span class="annottext"+ >ExpQ+</span+ ><a href="TemplateHaskellQuasiquotes.html#anExpression"+ ><span class="hs-identifier hs-var"+ >anExpression</span+ ></a+ ></span ><span > </span@@ -243,8 +278,14 @@ >[</span ><span > </span- ><span class="hs-identifier"- >aCrazyLongVariableName</span+ ><span id=""+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-var"+ >aCrazyLongVariableName</span+ ></a+ ></span+ ></span ><span > </span@@ -256,8 +297,14 @@ >,</span ><span > </span- ><span class="hs-identifier"- >_unused</span+ ><span id=""+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-var"+ >_unused</span+ ></a+ ></span+ ></span ><span > </span@@ -271,14 +318,26 @@ > </span ><span class="hs-special" >(</span- ><span class="hs-identifier"- >y</span+ ><span id=""+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-var"+ >y</span+ ></a+ ></span+ ></span ><span class="hs-special" >,</span ><span > </span- ><span class="hs-identifier"- >z</span+ ><span id=""+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-var"+ >z</span+ ></a+ ></span+ ></span ><span class="hs-special" >)</span ><span@@ -298,14 +357,23 @@ > </span ><span class="hs-special" >$</span- ><span class="hs-identifier"- >aNumberPattern</span+ ><span class="annot"+ ><span class="annottext"+ >PatQ+</span+ ><a href="TemplateHaskellQuasiquotes.html#aNumberPattern"+ ><span class="hs-identifier hs-var"+ >aNumberPattern</span+ ></a+ ></span ><span class="hs-special" >,</span ><span > </span+ ><span class="annot" ><span class="hs-string"- >"hello"</span+ >"hello"</span+ ></span ><span class="hs-special" >)</span ><span@@ -383,16 +451,30 @@ ></span ><span > </span- ><span class="hs-identifier"- >w</span+ ><span id=""+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-var"+ >w</span+ ></a+ ></span+ ></span ><span class="hs-glyph" >@</span- ><span class="hs-identifier"- >v</span+ ><span id=""+ ><span class="annot"+ ><a href="#"+ ><span class="hs-identifier hs-var"+ >v</span+ ></a+ ></span+ ></span ><span class="hs-glyph" >@</span+ ><span class="annot" ><span class="hs-number"- >4.5</span+ >4.5</span+ ></span ><span > </span@@ -475,24 +557,37 @@ > </span ><span class="hs-special" >(</span+ ><span class="annot" ><span class="hs-number"- >1</span+ >1</span+ ></span ><span > </span- ><span class="hs-operator"- >+</span+ ><span class="annot"+ ><span class="hs-operator hs-type"+ >+</span+ ></span ><span > </span ><span class="hs-special" >$</span- ><span class="hs-identifier"- >anExpression2</span+ ><span class="annot"+ ><span class="annottext"+ >ExpQ+</span+ ><a href="TemplateHaskellQuasiquotes.html#anExpression2"+ ><span class="hs-identifier hs-var"+ >anExpression2</span+ ></a+ ></span ><span class="hs-special" >,</span ><span > </span+ ><span class="annot" ><span class="hs-string"- >"world"</span+ >"world"</span+ ></span ><span class="hs-special" >)</span ><span@@ -536,20 +631,28 @@ > </span ><span class="hs-special" >(</span+ ><span class="annot" ><span class="hs-number"- >1</span+ >1</span+ ></span ><span > </span- ><span class="hs-operator"- >+</span+ ><span class="annot"+ ><span class="hs-operator hs-type"+ >+</span+ ></span ><span > </span- ><span class="hs-identifier"- >round</span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >round</span+ ></span ><span > </span- ><span class="hs-identifier"- >pi</span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >pi</span+ ></span ><span class="hs-special" >)</span ><span@@ -619,14 +722,18 @@ > </span ><span class="hs-special" >(</span- ><span class="hs-identifier"- >Double</span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >Double</span+ ></span ><span class="hs-special" >,</span ><span > </span- ><span class="hs-identifier"- >String</span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >String</span+ ></span ><span class="hs-special" >)</span ><span@@ -652,15 +759,186 @@ </span ><span id="line-39" ></span+ ><span class="annot"+ ><a href="TemplateHaskellQuasiquotes.html#typedExpr1"+ ><span class="hs-identifier hs-type"+ >typedExpr1</span+ ></a+ ></span ><span+ > </span+ ><span class="hs-glyph"+ >::</span+ ><span+ > </span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >Code</span+ ></span+ ><span+ > </span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >Q</span+ ></span+ ><span+ > </span+ ><span class="hs-special"+ >(</span+ ><span class="hs-special"+ >)</span+ ><span > </span ><span id="line-40" ></span+ ><span id="typedExpr1"+ ><span class="annot"+ ><span class="annottext"+ >typedExpr1 :: Code Q ()+</span+ ><a href="TemplateHaskellQuasiquotes.html#typedExpr1"+ ><span class="hs-identifier hs-var hs-var"+ >typedExpr1</span+ ></a+ ></span+ ></span ><span+ > </span+ ><span class="hs-glyph"+ >=</span+ ><span+ > </span+ ><span class="hs-special"+ >[||</span+ ><span+ > </span+ ><span class="hs-special"+ >(</span+ ><span class="hs-special"+ >)</span+ ><span+ > </span+ ><span class="hs-special"+ >||]</span+ ><span > </span ><span id="line-41"+ ></span+ ><span+ >+</span+ ><span id="line-42"+ ></span+ ><span class="annot"+ ><a href="TemplateHaskellQuasiquotes.html#typedExpr"+ ><span class="hs-identifier hs-type"+ >typedExpr</span+ ></a+ ></span+ ><span+ > </span+ ><span class="hs-glyph"+ >::</span+ ><span+ > </span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >Code</span+ ></span+ ><span+ > </span+ ><span class="annot"+ ><span class="hs-identifier hs-type"+ >Q</span+ ></span+ ><span+ > </span+ ><span class="hs-special"+ >(</span+ ><span class="hs-special"+ >)</span+ ><span+ >+</span+ ><span id="line-43"+ ></span+ ><span id="typedExpr"+ ><span class="annot"+ ><span class="annottext"+ >typedExpr :: Code Q ()+</span+ ><a href="TemplateHaskellQuasiquotes.html#typedExpr"+ ><span class="hs-identifier hs-var hs-var"+ >typedExpr</span+ ></a+ ></span+ ></span+ ><span+ > </span+ ><span class="hs-glyph"+ >=</span+ ><span+ > </span+ ><span class="hs-special"+ >[||</span+ ><span+ > </span+ ><span class="annot"+ ><span class="annottext"+ >a -> b -> a+forall a b. a -> b -> a+</span+ ><span class="hs-identifier hs-var"+ >const</span+ ></span+ ><span+ > </span+ ><span class="hs-special"+ >$$</span+ ><span class="hs-special"+ >(</span+ ><span class="annot"+ ><span class="annottext"+ >Code Q ()+</span+ ><a href="TemplateHaskellQuasiquotes.html#typedExpr1"+ ><span class="hs-identifier hs-var"+ >typedExpr1</span+ ></a+ ></span+ ><span class="hs-special"+ >)</span+ ><span+ > </span+ ><span class="hs-special"+ >(</span+ ><span class="hs-special"+ >)</span+ ><span+ > </span+ ><span class="hs-special"+ >||]</span+ ><span+ >+</span+ ><span id="line-44"+ ></span+ ><span+ >+</span+ ><span id="line-45"+ ></span+ ><span+ >+</span+ ><span id="line-46"+ ></span+ ><span+ >+</span+ ><span id="line-47" ></span ></pre ></body
hypsrc-test/ref/src/TemplateHaskellSplices.html view
@@ -111,14 +111,124 @@ >$</span ><span class="hs-special" >(</span- ><span class="hs-identifier"- >anExpression2</span+ ><span class="annot"+ ><a href="TemplateHaskellQuasiquotes.html#anExpression2"+ ><span class="hs-identifier hs-type"+ >anExpression2</span+ ></a+ ></span ><span class="hs-special" >)</span ><span > </span ><span id="line-10"+ ></span+ ><span+ >+</span+ ><span id="line-11"+ ></span+ ><span id="pat"+ ><span class="annot"+ ><span class="annottext"+ >pat :: [(a, String)] -> ()+</span+ ><a href="TemplateHaskellSplices.html#pat"+ ><span class="hs-identifier hs-var hs-var"+ >pat</span+ ></a+ ></span+ ></span+ ><span+ > </span+ ><span class="hs-special"+ >$</span+ ><span id=""+ ><span id=""+ ><span id=""+ ><span id=""+ ><span id=""+ ><span id=""+ ><span class="hs-special"+ >(</span+ ><span class="annot"+ ><a href="TemplateHaskellQuasiquotes.html#aPattern"+ ><span class="hs-identifier hs-type"+ >aPattern</span+ ></a+ ></span+ ><span class="hs-special"+ >)</span+ ></span+ ></span+ ></span+ ></span+ ></span+ ></span+ ><span+ > </span+ ><span class="hs-glyph"+ >=</span+ ><span+ > </span+ ><span class="hs-special"+ >(</span+ ><span class="hs-special"+ >)</span+ ><span+ >+</span+ ><span id="line-12"+ ></span+ ><span+ >+</span+ ><span id="line-13"+ ></span+ ><span id="qux"+ ><span class="annot"+ ><span class="annottext"+ >qux :: ()+</span+ ><a href="TemplateHaskellSplices.html#qux"+ ><span class="hs-identifier hs-var hs-var"+ >qux</span+ ></a+ ></span+ ></span+ ><span+ > </span+ ><span class="hs-glyph"+ >=</span+ ><span+ > </span+ ><span class="annot"+ ><span class="annottext"+ >() -> ()+forall a. a -> a+</span+ ><span class="hs-identifier hs-var"+ >id</span+ ></span+ ><span+ > </span+ ><span class="hs-special"+ >$$</span+ ><span class="hs-special"+ >(</span+ ><span class="annot"+ ><a href="TemplateHaskellQuasiquotes.html#typedExpr"+ ><span class="hs-identifier hs-type"+ >typedExpr</span+ ></a+ ></span+ ><span class="hs-special"+ >)</span+ ><span+ >+</span+ ><span id="line-14" ></span ></pre ></body
hypsrc-test/src/TemplateHaskellQuasiquotes.hs view
@@ -36,5 +36,11 @@ [ (Double, String) ] |] +typedExpr1 :: Code Q ()+typedExpr1 = [|| () ||]++typedExpr :: Code Q ()+typedExpr = [|| const $$(typedExpr1) () ||]+
hypsrc-test/src/TemplateHaskellSplices.hs view
@@ -7,3 +7,7 @@ $(aDecl) foo = id $(anExpression2)++pat $(aPattern) = ()++qux = id $$(typedExpr)