Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

24 changed files:

Changes:

  • hadrian/src/Rules/ToolArgs.hs
    ... ... @@ -172,6 +172,7 @@ toolTargets = [ cabalSyntax
    172 172
                   , time
    
    173 173
                   , semaphoreCompat
    
    174 174
                   , unlit  -- # executable
    
    175
    +              , xhtml
    
    175 176
                   ] ++ if windowsHost then [ win32 ] else [ unix ]
    
    176 177
     
    
    177 178
     -- | Create a mapping from files to which component it belongs to.
    

  • hadrian/src/Settings/Default.hs
    ... ... @@ -109,6 +109,7 @@ stage0Packages = do
    109 109
                  , thLift -- new library not yet present for boot compilers
    
    110 110
                  , thQuasiquoter -- new library not yet present for boot compilers
    
    111 111
                  , unlit
    
    112
    +             , xhtml -- new version is not backwards compat with latest
    
    112 113
                  , if windowsHost then win32 else unix
    
    113 114
                  -- We must use the in-tree `Win32` as the version
    
    114 115
                  -- bundled with GHC 9.6 is too old for `semaphore-compat`.
    

  • libraries/xhtml
    1
    -Subproject commit 68353ccd1a2e776d6c2b11619265d8140bb7dc07
    1
    +Subproject commit cc203b9cc0a60c53a3bcbf2f38eb72cb7cf6098d

  • utils/haddock/cabal.project
    ... ... @@ -12,4 +12,4 @@ package haddock-api
    12 12
       tests: False
    
    13 13
     
    
    14 14
     -- Pinning the index-state helps to make reasonably CI deterministic
    
    15
    -index-state: 2024-06-18T11:54:44Z
    15
    +index-state: 2025-11-17T03:30:46Z

  • utils/haddock/haddock-api/haddock-api.cabal
    ... ... @@ -51,6 +51,7 @@ common extensions
    51 51
         StrictData
    
    52 52
         TypeApplications
    
    53 53
         TypeOperators
    
    54
    +    OverloadedStrings
    
    54 55
     
    
    55 56
       default-language:   Haskell2010
    
    56 57
     
    
    ... ... @@ -81,7 +82,7 @@ library
    81 82
       build-depends: base             >= 4.16 && < 4.23
    
    82 83
                    , ghc             ^>= 9.15
    
    83 84
                    , haddock-library ^>= 1.11
    
    84
    -               , xhtml           ^>= 3000.2.2
    
    85
    +               , xhtml           ^>= 3000.4.0.0
    
    85 86
                    , parsec          ^>= 3.1.13.0
    
    86 87
     
    
    87 88
       -- Versions for the dependencies below are transitively pinned by
    
    ... ... @@ -97,6 +98,7 @@ library
    97 98
                    , ghc-boot
    
    98 99
                    , mtl
    
    99 100
                    , transformers
    
    101
    +               , text
    
    100 102
     
    
    101 103
       hs-source-dirs: src
    
    102 104
     
    
    ... ... @@ -212,7 +214,7 @@ test-suite spec
    212 214
       build-depends: ghc             ^>= 9.7
    
    213 215
                    , ghc-paths       ^>= 0.1.0.12
    
    214 216
                    , haddock-library ^>= 1.11
    
    215
    -               , xhtml           ^>= 3000.2.2
    
    217
    +               , xhtml           ^>= 3000.4.0.0
    
    216 218
                    , hspec           ^>= 2.9
    
    217 219
                    , parsec          ^>= 3.1.13.0
    
    218 220
                    , QuickCheck      >= 2.11  && ^>= 2.14
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Hoogle.hs
    ... ... @@ -134,7 +134,7 @@ out :: Outputable a => SDocContext -> a -> String
    134 134
     out sDocContext = outWith $ Outputable.renderWithContext sDocContext
    
    135 135
     
    
    136 136
     operator :: String -> String
    
    137
    -operator (x : xs) | not (isAlphaNum x) && x `notElem` "_' ([{" = '(' : x : xs ++ ")"
    
    137
    +operator (x : xs) | not (isAlphaNum x) && x `notElem` ("_' ([{" :: String) = '(' : x : xs ++ ")"
    
    138 138
     operator x = x
    
    139 139
     
    
    140 140
     commaSeparate :: Outputable a => SDocContext -> [a] -> String
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
    ... ... @@ -28,10 +28,11 @@ import Haddock.Backends.Hyperlinker.Parser
    28 28
     import Haddock.Backends.Hyperlinker.Renderer
    
    29 29
     import Haddock.Backends.Hyperlinker.Types
    
    30 30
     import Haddock.Backends.Hyperlinker.Utils
    
    31
    -import Haddock.Backends.Xhtml.Utils (renderToString)
    
    31
    +import Haddock.Backends.Xhtml.Utils (renderToBuilder)
    
    32 32
     import Haddock.InterfaceFile
    
    33 33
     import Haddock.Types
    
    34
    -import Haddock.Utils (Verbosity, out, verbose, writeUtf8File)
    
    34
    +import Haddock.Utils (Verbosity, out, verbose)
    
    35
    +import qualified Data.ByteString.Builder as Builder
    
    35 36
     
    
    36 37
     -- | Generate hyperlinked source for given interfaces.
    
    37 38
     --
    
    ... ... @@ -117,7 +118,7 @@ ppHyperlinkedModuleSource verbosity srcdir pretty srcs iface = do
    117 118
       let tokens = fmap (\tk -> tk{tkSpan = (tkSpan tk){srcSpanFile = srcSpanFile $ nodeSpan fullAst}}) tokens'
    
    118 119
     
    
    119 120
       -- Produce and write out the hyperlinked sources
    
    120
    -  writeUtf8File path . renderToString pretty . render' thisModule fullAst $ tokens
    
    121
    +  Builder.writeFile path . renderToBuilder pretty . render' thisModule fullAst $ tokens
    
    121 122
       where
    
    122 123
         dflags = ifaceDynFlags iface
    
    123 124
         sDocContext = DynFlags.initSDocContext dflags Outputable.defaultUserStyle
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Renderer.hs
    ... ... @@ -24,7 +24,9 @@ import qualified Text.XHtml as Html
    24 24
     import Haddock.Backends.Hyperlinker.Types
    
    25 25
     import Haddock.Backends.Hyperlinker.Utils
    
    26 26
     
    
    27
    -type StyleClass = String
    
    27
    +import qualified Data.Text.Lazy as LText
    
    28
    +
    
    29
    +type StyleClass = LText.Text
    
    28 30
     
    
    29 31
     -- | Produce the HTML corresponding to a hyperlinked Haskell source
    
    30 32
     render
    
    ... ... @@ -50,7 +52,7 @@ body thisModule srcs ast tokens = Html.body . Html.pre $ hypsrc
    50 52
     
    
    51 53
     header :: Maybe FilePath -> Maybe FilePath -> Html
    
    52 54
     header Nothing Nothing = Html.noHtml
    
    53
    -header mcss mjs = Html.header $ css mcss <> js mjs
    
    55
    +header mcss mjs = Html.header $ css (LText.pack <$> mcss) <> js (LText.pack <$> mjs)
    
    54 56
       where
    
    55 57
         css Nothing = Html.noHtml
    
    56 58
         css (Just cssFile) =
    
    ... ... @@ -225,7 +227,7 @@ tokenStyle TkPragma = ["hs-pragma"]
    225 227
     tokenStyle TkUnknown = []
    
    226 228
     
    
    227 229
     multiclass :: [StyleClass] -> HtmlAttr
    
    228
    -multiclass = Html.theclass . unwords
    
    230
    +multiclass = Html.theclass . LText.unwords
    
    229 231
     
    
    230 232
     externalAnchor :: Identifier -> Set.Set ContextInfo -> Html -> Html
    
    231 233
     externalAnchor (Right name) contexts content
    
    ... ... @@ -250,11 +252,11 @@ internalAnchor (Right name) contexts content
    250 252
           Html.thespan content ! [Html.identifier $ internalAnchorIdent name]
    
    251 253
     internalAnchor _ _ content = content
    
    252 254
     
    
    253
    -externalAnchorIdent :: Name -> String
    
    254
    -externalAnchorIdent = hypSrcNameUrl
    
    255
    +externalAnchorIdent :: Name -> LText.Text
    
    256
    +externalAnchorIdent name = LText.pack (hypSrcNameUrl name)
    
    255 257
     
    
    256
    -internalAnchorIdent :: Name -> String
    
    257
    -internalAnchorIdent = ("l-" ++) . showUnique . nameUnique
    
    258
    +internalAnchorIdent :: Name -> LText.Text
    
    259
    +internalAnchorIdent = LText.pack . ("l-" ++) . showUnique . nameUnique
    
    258 260
     
    
    259 261
     -- | Generate the HTML hyperlink for an identifier
    
    260 262
     hyperlink :: Module -> SrcMaps -> Identifier -> Html -> Html
    
    ... ... @@ -269,16 +271,16 @@ hyperlink thisModule (srcs, srcs') ident = case ident of
    269 271
         makeHyperlinkUrl url = ".." </> url
    
    270 272
     
    
    271 273
         internalHyperlink name content =
    
    272
    -      Html.anchor content ! [Html.href $ "#" ++ internalAnchorIdent name]
    
    274
    +      Html.anchor content ! [Html.href $ "#" <> internalAnchorIdent name]
    
    273 275
     
    
    274 276
         externalNameHyperlink name content = case Map.lookup mdl srcs of
    
    275 277
           Just SrcLocal ->
    
    276 278
             Html.anchor content
    
    277
    -          ! [Html.href $ hypSrcModuleNameUrl' thisModule mdl name]
    
    279
    +          ! [Html.href $ LText.pack (hypSrcModuleNameUrl' thisModule mdl name)]
    
    278 280
           Just (SrcExternal path) ->
    
    279 281
             let hyperlinkUrl = hypSrcModuleUrlToNameFormat $ makeHyperlinkUrl path
    
    280 282
              in Html.anchor content
    
    281
    -              ! [Html.href $ spliceURL (Just mdl) (Just name) Nothing hyperlinkUrl]
    
    283
    +              ! [Html.href $ LText.pack $ spliceURL (Just mdl) (Just name) Nothing hyperlinkUrl]
    
    282 284
           Nothing -> content
    
    283 285
           where
    
    284 286
             mdl = nameModule name
    
    ... ... @@ -287,11 +289,11 @@ hyperlink thisModule (srcs, srcs') ident = case ident of
    287 289
           case Map.lookup moduleName srcs' of
    
    288 290
             Just SrcLocal ->
    
    289 291
               Html.anchor content
    
    290
    -            ! [Html.href $ hypSrcModuleUrl' moduleName]
    
    292
    +            ! [Html.href $ LText.pack $ hypSrcModuleUrl' moduleName]
    
    291 293
             Just (SrcExternal path) ->
    
    292 294
               let hyperlinkUrl = makeHyperlinkUrl path
    
    293 295
                in Html.anchor content
    
    294
    -                ! [Html.href $ spliceURL' (Just moduleName) Nothing Nothing hyperlinkUrl]
    
    296
    +                ! [Html.href $ LText.pack $ spliceURL' (Just moduleName) Nothing Nothing hyperlinkUrl]
    
    295 297
             Nothing -> content
    
    296 298
     
    
    297 299
     renderSpace :: Int -> String -> Html
    
    ... ... @@ -307,4 +309,4 @@ renderSpace line space =
    307 309
        in Html.toHtml hspace <> renderSpace line rest
    
    308 310
     
    
    309 311
     lineAnchor :: Int -> Html
    
    310
    -lineAnchor line = Html.thespan Html.noHtml ! [Html.identifier $ hypSrcLineUrl line]
    312
    +lineAnchor line = Html.thespan Html.noHtml ! [Html.identifier $ LText.pack $ hypSrcLineUrl line]

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml.hs
    ... ... @@ -51,6 +51,10 @@ import qualified System.IO as IO
    51 51
     import Text.XHtml hiding (name, p, quote, title)
    
    52 52
     import qualified Text.XHtml as XHtml
    
    53 53
     import Prelude hiding (div)
    
    54
    +import qualified Data.Text.Lazy as LText
    
    55
    +import qualified Data.Text.Encoding as Text
    
    56
    +import qualified Data.Text as Text
    
    57
    +import qualified Data.ByteString.Lazy as LBS
    
    54 58
     
    
    55 59
     import Haddock.Backends.Xhtml.Decl
    
    56 60
     import Haddock.Backends.Xhtml.DocMarkup
    
    ... ... @@ -221,7 +225,7 @@ copyHtmlBits odir libdir themes withQuickjump = do
    221 225
     headHtml :: String -> Themes -> Maybe String -> Maybe String -> Html
    
    222 226
     headHtml docTitle themes mathjax_url base_url =
    
    223 227
       header
    
    224
    -    ! (maybe [] (\url -> [identifier "head", strAttr "data-base-url" url]) base_url)
    
    228
    +    ! (maybe [] (\url -> [identifier "head", strAttr "data-base-url" url]) (LText.pack <$> base_url))
    
    225 229
         << [ meta ! [httpequiv "Content-Type", content "text/html; charset=UTF-8"]
    
    226 230
            , meta ! [XHtml.name "viewport", content "width=device-width, initial-scale=1"]
    
    227 231
            , thetitle << docTitle
    
    ... ... @@ -229,18 +233,18 @@ headHtml docTitle themes mathjax_url base_url =
    229 233
            , thelink
    
    230 234
               ! [ rel "stylesheet"
    
    231 235
                 , thetype "text/css"
    
    232
    -            , href (withBaseURL base_url quickJumpCssFile)
    
    236
    +            , href (LText.pack $ withBaseURL base_url quickJumpCssFile)
    
    233 237
                 ]
    
    234 238
               << noHtml
    
    235 239
            , thelink ! [rel "stylesheet", thetype "text/css", href fontUrl] << noHtml
    
    236 240
            , script
    
    237
    -          ! [ src (withBaseURL base_url haddockJsFile)
    
    241
    +          ! [ src (LText.pack $ withBaseURL base_url haddockJsFile)
    
    238 242
                 , emptyAttr "async"
    
    239 243
                 , thetype "text/javascript"
    
    240 244
                 ]
    
    241 245
               << noHtml
    
    242 246
            , script ! [thetype "text/x-mathjax-config"] << primHtml mjConf
    
    243
    -       , script ! [src mjUrl, thetype "text/javascript"] << noHtml
    
    247
    +       , script ! [src (LText.pack mjUrl), thetype "text/javascript"] << noHtml
    
    244 248
            ]
    
    245 249
       where
    
    246 250
         fontUrl = "https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700"
    
    ... ... @@ -257,31 +261,31 @@ headHtml docTitle themes mathjax_url base_url =
    257 261
     
    
    258 262
     srcButton :: SourceURLs -> Maybe Interface -> Maybe Html
    
    259 263
     srcButton (Just src_base_url, _, _, _) Nothing =
    
    260
    -  Just (anchor ! [href src_base_url] << "Source")
    
    264
    +  Just (anchor ! [href (LText.pack src_base_url)] << ("Source" :: LText))
    
    261 265
     srcButton (_, Just src_module_url, _, _) (Just iface) =
    
    262 266
       let url = spliceURL (Just $ ifaceMod iface) Nothing Nothing src_module_url
    
    263
    -   in Just (anchor ! [href url] << "Source")
    
    267
    +   in Just (anchor ! [href (LText.pack url)] << ("Source" :: LText))
    
    264 268
     srcButton _ _ =
    
    265 269
       Nothing
    
    266 270
     
    
    267 271
     wikiButton :: WikiURLs -> Maybe Module -> Maybe Html
    
    268 272
     wikiButton (Just wiki_base_url, _, _) Nothing =
    
    269
    -  Just (anchor ! [href wiki_base_url] << "User Comments")
    
    273
    +  Just (anchor ! [href (LText.pack wiki_base_url)] << ("User Comments" :: LText))
    
    270 274
     wikiButton (_, Just wiki_module_url, _) (Just mdl) =
    
    271 275
       let url = spliceURL (Just mdl) Nothing Nothing wiki_module_url
    
    272
    -   in Just (anchor ! [href url] << "User Comments")
    
    276
    +   in Just (anchor ! [href (LText.pack url)] << ("User Comments" :: LText))
    
    273 277
     wikiButton _ _ =
    
    274 278
       Nothing
    
    275 279
     
    
    276 280
     contentsButton :: Maybe String -> Maybe Html
    
    277 281
     contentsButton maybe_contents_url =
    
    278
    -  Just (anchor ! [href url] << "Contents")
    
    282
    +  Just (anchor ! [href (LText.pack url)] << ("Contents" :: LText))
    
    279 283
       where
    
    280 284
         url = fromMaybe contentsHtmlFile maybe_contents_url
    
    281 285
     
    
    282 286
     indexButton :: Maybe String -> Maybe Html
    
    283 287
     indexButton maybe_index_url =
    
    284
    -  Just (anchor ! [href url] << "Index")
    
    288
    +  Just (anchor ! [href (LText.pack url)] << ("Index" :: LText))
    
    285 289
       where
    
    286 290
         url = fromMaybe indexHtmlFile maybe_index_url
    
    287 291
     
    
    ... ... @@ -318,8 +322,8 @@ bodyHtml
    318 322
              , divContent << pageContent
    
    319 323
              , divFooter
    
    320 324
                 << paragraph
    
    321
    -            << ( "Produced by "
    
    322
    -                  +++ (anchor ! [href projectUrl] << toHtml projectName)
    
    325
    +            << ( ("Produced by " :: LText)
    
    326
    +                  +++ (anchor ! [href (LText.pack projectUrl)] << toHtml projectName)
    
    323 327
                       +++ (" version " ++ projectVersion)
    
    324 328
                    )
    
    325 329
              ]
    
    ... ... @@ -368,7 +372,7 @@ moduleInfo iface =
    368 372
                         xs -> extField $ unordList xs ! [theclass "extension-list"]
    
    369 373
               | otherwise = []
    
    370 374
               where
    
    371
    -            extField x = return $ th << "Extensions" <-> td << x
    
    375
    +            extField x = return $ th << ("Extensions" :: LText) <-> td << x
    
    372 376
                 dropOpt x = if "Opt_" `isPrefixOf` x then drop 4 x else x
    
    373 377
        in
    
    374 378
         case entries of
    
    ... ... @@ -454,7 +458,7 @@ ppHtmlContents
    454 458
                    , ppModuleTrees pkg qual trees
    
    455 459
                    ]
    
    456 460
         createDirectoryIfMissing True odir
    
    457
    -    writeUtf8File (joinPath [odir, contentsHtmlFile]) (renderToString debug html)
    
    461
    +    Builder.writeFile (joinPath [odir, contentsHtmlFile]) (renderToBuilder debug html)
    
    458 462
         where
    
    459 463
           -- Extract a module's short description.
    
    460 464
           toInstalledDescription :: InstalledInterface -> Maybe (MDoc Name)
    
    ... ... @@ -472,11 +476,11 @@ ppPrologue pkg qual title (Just doc) =
    472 476
     ppSignatureTrees :: Maybe Package -> Qualification -> [(PackageInfo, [ModuleTree])] -> Html
    
    473 477
     ppSignatureTrees _ _ tss | all (null . snd) tss = mempty
    
    474 478
     ppSignatureTrees pkg qual [(info, ts)] =
    
    475
    -  divPackageList << (sectionName << "Signatures" +++ ppSignatureTree pkg qual "n" info ts)
    
    479
    +  divPackageList << (sectionName << ("Signatures" :: LText) +++ ppSignatureTree pkg qual "n" info ts)
    
    476 480
     ppSignatureTrees pkg qual tss =
    
    477 481
       divModuleList
    
    478 482
         << ( sectionName
    
    479
    -          << "Signatures"
    
    483
    +          << ("Signatures" :: LText)
    
    480 484
               +++ concatHtml
    
    481 485
                 [ ppSignatureTree pkg qual ("n." ++ show i ++ ".") info ts
    
    482 486
                 | (i, (info, ts)) <- zip [(1 :: Int) ..] tss
    
    ... ... @@ -491,11 +495,11 @@ ppSignatureTree pkg qual p info ts =
    491 495
     ppModuleTrees :: Maybe Package -> Qualification -> [(PackageInfo, [ModuleTree])] -> Html
    
    492 496
     ppModuleTrees _ _ tss | all (null . snd) tss = mempty
    
    493 497
     ppModuleTrees pkg qual [(info, ts)] =
    
    494
    -  divModuleList << (sectionName << "Modules" +++ ppModuleTree pkg qual "n" info ts)
    
    498
    +  divModuleList << (sectionName << ("Modules" :: LText) +++ ppModuleTree pkg qual "n" info ts)
    
    495 499
     ppModuleTrees pkg qual tss =
    
    496 500
       divPackageList
    
    497 501
         << ( sectionName
    
    498
    -          << "Packages"
    
    502
    +          << ("Packages" :: LText)
    
    499 503
               +++ concatHtml
    
    500 504
                 [ ppModuleTree pkg qual ("n." ++ show i ++ ".") info ts
    
    501 505
                 | (i, (info, ts)) <- zip [(1 :: Int) ..] tss
    
    ... ... @@ -519,11 +523,11 @@ mkNode pkg qual ss p (Node s leaf _pkg srcPkg short ts) =
    519 523
       htmlModule <+> shortDescr +++ htmlPkg +++ subtree
    
    520 524
       where
    
    521 525
         modAttrs = case (ts, leaf) of
    
    522
    -      (_ : _, Nothing) -> collapseControl p "module"
    
    526
    +      (_ : _, Nothing) -> collapseControl (LText.pack p) "module"
    
    523 527
           (_, _) -> [theclass "module"]
    
    524 528
     
    
    525 529
         cBtn = case (ts, leaf) of
    
    526
    -      (_ : _, Just _) -> thespan ! collapseControl p "" << spaceHtml
    
    530
    +      (_ : _, Just _) -> thespan ! collapseControl (LText.pack p) "" << spaceHtml
    
    527 531
           ([], Just _) -> thespan ! [theclass "noexpander"] << spaceHtml
    
    528 532
           (_, _) -> noHtml
    
    529 533
         -- We only need an explicit collapser button when the module name
    
    ... ... @@ -547,11 +551,11 @@ mkNode pkg qual ss p (Node s leaf _pkg srcPkg short ts) =
    547 551
             then noHtml
    
    548 552
             else
    
    549 553
               collapseDetails
    
    550
    -            p
    
    554
    +            (LText.pack p)
    
    551 555
                 DetailsOpen
    
    552 556
                 ( thesummary
    
    553 557
                     ! [theclass "hide-when-js-enabled"]
    
    554
    -                << "Submodules"
    
    558
    +                << ("Submodules" :: LText)
    
    555 559
                     +++ mkNodeList pkg qual (s : ss) p ts
    
    556 560
                 )
    
    557 561
     
    
    ... ... @@ -650,10 +654,10 @@ ppJsonIndex odir maybe_source_url maybe_wiki_url unicode pkg qual_opt ifaces ins
    650 654
           | Just item_html <- processExport True links_info unicode pkg qual item =
    
    651 655
               Just
    
    652 656
                 JsonIndexEntry
    
    653
    -              { jieHtmlFragment = showHtmlFragment item_html
    
    657
    +              { jieHtmlFragment = Text.unpack (Text.decodeUtf8Lenient (LBS.toStrict (Builder.toLazyByteString (showHtmlFragment item_html))))
    
    654 658
                   , jieName = unwords (map getOccString names)
    
    655 659
                   , jieModule = moduleString mdl
    
    656
    -              , jieLink = fromMaybe "" (listToMaybe (map (nameLink mdl) names))
    
    660
    +              , jieLink = LText.unpack $ fromMaybe "" (listToMaybe (map (nameLink mdl) names))
    
    657 661
                   }
    
    658 662
           | otherwise = Nothing
    
    659 663
           where
    
    ... ... @@ -668,7 +672,7 @@ ppJsonIndex odir maybe_source_url maybe_wiki_url unicode pkg qual_opt ifaces ins
    668 672
         exportName ExportNoDecl{expItemName} = [expItemName]
    
    669 673
         exportName _ = []
    
    670 674
     
    
    671
    -    nameLink :: NamedThing name => Module -> name -> String
    
    675
    +    nameLink :: NamedThing name => Module -> name -> LText
    
    672 676
         nameLink mdl = moduleNameUrl' (moduleName mdl) . nameOccName . getName
    
    673 677
     
    
    674 678
         links_info = (maybe_source_url, maybe_wiki_url)
    
    ... ... @@ -720,9 +724,9 @@ ppHtmlIndex
    720 724
           mapM_ (do_sub_index index) initialChars
    
    721 725
           -- Let's add a single large index as well for those who don't know exactly what they're looking for:
    
    722 726
           let mergedhtml = indexPage False Nothing index
    
    723
    -      writeUtf8File (joinPath [odir, subIndexHtmlFile merged_name]) (renderToString debug mergedhtml)
    
    727
    +      Builder.writeFile (joinPath [odir, subIndexHtmlFile merged_name]) (renderToBuilder debug mergedhtml)
    
    724 728
     
    
    725
    -    writeUtf8File (joinPath [odir, indexHtmlFile]) (renderToString debug html)
    
    729
    +    Builder.writeFile (joinPath [odir, indexHtmlFile]) (renderToBuilder debug html)
    
    726 730
         where
    
    727 731
           indexPage showLetters ch items =
    
    728 732
             headHtml (doctitle ++ " (" ++ indexName ch ++ ")") themes maybe_mathjax_url Nothing
    
    ... ... @@ -754,7 +758,7 @@ ppHtmlIndex
    754 758
           indexInitialLetterLinks =
    
    755 759
             divAlphabet
    
    756 760
               << unordList
    
    757
    -            ( map (\str -> anchor ! [href (subIndexHtmlFile str)] << str) $
    
    761
    +            ( map (\str -> anchor ! [href (LText.pack $ subIndexHtmlFile str)] << str) $
    
    758 762
                     [ [c] | c <- initialChars, any (indexStartsWith c) index
    
    759 763
                     ]
    
    760 764
                       ++ [merged_name]
    
    ... ... @@ -773,7 +777,7 @@ ppHtmlIndex
    773 777
     
    
    774 778
           do_sub_index this_ix c =
    
    775 779
             unless (null index_part) $
    
    776
    -          writeUtf8File (joinPath [odir, subIndexHtmlFile [c]]) (renderToString debug html)
    
    780
    +          Builder.writeFile (joinPath [odir, subIndexHtmlFile [c]]) (renderToBuilder debug html)
    
    777 781
             where
    
    778 782
               html = indexPage True (Just c) index_part
    
    779 783
               index_part = [(n, stuff) | (n@(headN : _), stuff) <- this_ix, toUpper headN == c]
    
    ... ... @@ -844,9 +848,9 @@ ppHtmlIndex
    844 848
               <-> indexLinks nm entries
    
    845 849
     
    
    846 850
           ppAnnot n
    
    847
    -        | not (isValOcc n) = toHtml "Type/Class"
    
    848
    -        | isDataOcc n = toHtml "Data Constructor"
    
    849
    -        | otherwise = toHtml "Function"
    
    851
    +        | not (isValOcc n) = toHtml ("Type/Class" :: LText)
    
    852
    +        | isDataOcc n = toHtml ("Data Constructor" :: LText)
    
    853
    +        | otherwise = toHtml ("Function" :: LText)
    
    850 854
     
    
    851 855
           indexLinks nm entries =
    
    852 856
             td
    
    ... ... @@ -909,10 +913,10 @@ ppHtmlModule
    909 913
           mdl_str_linked
    
    910 914
             | ifaceIsSig iface =
    
    911 915
                 mdl_str
    
    912
    -              +++ " (signature"
    
    916
    +              +++ (" (signature" :: LText)
    
    913 917
                   +++ sup
    
    914
    -              << ("[" +++ anchor ! [href signatureDocURL] << "?" +++ "]")
    
    915
    -              +++ ")"
    
    918
    +              << (("[" :: LText) +++ anchor ! [href (LText.pack signatureDocURL)] << ("?" :: LText) +++ ("]" :: LText))
    
    919
    +              +++ (")" :: LText)
    
    916 920
             | otherwise =
    
    917 921
                 toHtml mdl_str
    
    918 922
           real_qual = makeModuleQual qual mdl
    
    ... ... @@ -930,7 +934,7 @@ ppHtmlModule
    930 934
                  ]
    
    931 935
     
    
    932 936
         createDirectoryIfMissing True odir
    
    933
    -    writeUtf8File (joinPath [odir, moduleHtmlFile mdl]) (renderToString debug html)
    
    937
    +    Builder.writeFile (joinPath [odir, moduleHtmlFile mdl]) (renderToBuilder debug html)
    
    934 938
     
    
    935 939
     signatureDocURL :: String
    
    936 940
     signatureDocURL = "https://wiki.haskell.org/Module_signature"
    
    ... ... @@ -965,7 +969,7 @@ ifaceToHtml maybe_source_url maybe_wiki_url iface unicode pkg qual =
    965 969
     
    
    966 970
         description
    
    967 971
           | isNoHtml doc = doc
    
    968
    -      | otherwise = divDescription $ sectionName << "Description" +++ doc
    
    972
    +      | otherwise = divDescription $ sectionName << ("Description" :: LText) +++ doc
    
    969 973
           where
    
    970 974
             doc = docSection Nothing pkg qual (ifaceRnDoc iface)
    
    971 975
     
    
    ... ... @@ -978,7 +982,7 @@ ifaceToHtml maybe_source_url maybe_wiki_url iface unicode pkg qual =
    978 982
                   "syn"
    
    979 983
                   DetailsClosed
    
    980 984
                   ( thesummary
    
    981
    -                  << "Synopsis"
    
    985
    +                  << ("Synopsis" :: LText)
    
    982 986
                       +++ shortDeclList
    
    983 987
                         ( mapMaybe (processExport True linksInfo unicode pkg qual) exports
    
    984 988
                         )
    
    ... ... @@ -991,7 +995,7 @@ ifaceToHtml maybe_source_url maybe_wiki_url iface unicode pkg qual =
    991 995
           case exports of
    
    992 996
             [] -> noHtml
    
    993 997
             ExportGroup{} : _ -> noHtml
    
    994
    -        _ -> h1 << "Documentation"
    
    998
    +        _ -> h1 << ("Documentation" :: LText)
    
    995 999
     
    
    996 1000
         bdy =
    
    997 1001
           foldr (+++) noHtml $
    
    ... ... @@ -1017,7 +1021,7 @@ ppModuleContents pkg qual exports orphan
    1017 1021
         contentsDiv =
    
    1018 1022
           divTableOfContents
    
    1019 1023
             << ( divContentsList
    
    1020
    -              << ( (sectionName << "Contents")
    
    1024
    +              << ( (sectionName << ("Contents" :: LText))
    
    1021 1025
                         ! [strAttr "onclick" "window.scrollTo(0,0)"]
    
    1022 1026
                         +++ unordList (sections ++ orphanSection)
    
    1023 1027
                      )
    
    ... ... @@ -1025,7 +1029,7 @@ ppModuleContents pkg qual exports orphan
    1025 1029
     
    
    1026 1030
         (sections, _leftovers {-should be []-}) = process 0 exports
    
    1027 1031
         orphanSection
    
    1028
    -      | orphan = [linkedAnchor "section.orphans" << "Orphan instances"]
    
    1032
    +      | orphan = [linkedAnchor "section.orphans" << ("Orphan instances" :: LText)]
    
    1029 1033
           | otherwise = []
    
    1030 1034
     
    
    1031 1035
         process :: Int -> [ExportItem DocNameI] -> ([Html], [ExportItem DocNameI])
    
    ... ... @@ -1035,7 +1039,7 @@ ppModuleContents pkg qual exports orphan
    1035 1039
           | otherwise = (html : secs, rest2)
    
    1036 1040
           where
    
    1037 1041
             html =
    
    1038
    -          linkedAnchor (groupId id0)
    
    1042
    +          linkedAnchor (groupId (LText.pack id0))
    
    1039 1043
                 << docToHtmlNoAnchors (Just id0) pkg qual (mkMeta doc)
    
    1040 1044
                 +++ mk_subsections ssecs
    
    1041 1045
             (ssecs, rest1) = process lev rest
    
    ... ... @@ -1103,7 +1107,7 @@ processExport
    1103 1107
         ) =
    
    1104 1108
         processDecl summary $ ppDecl summary links decl pats doc insts fixities subdocs splice unicode pkg qual
    
    1105 1109
     processExport summary _ _ pkg qual (ExportGroup lev id0 doc) =
    
    1106
    -  nothingIf summary $ groupHeading lev id0 << docToHtmlNoAnchors (Just id0) pkg qual (mkMeta doc)
    
    1110
    +  nothingIf summary $ groupHeading lev (LText.pack id0) << docToHtmlNoAnchors (Just id0) pkg qual (mkMeta doc)
    
    1107 1111
     processExport summary _ _ _ qual (ExportNoDecl y []) =
    
    1108 1112
       processDeclOneLiner summary $ ppDocName qual Prefix True y
    
    1109 1113
     processExport summary _ _ _ qual (ExportNoDecl y subs) =
    
    ... ... @@ -1113,7 +1117,7 @@ processExport summary _ _ _ qual (ExportNoDecl y subs) =
    1113 1117
     processExport summary _ _ pkg qual (ExportDoc doc) =
    
    1114 1118
       nothingIf summary $ docSection_ Nothing pkg qual doc
    
    1115 1119
     processExport summary _ _ _ _ (ExportModule mdl) =
    
    1116
    -  processDeclOneLiner summary $ toHtml "module" <+> ppModule mdl
    
    1120
    +  processDeclOneLiner summary $ toHtml ("module" :: LText) <+> ppModule mdl
    
    1117 1121
     
    
    1118 1122
     nothingIf :: Bool -> a -> Maybe a
    
    1119 1123
     nothingIf True _ = Nothing
    
    ... ... @@ -1132,7 +1136,7 @@ processDeclOneLiner :: Bool -> Html -> Maybe Html
    1132 1136
     processDeclOneLiner True = Just
    
    1133 1137
     processDeclOneLiner False = Just . divTopDecl . declElem
    
    1134 1138
     
    
    1135
    -groupHeading :: Int -> String -> Html -> Html
    
    1139
    +groupHeading :: Int -> LText -> Html -> Html
    
    1136 1140
     groupHeading lev id0 = linkedAnchor grpId . groupTag lev ! [identifier grpId]
    
    1137 1141
       where
    
    1138 1142
         grpId = groupId id0
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
    ... ... @@ -45,6 +45,7 @@ import Haddock.Backends.Xhtml.Utils
    45 45
     import Haddock.Doc (combineDocumentation)
    
    46 46
     import Haddock.GhcUtils
    
    47 47
     import Haddock.Types
    
    48
    +import qualified Data.Text.Lazy as LText
    
    48 49
     
    
    49 50
     -- | Pretty print a declaration
    
    50 51
     ppDecl
    
    ... ... @@ -352,9 +353,9 @@ ppSubSigLike unicode qual typ argDocs subdocs sep emptyCtxts = do_sig_args 0 sep
    352 353
         -- We need 'gadtComma' and 'gadtEnd' to line up with the `{` from
    
    353 354
         -- 'gadtOpen', so we add 3 spaces to cover for `-> `/`:: ` (3 in unicode
    
    354 355
         -- mode since `->` and `::` are rendered as single characters.
    
    355
    -    gadtComma = concatHtml (replicate (if unicode then 2 else 3) spaceHtml) <> toHtml ","
    
    356
    -    gadtEnd = concatHtml (replicate (if unicode then 2 else 3) spaceHtml) <> toHtml "}"
    
    357
    -    gadtOpen = toHtml "{"
    
    356
    +    gadtComma = concatHtml (replicate (if unicode then 2 else 3) spaceHtml) <> toHtml ("," :: LText)
    
    357
    +    gadtEnd = concatHtml (replicate (if unicode then 2 else 3) spaceHtml) <> toHtml ("}" :: LText)
    
    358
    +    gadtOpen = toHtml ("{" :: LText)
    
    358 359
     
    
    359 360
     ppFixities :: [(DocName, Fixity)] -> Qualification -> Html
    
    360 361
     ppFixities [] _ = noHtml
    
    ... ... @@ -365,7 +366,7 @@ ppFixities fs qual = foldr1 (+++) (map ppFix uniq_fs) +++ rightEdge
    365 366
             ! [theclass "fixity"]
    
    366 367
             << (toHtml d <+> toHtml (show p) <+> ppNames ns)
    
    367 368
     
    
    368
    -    ppDir InfixR = "infixr"
    
    369
    +    ppDir InfixR = ("infixr" :: LText)
    
    369 370
         ppDir InfixL = "infixl"
    
    370 371
         ppDir InfixN = "infix"
    
    371 372
     
    
    ... ... @@ -730,7 +731,7 @@ ppContextNoLocsMaybe :: [HsType DocNameI] -> Unicode -> Qualification -> HideEmp
    730 731
     ppContextNoLocsMaybe [] _ _ emptyCtxts =
    
    731 732
       case emptyCtxts of
    
    732 733
         HideEmptyContexts -> Nothing
    
    733
    -    ShowEmptyToplevelContexts -> Just (toHtml "()")
    
    734
    +    ShowEmptyToplevelContexts -> Just (toHtml ("()" :: LText))
    
    734 735
     ppContextNoLocsMaybe cxt unicode qual _ = Just $ ppHsContext cxt unicode qual
    
    735 736
     
    
    736 737
     ppContext :: HsContext DocNameI -> Unicode -> Qualification -> HideEmptyContexts -> Html
    
    ... ... @@ -1006,13 +1007,13 @@ ppClassDecl
    1006 1007
                   == [getName n' | ClassOpSig _ _ ns _ <- sigs, L _ n' <- ns] ->
    
    1007 1008
                   noHtml
    
    1008 1009
             -- Minimal complete definition = nothing
    
    1009
    -        And [] : _ -> subMinimal $ toHtml "Nothing"
    
    1010
    +        And [] : _ -> subMinimal $ toHtml ("Nothing" :: LText)
    
    1010 1011
             m : _ -> subMinimal $ ppMinimal False m
    
    1011 1012
             _ -> noHtml
    
    1012 1013
     
    
    1013 1014
           ppMinimal _ (Var (L _ n)) = ppDocName qual Prefix True n
    
    1014
    -      ppMinimal _ (And fs) = foldr1 (\a b -> a +++ ", " +++ b) $ map (ppMinimal True . unLoc) fs
    
    1015
    -      ppMinimal p (Or fs) = wrap $ foldr1 (\a b -> a +++ " | " +++ b) $ map (ppMinimal False . unLoc) fs
    
    1015
    +      ppMinimal _ (And fs) = foldr1 (\a b -> a +++ (", " :: LText) +++ b) $ map (ppMinimal True . unLoc) fs
    
    1016
    +      ppMinimal p (Or fs) = wrap $ foldr1 (\a b -> a +++ (" | " :: LText) +++ b) $ map (ppMinimal False . unLoc) fs
    
    1016 1017
             where
    
    1017 1018
               wrap | p = parens | otherwise = id
    
    1018 1019
           ppMinimal p (Parens x) = ppMinimal p (unLoc x)
    
    ... ... @@ -1115,7 +1116,7 @@ ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead{..}) md
    1115 1116
             pdecl = pdata <+> ppShortDataDecl False True dd [] unicode qual
    
    1116 1117
         DataInst {} -> error "ppInstHead"
    
    1117 1118
       where
    
    1118
    -    mname = maybe noHtml (\m -> toHtml "Defined in" <+> ppModule m) mdl
    
    1119
    +    mname = maybe noHtml (\m -> toHtml ("Defined in" :: LText) <+> ppModule m) mdl
    
    1119 1120
         iid = instanceId origin no orphan ihd
    
    1120 1121
         typ = ppAppNameTypes ihdClsName ihdTypes unicode qual
    
    1121 1122
     
    
    ... ... @@ -1163,9 +1164,9 @@ ppInstanceSigs links splice unicode qual sigs = do
    1163 1164
     lookupAnySubdoc :: Eq id1 => id1 -> [(id1, DocForDecl id2)] -> DocForDecl id2
    
    1164 1165
     lookupAnySubdoc n = Maybe.fromMaybe noDocForDecl . lookup n
    
    1165 1166
     
    
    1166
    -instanceId :: InstOrigin DocName -> Int -> Bool -> InstHead DocNameI -> String
    
    1167
    +instanceId :: InstOrigin DocName -> Int -> Bool -> InstHead DocNameI -> LText
    
    1167 1168
     instanceId origin no orphan ihd =
    
    1168
    -  concat $
    
    1169
    +  LText.pack $ concat $
    
    1169 1170
         ["o:" | orphan]
    
    1170 1171
           ++ [ qual origin
    
    1171 1172
              , ":" ++ getOccString origin
    
    ... ... @@ -1529,7 +1530,7 @@ ppConstrHdr forall_ tvs ctxt unicode qual = ppForall +++ ppCtxt
    1529 1530
           | otherwise =
    
    1530 1531
               ppContextNoArrow ctxt unicode qual HideEmptyContexts
    
    1531 1532
                 <+> darrow unicode
    
    1532
    -            +++ toHtml " "
    
    1533
    +            +++ toHtml (" " :: LText)
    
    1533 1534
     
    
    1534 1535
     -- | Pretty-print a record field
    
    1535 1536
     ppSideBySideField
    
    ... ... @@ -1564,7 +1565,7 @@ ppSideBySideField subdocs unicode qual (HsConDeclRecField _ names ltype) =
    1564 1565
     ppRecFieldMultAnn :: Unicode -> Qualification -> HsConDeclField DocNameI -> Html
    
    1565 1566
     ppRecFieldMultAnn unicode qual (CDF { cdf_multiplicity = ann }) = case ann of
    
    1566 1567
       HsUnannotated _ -> noHtml
    
    1567
    -  HsLinearAnn _ -> toHtml "%1"
    
    1568
    +  HsLinearAnn _ -> toHtml ("%1" :: LText)
    
    1568 1569
       HsExplicitMult _ mult -> multAnnotation <> ppr_mono_lty mult unicode qual HideEmptyContexts
    
    1569 1570
     
    
    1570 1571
     ppShortField :: Bool -> Unicode -> Qualification -> HsConDeclRecField DocNameI -> Html
    
    ... ... @@ -1668,8 +1669,8 @@ ppDataHeader _ _ _ _ = error "ppDataHeader: illegal argument"
    1668 1669
     --------------------------------------------------------------------------------
    
    1669 1670
     
    
    1670 1671
     ppBang :: HsSrcBang -> Html
    
    1671
    -ppBang (HsSrcBang _ _ SrcStrict) = toHtml "!"
    
    1672
    -ppBang (HsSrcBang _ _ SrcLazy) = toHtml "~"
    
    1672
    +ppBang (HsSrcBang _ _ SrcStrict) = toHtml ("!" :: LText)
    
    1673
    +ppBang (HsSrcBang _ _ SrcLazy) = toHtml ("~" :: LText)
    
    1673 1674
     ppBang _ = noHtml
    
    1674 1675
     
    
    1675 1676
     tupleParens :: HsTupleSort -> [Html] -> Html
    
    ... ... @@ -1707,7 +1708,7 @@ ppSigType unicode qual emptyCtxts sig_ty = ppr_sig_ty (reparenSigType sig_ty) un
    1707 1708
     ppLHsTypeArg :: Unicode -> Qualification -> HideEmptyContexts -> LHsTypeArg DocNameI -> Html
    
    1708 1709
     ppLHsTypeArg unicode qual emptyCtxts (HsValArg _ ty) = ppLParendType unicode qual emptyCtxts ty
    
    1709 1710
     ppLHsTypeArg unicode qual emptyCtxts (HsTypeArg _ ki) = atSign <> ppLParendType unicode qual emptyCtxts ki
    
    1710
    -ppLHsTypeArg _ _ _ (HsArgPar _) = toHtml ""
    
    1711
    +ppLHsTypeArg _ _ _ (HsArgPar _) = toHtml ("" :: LText)
    
    1711 1712
     
    
    1712 1713
     class RenderableBndrFlag flag where
    
    1713 1714
       ppHsTyVarBndr :: Unicode -> Qualification -> HsTyVarBndr flag DocNameI -> Html
    
    ... ... @@ -1814,12 +1815,12 @@ ppr_mono_ty (HsQualTy _ ctxt ty) unicode qual emptyCtxts =
    1814 1815
       ppLContext (Just ctxt) unicode qual emptyCtxts <+> ppr_mono_lty ty unicode qual emptyCtxts
    
    1815 1816
     -- UnicodeSyntax alternatives
    
    1816 1817
     ppr_mono_ty (HsTyVar _ _ (L _ name)) True _ _
    
    1817
    -  | getOccString (getName name) == "(->)" = toHtml "(→)"
    
    1818
    +  | getOccString (getName name) == "(->)" = toHtml ("(→)" :: LText)
    
    1818 1819
     ppr_mono_ty (HsTyVar _ prom (L _ name)) _ q _
    
    1819 1820
       | isPromoted prom = promoQuote (ppDocName q Prefix True name)
    
    1820 1821
       | otherwise = ppDocName q Prefix True name
    
    1821 1822
     ppr_mono_ty (HsStarTy _ isUni) u _ _ =
    
    1822
    -  toHtml (if u || isUni then "★" else "*")
    
    1823
    +  toHtml (if u || isUni then "★" else "*" :: LText)
    
    1823 1824
     ppr_mono_ty (HsFunTy _ mult ty1 ty2) u q e =
    
    1824 1825
       hsep
    
    1825 1826
         [ ppr_mono_lty ty1 u q HideEmptyContexts
    
    ... ... @@ -1842,7 +1843,7 @@ ppr_mono_ty (HsIParamTy _ (L _ n) ty) u q _ =
    1842 1843
     ppr_mono_ty (HsSpliceTy v _) _ _ _ = dataConCantHappen v
    
    1843 1844
     ppr_mono_ty (XHsType (HsBangTy b ty)) u q _ =
    
    1844 1845
       ppBang b +++ ppLParendType u q HideEmptyContexts ty
    
    1845
    -ppr_mono_ty (XHsType (HsRecTy{})) _ _ _ = toHtml "{..}"
    
    1846
    +ppr_mono_ty (XHsType (HsRecTy{})) _ _ _ = toHtml ("{..}" :: LText)
    
    1846 1847
     -- Can now legally occur in ConDeclGADT, the output here is to provide a
    
    1847 1848
     -- placeholder in the signature, which is followed by the field
    
    1848 1849
     -- declarations.
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/DocMarkup.hs
    ... ... @@ -39,6 +39,7 @@ import Haddock.Doc
    39 39
       )
    
    40 40
     import Haddock.Types
    
    41 41
     import Haddock.Utils
    
    42
    +import qualified Data.Text.Lazy as LText
    
    42 43
     
    
    43 44
     parHtmlMarkup
    
    44 45
       :: Qualification
    
    ... ... @@ -60,7 +61,7 @@ parHtmlMarkup qual insertAnchors ppId =
    60 61
                 mdl' = case reverse mdl of
    
    61 62
                   '\\' : _ -> init mdl
    
    62 63
                   _ -> mdl
    
    63
    -         in ppModuleRef lbl (mkModuleName mdl') ref
    
    64
    +         in ppModuleRef lbl (mkModuleName mdl') (LText.pack ref)
    
    64 65
         , markupWarning = thediv ! [theclass "warning"]
    
    65 66
         , markupEmphasis = emphasize
    
    66 67
         , markupBold = strong
    
    ... ... @@ -73,14 +74,14 @@ parHtmlMarkup qual insertAnchors ppId =
    73 74
             if insertAnchors
    
    74 75
               then
    
    75 76
                 anchor
    
    76
    -              ! [href url]
    
    77
    +              ! [href (LText.pack url)]
    
    77 78
                   << fromMaybe (toHtml url) mLabel
    
    78 79
               else fromMaybe (toHtml url) mLabel
    
    79 80
         , markupAName = \aname ->
    
    80 81
             if insertAnchors
    
    81
    -          then namedAnchor aname << ""
    
    82
    +          then namedAnchor (LText.pack aname) << ("" :: LText.Text)
    
    82 83
               else noHtml
    
    83
    -    , markupPic = \(Picture uri t) -> image ! ([src uri] ++ fromMaybe [] (return . title <$> t))
    
    84
    +    , markupPic = \(Picture uri t) -> image ! ([src (LText.pack uri)] ++ fromMaybe [] (return . title <$> (LText.pack <$> t)))
    
    84 85
         , markupMathInline = \mathjax -> thespan ! [theclass "mathjax"] << toHtml ("\\(" ++ mathjax ++ "\\)")
    
    85 86
         , markupMathDisplay = \mathjax -> thespan ! [theclass "mathjax"] << toHtml ("\\[" ++ mathjax ++ "\\]")
    
    86 87
         , markupProperty = pre . toHtml
    
    ... ... @@ -121,7 +122,7 @@ parHtmlMarkup qual insertAnchors ppId =
    121 122
         exampleToHtml (Example expression result) = htmlExample
    
    122 123
           where
    
    123 124
             htmlExample = htmlPrompt +++ htmlExpression +++ toHtml (unlines result)
    
    124
    -        htmlPrompt = (thecode . toHtml $ ">>> ") ! [theclass "prompt"]
    
    125
    +        htmlPrompt = (thecode . toHtml $ (">>> " :: LText.Text)) ! [theclass "prompt"]
    
    125 126
             htmlExpression = (strong . thecode . toHtml $ expression ++ "\n") ! [theclass "userinput"]
    
    126 127
     
    
    127 128
         makeOrdList :: HTML a => [(Int, a)] -> Html
    
    ... ... @@ -204,9 +205,9 @@ hackMarkup fmt' currPkg h' =
    204 205
         hackMarkup' fmt h = case h of
    
    205 206
           UntouchedDoc d -> (markup fmt $ _doc d, [_meta d])
    
    206 207
           CollapsingHeader (Header lvl titl) par n nm ->
    
    207
    -        let id_ = makeAnchorId $ "ch:" ++ fromMaybe "noid:" nm ++ show n
    
    208
    +        let id_ = makeAnchorId $ "ch:" <> fromMaybe "noid:" (LText.pack <$> nm) <> LText.pack (show n)
    
    208 209
                 col' = collapseControl id_ "subheading"
    
    209
    -            summary = thesummary ! [theclass "hide-when-js-enabled"] << "Expand"
    
    210
    +            summary = thesummary ! [theclass "hide-when-js-enabled"] << ("Expand" :: LText.Text)
    
    210 211
                 instTable contents = collapseDetails id_ DetailsClosed (summary +++ contents)
    
    211 212
                 lvs = zip [1 ..] [h1, h2, h3, h4, h5, h6]
    
    212 213
                 getHeader = fromMaybe caption (lookup lvl lvs)
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs
    ... ... @@ -63,6 +63,7 @@ import Haddock.Backends.Xhtml.Types
    63 63
     import Haddock.Backends.Xhtml.Utils
    
    64 64
     import Haddock.Types
    
    65 65
     import Haddock.Utils (makeAnchorId, nameAnchorId)
    
    66
    +import qualified Data.Text.Lazy as LText
    
    66 67
     
    
    67 68
     --------------------------------------------------------------------------------
    
    68 69
     
    
    ... ... @@ -73,7 +74,7 @@ import Haddock.Utils (makeAnchorId, nameAnchorId)
    73 74
     miniBody :: Html -> Html
    
    74 75
     miniBody = body ! [identifier "mini"]
    
    75 76
     
    
    76
    -sectionDiv :: String -> Html -> Html
    
    77
    +sectionDiv :: LText -> Html -> Html
    
    77 78
     sectionDiv i = thediv ! [identifier i]
    
    78 79
     
    
    79 80
     sectionName :: Html -> Html
    
    ... ... @@ -138,11 +139,11 @@ divTopDecl = thediv ! [theclass "top"]
    138 139
     
    
    139 140
     type SubDecl = (Html, Maybe (MDoc DocName), [Html])
    
    140 141
     
    
    141
    -divSubDecls :: HTML a => String -> a -> Maybe Html -> Html
    
    142
    +divSubDecls :: LText -> LText -> Maybe Html -> Html
    
    142 143
     divSubDecls cssClass captionName = maybe noHtml wrap
    
    143 144
       where
    
    144 145
         wrap = (subSection <<) . (subCaption +++)
    
    145
    -    subSection = thediv ! [theclass $ unwords ["subs", cssClass]]
    
    146
    +    subSection = thediv ! [theclass $ LText.unwords ["subs", cssClass]]
    
    146 147
         subCaption = paragraph ! [theclass "caption"] << captionName
    
    147 148
     
    
    148 149
     subDlist :: Maybe Package -> Qualification -> [SubDecl] -> Maybe Html
    
    ... ... @@ -232,9 +233,9 @@ subInstances pkg qual nm lnks splice = maybe noHtml wrap . instTable
    232 233
         wrap contents = subSection (hdr +++ collapseDetails id_ DetailsOpen (summary +++ contents))
    
    233 234
         instTable = subTableSrc pkg qual lnks splice
    
    234 235
         subSection = thediv ! [theclass "subs instances"]
    
    235
    -    hdr = h4 ! collapseControl id_ "instances" << "Instances"
    
    236
    -    summary = thesummary ! [theclass "hide-when-js-enabled"] << "Instances details"
    
    237
    -    id_ = makeAnchorId $ "i:" ++ nm
    
    236
    +    hdr = h4 ! collapseControl id_ "instances" << ("Instances" :: LText)
    
    237
    +    summary = thesummary ! [theclass "hide-when-js-enabled"] << ("Instances details" :: LText)
    
    238
    +    id_ = makeAnchorId $ "i:" <> (LText.pack nm)
    
    238 239
     
    
    239 240
     subOrphanInstances
    
    240 241
       :: Maybe Package
    
    ... ... @@ -245,12 +246,12 @@ subOrphanInstances
    245 246
       -> Html
    
    246 247
     subOrphanInstances pkg qual lnks splice = maybe noHtml wrap . instTable
    
    247 248
       where
    
    248
    -    wrap = ((h1 << "Orphan instances") +++)
    
    249
    -    instTable = fmap (thediv ! [identifier ("section." ++ id_)] <<) . subTableSrc pkg qual lnks splice
    
    249
    +    wrap = ((h1 << ("Orphan instances" :: LText)) +++)
    
    250
    +    instTable = fmap (thediv ! [identifier ("section." <> id_)] <<) . subTableSrc pkg qual lnks splice
    
    250 251
         id_ = makeAnchorId "orphans"
    
    251 252
     
    
    252 253
     subInstHead
    
    253
    -  :: String
    
    254
    +  :: LText
    
    254 255
       -- ^ Instance unique id (for anchor generation)
    
    255 256
       -> Html
    
    256 257
       -- ^ Header content (instance name and type)
    
    ... ... @@ -261,7 +262,7 @@ subInstHead iid hdr =
    261 262
         expander = thespan ! collapseControl (instAnchorId iid) "instance"
    
    262 263
     
    
    263 264
     subInstDetails
    
    264
    -  :: String
    
    265
    +  :: LText
    
    265 266
       -- ^ Instance unique id (for anchor generation)
    
    266 267
       -> [Html]
    
    267 268
       -- ^ Associated type contents
    
    ... ... @@ -274,7 +275,7 @@ subInstDetails iid ats mets mdl =
    274 275
       subInstSection iid << (p mdl <+> subAssociatedTypes ats <+> subMethods mets)
    
    275 276
     
    
    276 277
     subFamInstDetails
    
    277
    -  :: String
    
    278
    +  :: LText
    
    278 279
       -- ^ Instance unique id (for anchor generation)
    
    279 280
       -> Html
    
    280 281
       -- ^ Type or data family instance
    
    ... ... @@ -285,16 +286,16 @@ subFamInstDetails iid fi mdl =
    285 286
       subInstSection iid << (p mdl <+> (thediv ! [theclass "src"] << fi))
    
    286 287
     
    
    287 288
     subInstSection
    
    288
    -  :: String
    
    289
    +  :: LText
    
    289 290
       -- ^ Instance unique id (for anchor generation)
    
    290 291
       -> Html
    
    291 292
       -> Html
    
    292 293
     subInstSection iid contents = collapseDetails (instAnchorId iid) DetailsClosed (summary +++ contents)
    
    293 294
       where
    
    294
    -    summary = thesummary ! [theclass "hide-when-js-enabled"] << "Instance details"
    
    295
    +    summary = thesummary ! [theclass "hide-when-js-enabled"] << ("Instance details" :: LText)
    
    295 296
     
    
    296
    -instAnchorId :: String -> String
    
    297
    -instAnchorId iid = makeAnchorId $ "i:" ++ iid
    
    297
    +instAnchorId :: LText -> LText
    
    298
    +instAnchorId iid = makeAnchorId $ "i:" <> iid
    
    298 299
     
    
    299 300
     subMethods :: [Html] -> Html
    
    300 301
     subMethods = divSubDecls "methods" "Methods" . subBlock
    
    ... ... @@ -321,7 +322,7 @@ topDeclElem lnks loc splice name html =
    321 322
     -- Name must be documented, otherwise we wouldn't get here.
    
    322 323
     links :: LinksInfo -> SrcSpan -> Bool -> Maybe Module -> DocName -> Html
    
    323 324
     links ((_, _, sourceMap, lineMap), (_, _, maybe_wiki_url)) loc splice mdl' docName@(Documented n mdl) =
    
    324
    -  srcLink <+> wikiLink <+> (selfLink ! [theclass "selflink"] << "#")
    
    325
    +  srcLink <+> wikiLink <+> (selfLink ! [theclass "selflink"] << ("#" :: LText))
    
    325 326
       where
    
    326 327
         selfLink = linkedAnchor (nameAnchorId (nameOccName (getName docName)))
    
    327 328
     
    
    ... ... @@ -335,15 +336,15 @@ links ((_, _, sourceMap, lineMap), (_, _, maybe_wiki_url)) loc splice mdl' docNa
    335 336
            in case mUrl of
    
    336 337
                 Nothing -> noHtml
    
    337 338
                 Just url ->
    
    338
    -              let url' = spliceURL (Just origMod) (Just n) (Just loc) url
    
    339
    -               in anchor ! [href url', theclass "link"] << "Source"
    
    339
    +              let url' = LText.pack $ spliceURL (Just origMod) (Just n) (Just loc) url
    
    340
    +               in anchor ! [href url', theclass "link"] << ("Source" :: LText)
    
    340 341
     
    
    341 342
         wikiLink =
    
    342 343
           case maybe_wiki_url of
    
    343 344
             Nothing -> noHtml
    
    344 345
             Just url ->
    
    345
    -          let url' = spliceURL (Just mdl) (Just n) (Just loc) url
    
    346
    -           in anchor ! [href url', theclass "link"] << "Comments"
    
    346
    +          let url' = LText.pack $ spliceURL (Just mdl) (Just n) (Just loc) url
    
    347
    +           in anchor ! [href url', theclass "link"] << ("Comments" :: LText)
    
    347 348
     
    
    348 349
         -- For source links, we want to point to the original module,
    
    349 350
         -- because only that will have the source.
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Names.hs
    ... ... @@ -41,6 +41,7 @@ import Haddock.Backends.Xhtml.Utils
    41 41
     import Haddock.GhcUtils
    
    42 42
     import Haddock.Types
    
    43 43
     import Haddock.Utils
    
    44
    +import qualified Data.Text.Lazy as LText
    
    44 45
     
    
    45 46
     -- | Indicator of how to render a 'DocName' into 'Html'
    
    46 47
     data Notation
    
    ... ... @@ -171,7 +172,7 @@ linkIdOcc mdl mbName insertAnchors =
    171 172
         then anchor ! [href url, title ttl]
    
    172 173
         else id
    
    173 174
       where
    
    174
    -    ttl = moduleNameString (moduleName mdl)
    
    175
    +    ttl = LText.pack (moduleNameString (moduleName mdl))
    
    175 176
         url = case mbName of
    
    176 177
           Nothing -> moduleUrl mdl
    
    177 178
           Just name -> moduleNameUrl mdl name
    
    ... ... @@ -179,9 +180,9 @@ linkIdOcc mdl mbName insertAnchors =
    179 180
     linkIdOcc' :: ModuleName -> Maybe OccName -> Html -> Html
    
    180 181
     linkIdOcc' mdl mbName = anchor ! [href url, title ttl]
    
    181 182
       where
    
    182
    -    ttl = moduleNameString mdl
    
    183
    +    ttl = LText.pack (moduleNameString mdl)
    
    183 184
         url = case mbName of
    
    184
    -      Nothing -> moduleHtmlFile' mdl
    
    185
    +      Nothing -> LText.pack (moduleHtmlFile' mdl)
    
    185 186
           Just name -> moduleNameUrl' mdl name
    
    186 187
     
    
    187 188
     ppModule :: Module -> Html
    
    ... ... @@ -190,14 +191,14 @@ ppModule mdl =
    190 191
         ! [href (moduleUrl mdl)]
    
    191 192
         << toHtml (moduleString mdl)
    
    192 193
     
    
    193
    -ppModuleRef :: Maybe Html -> ModuleName -> String -> Html
    
    194
    +ppModuleRef :: Maybe Html -> ModuleName -> LText -> Html
    
    194 195
     ppModuleRef Nothing mdl ref =
    
    195 196
       anchor
    
    196
    -    ! [href (moduleHtmlFile' mdl ++ ref)]
    
    197
    +    ! [href (LText.pack (moduleHtmlFile' mdl) <> ref)]
    
    197 198
         << toHtml (moduleNameString mdl)
    
    198 199
     ppModuleRef (Just lbl) mdl ref =
    
    199 200
       anchor
    
    200
    -    ! [href (moduleHtmlFile' mdl ++ ref)]
    
    201
    +    ! [href (LText.pack (moduleHtmlFile' mdl) <> ref)]
    
    201 202
         << lbl
    
    202 203
     
    
    203 204
     -- NB: The ref parameter already includes the '#'.
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Themes.hs
    ... ... @@ -27,6 +27,7 @@ import System.Directory
    27 27
     import System.FilePath
    
    28 28
     import Text.XHtml hiding (name, p, quote, title, (</>))
    
    29 29
     import qualified Text.XHtml as XHtml
    
    30
    +import qualified Data.Text.Lazy as LText
    
    30 31
     
    
    31 32
     import Haddock.Backends.Xhtml.Types (BaseURL, withBaseURL)
    
    32 33
     import Haddock.Options
    
    ... ... @@ -185,10 +186,10 @@ styleSheet base_url ts = toHtml $ zipWith mkLink rels ts
    185 186
         rels = "stylesheet" : repeat "alternate stylesheet"
    
    186 187
         mkLink aRel t =
    
    187 188
           thelink
    
    188
    -        ! [ href (withBaseURL base_url (themeHref t))
    
    189
    +        ! [ href (LText.pack (withBaseURL base_url (themeHref t)))
    
    189 190
               , rel aRel
    
    190 191
               , thetype "text/css"
    
    191
    -          , XHtml.title (themeName t)
    
    192
    +          , XHtml.title (LText.pack (themeName t))
    
    192 193
               ]
    
    193 194
             << noHtml
    
    194 195
     
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs
    ... ... @@ -13,7 +13,7 @@
    13 13
     -- Stability   :  experimental
    
    14 14
     -- Portability :  portable
    
    15 15
     module Haddock.Backends.Xhtml.Utils
    
    16
    -  ( renderToString
    
    16
    +  ( renderToBuilder
    
    17 17
       , namedAnchor
    
    18 18
       , linkedAnchor
    
    19 19
       , spliceURL
    
    ... ... @@ -58,6 +58,7 @@ import GHC.Types.Name (getOccString, isValOcc, nameOccName)
    58 58
     import GHC.Unit.Module (Module, ModuleName, moduleName, moduleNameString)
    
    59 59
     import Text.XHtml hiding (name, p, quote, title)
    
    60 60
     import qualified Text.XHtml as XHtml
    
    61
    +import qualified Data.Text.Lazy as LText
    
    61 62
     
    
    62 63
     import Haddock.Utils
    
    63 64
     
    
    ... ... @@ -118,8 +119,8 @@ spliceURL' maybe_mod maybe_name maybe_loc = run
    118 119
         run ('%' : '{' : 'L' : 'I' : 'N' : 'E' : '}' : rest) = line ++ run rest
    
    119 120
         run (c : rest) = c : run rest
    
    120 121
     
    
    121
    -renderToString :: Bool -> Html -> String
    
    122
    -renderToString debug html
    
    122
    +renderToBuilder :: Bool -> Html -> Builder
    
    123
    +renderToBuilder debug html
    
    123 124
       | debug = renderHtml html
    
    124 125
       | otherwise = showHtml html
    
    125 126
     
    
    ... ... @@ -136,7 +137,7 @@ infixr 8 <+>
    136 137
     (<+>) :: Html -> Html -> Html
    
    137 138
     a <+> b = a +++ sep +++ b
    
    138 139
       where
    
    139
    -    sep = if isNoHtml a || isNoHtml b then noHtml else toHtml " "
    
    140
    +    sep = if isNoHtml a || isNoHtml b then noHtml else toHtml (" " :: LText)
    
    140 141
     
    
    141 142
     -- | Join two 'Html' values together with a linebreak in between.
    
    142 143
     --   Has 'noHtml' as left identity.
    
    ... ... @@ -167,7 +168,7 @@ promoQuote h = char '\'' +++ h
    167 168
     parens, brackets, pabrackets, braces :: Html -> Html
    
    168 169
     parens h = char '(' +++ h +++ char ')'
    
    169 170
     brackets h = char '[' +++ h +++ char ']'
    
    170
    -pabrackets h = toHtml "[:" +++ h +++ toHtml ":]"
    
    171
    +pabrackets h = toHtml ("[:" :: LText) +++ h +++ toHtml (":]" :: LText)
    
    171 172
     braces h = char '{' +++ h +++ char '}'
    
    172 173
     
    
    173 174
     punctuate :: Html -> [Html] -> [Html]
    
    ... ... @@ -188,37 +189,37 @@ ubxParenList :: [Html] -> Html
    188 189
     ubxParenList = ubxparens . hsep . punctuate comma
    
    189 190
     
    
    190 191
     ubxSumList :: [Html] -> Html
    
    191
    -ubxSumList = ubxparens . hsep . punctuate (toHtml " | ")
    
    192
    +ubxSumList = ubxparens . hsep . punctuate (toHtml (" | " :: LText))
    
    192 193
     
    
    193 194
     ubxparens :: Html -> Html
    
    194
    -ubxparens h = toHtml "(#" <+> h <+> toHtml "#)"
    
    195
    +ubxparens h = toHtml ("(#" :: LText) <+> h <+> toHtml ("#)" :: LText)
    
    195 196
     
    
    196 197
     dcolon, arrow, lollipop, darrow, forallSymbol :: Bool -> Html
    
    197
    -dcolon unicode = toHtml (if unicode then "∷" else "::")
    
    198
    -arrow unicode = toHtml (if unicode then "→" else "->")
    
    199
    -lollipop unicode = toHtml (if unicode then "⊸" else "%1 ->")
    
    200
    -darrow unicode = toHtml (if unicode then "⇒" else "=>")
    
    201
    -forallSymbol unicode = if unicode then toHtml "∀" else keyword "forall"
    
    198
    +dcolon unicode = toHtml (if unicode then "∷" :: LText else "::")
    
    199
    +arrow unicode = toHtml (if unicode then "→" :: LText else "->")
    
    200
    +lollipop unicode = toHtml (if unicode then "⊸" :: LText else "%1 ->")
    
    201
    +darrow unicode = toHtml (if unicode then "⇒" :: LText else "=>")
    
    202
    +forallSymbol unicode = if unicode then toHtml ("∀" :: LText) else keyword "forall"
    
    202 203
     
    
    203 204
     atSign :: Html
    
    204
    -atSign = toHtml "@"
    
    205
    +atSign = toHtml ("@" :: LText)
    
    205 206
     
    
    206 207
     multAnnotation :: Html
    
    207
    -multAnnotation = toHtml "%"
    
    208
    +multAnnotation = toHtml ("%" :: LText)
    
    208 209
     
    
    209 210
     dot :: Html
    
    210
    -dot = toHtml "."
    
    211
    +dot = toHtml ("." :: LText)
    
    211 212
     
    
    212 213
     -- | Generate a named anchor
    
    213
    -namedAnchor :: String -> Html -> Html
    
    214
    +namedAnchor :: LText -> Html -> Html
    
    214 215
     namedAnchor n = anchor ! [XHtml.identifier n]
    
    215 216
     
    
    216
    -linkedAnchor :: String -> Html -> Html
    
    217
    -linkedAnchor n = anchor ! [href ('#' : n)]
    
    217
    +linkedAnchor :: LText -> Html -> Html
    
    218
    +linkedAnchor n = anchor ! [href ("#" <> n)]
    
    218 219
     
    
    219 220
     -- | generate an anchor identifier for a group
    
    220
    -groupId :: String -> String
    
    221
    -groupId g = makeAnchorId ("g:" ++ g)
    
    221
    +groupId :: LText -> LText
    
    222
    +groupId g = makeAnchorId ("g:" <> g)
    
    222 223
     
    
    223 224
     --
    
    224 225
     -- A section of HTML which is collapsible.
    
    ... ... @@ -226,7 +227,7 @@ groupId g = makeAnchorId ("g:" ++ g)
    226 227
     
    
    227 228
     data DetailsState = DetailsOpen | DetailsClosed
    
    228 229
     
    
    229
    -collapseDetails :: String -> DetailsState -> Html -> Html
    
    230
    +collapseDetails :: LText -> DetailsState -> Html -> Html
    
    230 231
     collapseDetails id_ state = tag "details" ! (identifier id_ : openAttrs)
    
    231 232
       where
    
    232 233
         openAttrs = case state of DetailsOpen -> [emptyAttr "open"]; DetailsClosed -> []
    
    ... ... @@ -235,14 +236,14 @@ thesummary :: Html -> Html
    235 236
     thesummary = tag "summary"
    
    236 237
     
    
    237 238
     -- | Attributes for an area that toggles a collapsed area
    
    238
    -collapseToggle :: String -> String -> [HtmlAttr]
    
    239
    +collapseToggle :: LText -> LText -> [HtmlAttr]
    
    239 240
     collapseToggle id_ classes = [theclass cs, strAttr "data-details-id" id_]
    
    240 241
       where
    
    241
    -    cs = unwords (words classes ++ ["details-toggle"])
    
    242
    +    cs = LText.unwords (LText.words classes <> ["details-toggle"])
    
    242 243
     
    
    243 244
     -- | Attributes for an area that toggles a collapsed area,
    
    244 245
     -- and displays a control.
    
    245
    -collapseControl :: String -> String -> [HtmlAttr]
    
    246
    +collapseControl :: LText -> LText -> [HtmlAttr]
    
    246 247
     collapseControl id_ classes = collapseToggle id_ cs
    
    247 248
       where
    
    248
    -    cs = unwords (words classes ++ ["details-toggle-control"])
    249
    +    cs = LText.unwords (LText.words classes <> ["details-toggle-control"])

  • utils/haddock/haddock-api/src/Haddock/Doc.hs
    ... ... @@ -32,7 +32,7 @@ combineDocumentation (Documentation mDoc mWarning) =
    32 32
     --
    
    33 33
     docCodeBlock :: DocH mod id -> DocH mod id
    
    34 34
     docCodeBlock (DocString s) =
    
    35
    -  DocString (reverse $ dropWhile (`elem` " \t") $ reverse s)
    
    35
    +  DocString (reverse $ dropWhile (`elem` (" \t" :: String)) $ reverse s)
    
    36 36
     docCodeBlock (DocAppend l r) =
    
    37 37
       DocAppend l (docCodeBlock r)
    
    38 38
     docCodeBlock d = d

  • utils/haddock/haddock-api/src/Haddock/Utils.hs
    ... ... @@ -83,6 +83,8 @@ import System.IO.Unsafe (unsafePerformIO)
    83 83
     
    
    84 84
     import Documentation.Haddock.Doc (emptyMetaDoc)
    
    85 85
     import Haddock.Types
    
    86
    +import Data.Text.Lazy (Text)
    
    87
    +import qualified Data.Text.Lazy as LText
    
    86 88
     
    
    87 89
     --------------------------------------------------------------------------------
    
    88 90
     
    
    ... ... @@ -184,35 +186,43 @@ subIndexHtmlFile ls = "doc-index-" ++ b ++ ".html"
    184 186
     -- before being matched with IDs in the target document.
    
    185 187
     -------------------------------------------------------------------------------
    
    186 188
     
    
    187
    -moduleUrl :: Module -> String
    
    188
    -moduleUrl = moduleHtmlFile
    
    189
    +moduleUrl :: Module -> Text
    
    190
    +moduleUrl module_ = LText.pack (moduleHtmlFile module_)
    
    189 191
     
    
    190
    -moduleNameUrl :: Module -> OccName -> String
    
    191
    -moduleNameUrl mdl n = moduleUrl mdl ++ '#' : nameAnchorId n
    
    192
    +moduleNameUrl :: Module -> OccName -> Text
    
    193
    +moduleNameUrl mdl n = moduleUrl mdl <> "#" <> nameAnchorId n
    
    192 194
     
    
    193
    -moduleNameUrl' :: ModuleName -> OccName -> String
    
    194
    -moduleNameUrl' mdl n = moduleHtmlFile' mdl ++ '#' : nameAnchorId n
    
    195
    +moduleNameUrl' :: ModuleName -> OccName -> Text
    
    196
    +moduleNameUrl' mdl n = LText.pack (moduleHtmlFile' mdl) <> "#" <> nameAnchorId n
    
    195 197
     
    
    196
    -nameAnchorId :: OccName -> String
    
    197
    -nameAnchorId name = makeAnchorId (prefix : ':' : occNameString name)
    
    198
    +nameAnchorId :: OccName -> Text
    
    199
    +nameAnchorId name = makeAnchorId (prefix <> ":" <> LText.pack (occNameString name))
    
    198 200
       where
    
    199 201
         prefix
    
    200
    -      | isValOcc name = 'v'
    
    201
    -      | otherwise = 't'
    
    202
    +      | isValOcc name = "v"
    
    203
    +      | otherwise = "t"
    
    202 204
     
    
    203 205
     -- | Takes an arbitrary string and makes it a valid anchor ID. The mapping is
    
    204 206
     -- identity preserving.
    
    205
    -makeAnchorId :: String -> String
    
    206
    -makeAnchorId [] = []
    
    207
    -makeAnchorId (f : r) = escape isAlpha f ++ concatMap (escape isLegal) r
    
    207
    +makeAnchorId :: Text -> Text
    
    208
    +makeAnchorId input =
    
    209
    +    case LText.uncons input of
    
    210
    +        Nothing        -> LText.empty
    
    211
    +        Just (f, rest) ->
    
    212
    +            escape isAlpha f <> LText.concatMap (escape isLegal) rest
    
    208 213
       where
    
    214
    +    escape :: (Char -> Bool) -> Char -> Text
    
    209 215
         escape p c
    
    210
    -      | p c = [c]
    
    211
    -      | otherwise = '-' : show (ord c) ++ "-"
    
    216
    +        | p c       = LText.singleton c
    
    217
    +        | otherwise =
    
    218
    +            -- "-" <> show (ord c) <> "-"
    
    219
    +            LText.cons '-' (LText.pack (show (ord c) <> "-"))
    
    220
    +
    
    221
    +    isLegal :: Char -> Bool
    
    212 222
         isLegal ':' = True
    
    213 223
         isLegal '_' = True
    
    214 224
         isLegal '.' = True
    
    215
    -    isLegal c = isAscii c && isAlphaNum c
    
    225
    +    isLegal c   = isAscii c && isAlphaNum c
    
    216 226
     
    
    217 227
     -- NB: '-' is legal in IDs, but we use it as the escape char
    
    218 228
     
    
    ... ... @@ -272,7 +282,7 @@ escapeURIString :: (Char -> Bool) -> String -> String
    272 282
     escapeURIString = concatMap . escapeURIChar
    
    273 283
     
    
    274 284
     isUnreserved :: Char -> Bool
    
    275
    -isUnreserved c = isAlphaNumChar c || (c `elem` "-_.~")
    
    285
    +isUnreserved c = isAlphaNumChar c || (c `elem` ("-_.~" :: String))
    
    276 286
     
    
    277 287
     isAlphaChar, isDigitChar, isAlphaNumChar :: Char -> Bool
    
    278 288
     isAlphaChar c = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
    

  • utils/haddock/html-test/ref/Bug26.html
    ... ... @@ -53,7 +53,7 @@
    53 53
     	>Description</p
    
    54 54
     	><div class="doc"
    
    55 55
     	><p
    
    56
    -	  >This module tests the &#8216;@since &#8230;&#8217; annotation.</p
    
    56
    +	  >This module tests the ‘@since …’ annotation.</p
    
    57 57
     	  ><p
    
    58 58
     	  ><em
    
    59 59
     	    >Since: 1.2.3</em
    

  • utils/haddock/html-test/ref/Bug298.html
    ... ... @@ -67,7 +67,7 @@
    67 67
     	      > :: a -&gt; a -&gt; a</li
    
    68 68
     	    ><li class="src short"
    
    69 69
     	    ><a href="#"
    
    70
    -	      >(&#8902;^)</a
    
    70
    +	      >(^)</a
    
    71 71
     	      > :: a -&gt; a -&gt; a</li
    
    72 72
     	    ><li class="src short"
    
    73 73
     	    ><a href="#"
    
    ... ... @@ -106,7 +106,7 @@
    106 106
     	><div class="top"
    
    107 107
     	><p class="src"
    
    108 108
     	  ><a id="v:-8902--94-" class="def"
    
    109
    -	    >(&#8902;^)</a
    
    109
    +	    >(^)</a
    
    110 110
     	    > :: a -&gt; a -&gt; a <a href="#" class="selflink"
    
    111 111
     	    >#</a
    
    112 112
     	    ></p
    
    ... ... @@ -134,7 +134,7 @@
    134 134
     		></code
    
    135 135
     	      > and <code
    
    136 136
     	      ><a href="#" title="Bug298"
    
    137
    -		>&#8902;^</a
    
    137
    +		>^</a
    
    138 138
     		></code
    
    139 139
     	      >.</p
    
    140 140
     	    ></div
    

  • utils/haddock/html-test/ref/Bug458.html
    ... ... @@ -55,7 +55,7 @@
    55 55
     	  ><ul class="details-toggle" data-details-id="syn"
    
    56 56
     	  ><li class="src short"
    
    57 57
     	    ><a href="#"
    
    58
    -	      >(&#8838;)</a
    
    58
    +	      >()</a
    
    59 59
     	      > :: () -&gt; () -&gt; ()</li
    
    60 60
     	    ></ul
    
    61 61
     	  ></details
    
    ... ... @@ -66,7 +66,7 @@
    66 66
     	><div class="top"
    
    67 67
     	><p class="src"
    
    68 68
     	  ><a id="v:-8838-" class="def"
    
    69
    -	    >(&#8838;)</a
    
    69
    +	    >()</a
    
    70 70
     	    > :: () -&gt; () -&gt; () <a href="#" class="selflink"
    
    71 71
     	    >#</a
    
    72 72
     	    ></p
    
    ... ... @@ -75,7 +75,7 @@
    75 75
     	    >See the defn of <code class="inline-code"
    
    76 76
     	      ><code
    
    77 77
     		><a href="#" title="Bug458"
    
    78
    -		  >&#8838;</a
    
    78
    +		  ></a
    
    79 79
     		  ></code
    
    80 80
     		></code
    
    81 81
     	      >.</p
    

  • utils/haddock/html-test/ref/Nesting.html
    ... ... @@ -317,7 +317,7 @@ with more of the indented list content.</p
    317 317
     			><h3
    
    318 318
     			>Level 3 header</h3
    
    319 319
     			><p
    
    320
    -			>with some content&#8230;</p
    
    320
    +			>with some content</p
    
    321 321
     			><ul
    
    322 322
     			><li
    
    323 323
     			  >and even more lists inside</li
    

  • utils/haddock/html-test/ref/TitledPicture.html
    ... ... @@ -105,7 +105,7 @@
    105 105
     	      ><a href="#" title="TitledPicture"
    
    106 106
     		>bar</a
    
    107 107
     		></code
    
    108
    -	      > with title <img src="un&#8739;&#8705;&#8728;" title="&#948;&#8712;"
    
    108
    +	      > with title <img src="un∣∁∘" title="δ∈"
    
    109 109
     	       /></p
    
    110 110
     	    ></div
    
    111 111
     	  ></div
    

  • utils/haddock/html-test/ref/Unicode.html
    ... ... @@ -76,7 +76,7 @@
    76 76
     	    ></p
    
    77 77
     	  ><div class="doc"
    
    78 78
     	  ><p
    
    79
    -	    >&#947;&#955;&#974;&#963;&#963;&#945;</p
    
    79
    +	    >γλώσσα</p
    
    80 80
     	    ></div
    
    81 81
     	  ></div
    
    82 82
     	></div
    

  • utils/haddock/html-test/ref/Unicode2.html
    ... ... @@ -55,7 +55,7 @@
    55 55
     	  ><ul class="details-toggle" data-details-id="syn"
    
    56 56
     	  ><li class="src short"
    
    57 57
     	    ><a href="#"
    
    58
    -	      >&#252;</a
    
    58
    +	      >ü</a
    
    59 59
     	      > :: ()</li
    
    60 60
     	    ></ul
    
    61 61
     	  ></details
    
    ... ... @@ -66,36 +66,36 @@
    66 66
     	><div class="top"
    
    67 67
     	><p class="src"
    
    68 68
     	  ><a id="v:-252-" class="def"
    
    69
    -	    >&#252;</a
    
    69
    +	    >ü</a
    
    70 70
     	    > :: () <a href="#" class="selflink"
    
    71 71
     	    >#</a
    
    72 72
     	    ></p
    
    73 73
     	  ><div class="doc"
    
    74 74
     	  ><p
    
    75
    -	    >All of the following work with a unicode character &#252;:</p
    
    75
    +	    >All of the following work with a unicode character ü:</p
    
    76 76
     	    ><ul
    
    77 77
     	    ><li
    
    78 78
     	      >an italicized <em
    
    79
    -		>&#252;</em
    
    79
    +		>ü</em
    
    80 80
     		></li
    
    81 81
     	      ><li
    
    82 82
     	      >inline code <code class="inline-code"
    
    83
    -		>&#252;</code
    
    83
    +		>ü</code
    
    84 84
     		></li
    
    85 85
     	      ><li
    
    86 86
     	      >a code block:</li
    
    87 87
     	      ></ul
    
    88 88
     	    ><pre
    
    89
    -	    >&#252;</pre
    
    89
    +	    >ü</pre
    
    90 90
     	    ><ul
    
    91 91
     	    ><li
    
    92 92
     	      >a url <a href="#"
    
    93
    -		>https://www.google.com/search?q=&#252;</a
    
    93
    +		>https://www.google.com/search?q=ü</a
    
    94 94
     		></li
    
    95 95
     	      ><li
    
    96 96
     	      >a link to <code
    
    97 97
     		><a href="#" title="Unicode2"
    
    98
    -		  >&#252;</a
    
    98
    +		  >ü</a
    
    99 99
     		  ></code
    
    100 100
     		></li
    
    101 101
     	      ></ul