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

Commits:

9 changed files:

Changes:

  • compiler/GHC/Builtin/PrimOps.hs
    ... ... @@ -17,7 +17,7 @@ module GHC.Builtin.PrimOps (
    17 17
     
    
    18 18
             primOpOutOfLine, primOpCodeSize,
    
    19 19
             primOpOkForSpeculation, primOpOkToDiscard,
    
    20
    -        primOpIsWorkFree, primOpIsCheap, primOpFixity, primOpDocs, primOpDeprecations,
    
    20
    +        primOpIsWorkFree, primOpIsCheap, primOpFixity, primOpDocs, PrimOpDoc(..), primOpDeprecations,
    
    21 21
             primOpIsDiv, primOpIsReallyInline,
    
    22 22
     
    
    23 23
             PrimOpEffect(..), primOpEffect,
    
    ... ... @@ -166,7 +166,13 @@ primOpFixity :: PrimOp -> Maybe Fixity
    166 166
     See Note [GHC.Prim Docs] in GHC.Builtin.Utils
    
    167 167
     -}
    
    168 168
     
    
    169
    -primOpDocs :: [(FastString, String)]
    
    169
    +data PrimOpDoc
    
    170
    +  = -- | Section header with title and description
    
    171
    +    PrimOpSection String String
    
    172
    +  | -- | Documentation for a named declaration
    
    173
    +    PrimOpDecl FastString String
    
    174
    +
    
    175
    +primOpDocs :: [PrimOpDoc]
    
    170 176
     #include "primop-docs.hs-incl"
    
    171 177
     
    
    172 178
     primOpDeprecations :: [(OccName, FastString)]
    

  • compiler/GHC/Builtin/Utils.hs
    ... ... @@ -246,12 +246,39 @@ ghcPrimExports
    246 246
        | tc <- exposedPrimTyCons, let n = tyConName tc ]
    
    247 247
     
    
    248 248
     ghcPrimDeclDocs :: Docs
    
    249
    -ghcPrimDeclDocs = emptyDocs { docs_decls = listToUniqMap $ mapMaybe findName primOpDocs }
    
    249
    +ghcPrimDeclDocs = emptyDocs
    
    250
    +  { docs_decls = listToUniqMap $ mapMaybe declDoc primOpDocs
    
    251
    +  , docs_structure = buildStructure primOpDocs
    
    252
    +  }
    
    250 253
       where
    
    251
    -    findName (nameStr, doc)
    
    252
    -      | Just name <- lookupFsEnv ghcPrimNames nameStr
    
    253
    -      = Just (name, [WithHsDocIdentifiers (mkGeneratedHsDocString doc) []])
    
    254
    -      | otherwise = Nothing
    
    254
    +    declDoc (PrimOpDecl fs doc)
    
    255
    +      | not (null doc)
    
    256
    +      , Just name <- lookupFsEnv ghcPrimNames fs
    
    257
    +      = Just (name, [mkHsDoc doc])
    
    258
    +    declDoc _ = Nothing
    
    259
    +
    
    260
    +    buildStructure [] = []
    
    261
    +    buildStructure (PrimOpSection title desc : rest) =
    
    262
    +        DsiSectionHeading 1 (mkHsDoc title)
    
    263
    +      : [DsiDocChunk (mkHsDoc desc) | not (null desc)]
    
    264
    +     ++ buildStructure rest
    
    265
    +    buildStructure items =
    
    266
    +      let (decls, rest) = span isDecl items
    
    267
    +          avails = mapMaybe declAvail decls
    
    268
    +      in  [DsiExports (DefinitelyDeterministicAvails avails) | not (null avails)]
    
    269
    +       ++ buildStructure rest
    
    270
    +
    
    271
    +    isDecl (PrimOpDecl {}) = True
    
    272
    +    isDecl _               = False
    
    273
    +
    
    274
    +    declAvail (PrimOpDecl fs _)
    
    275
    +      | Just name <- lookupFsEnv ghcPrimNames fs
    
    276
    +      = Just $ if isTyConName name
    
    277
    +               then AvailTC name [name]
    
    278
    +               else Avail name
    
    279
    +    declAvail _ = Nothing
    
    280
    +
    
    281
    +    mkHsDoc s = WithHsDocIdentifiers (mkGeneratedHsDocString s) []
    
    255 282
     
    
    256 283
     ghcPrimNames :: FastStringEnv Name
    
    257 284
     ghcPrimNames
    
    ... ... @@ -287,18 +314,13 @@ ghcPrimFixities = fixities
    287 314
     {-
    
    288 315
     Note [GHC.Prim Docs]
    
    289 316
     ~~~~~~~~~~~~~~~~~~~~
    
    290
    -For haddocks of GHC.Prim we generate a dummy haskell file (gen_hs_source) that
    
    291
    -contains the type signatures and the comments (but no implementations)
    
    292
    -specifically for consumption by haddock.
    
    293
    -
    
    294
    -GHCi's :doc command reads directly from ModIface's though, and GHC.Prim has a
    
    295
    -wired-in iface that has nothing to do with the above haskell file. The code
    
    296
    -below converts primops.txt into an intermediate form that would later be turned
    
    297
    -into a proper DeclDocMap.
    
    298
    -
    
    299
    -We output the docs as a list of pairs (name, docs). We use stringy names here
    
    300
    -because mapping names to "Name"s is difficult for things like primtypes and
    
    301
    -pseudoops.
    
    317
    +GHCi's :doc command and Haddock read from ModIface's. GHC.Prim has a wired-in
    
    318
    +iface whose docs are populated from primops.txt.
    
    319
    +
    
    320
    +genprimopcode --wired-in-docs generates the primOpDocs list (included as
    
    321
    +primop-docs.hs-incl), which contains section headers (PrimOpSection) and
    
    322
    +per-declaration documentation (PrimOpDecl). We use stringy names because
    
    323
    +mapping names to "Name"s is difficult for things like primtypes and pseudoops.
    
    302 324
     
    
    303 325
     Note [GHC.Prim Deprecations]
    
    304 326
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

  • compiler/GHC/Builtin/primops.txt.pp
    ... ... @@ -46,7 +46,7 @@
    46 46
     -- * The primitives are listed in this file, primops.txt.pp.
    
    47 47
     --   It goes through CPP, which creates primops.txt.
    
    48 48
     --   It is then consumed by the utility program genprimopcode, which produces
    
    49
    ---   the following three types of files.
    
    49
    +--   the following types of files.
    
    50 50
     --
    
    51 51
     --   1. The files with extension .hs-incl.
    
    52 52
     --      They can be found by grepping for hs-incl.
    
    ... ... @@ -71,12 +71,7 @@
    71 71
     --      Additionally, we pattern match on PrimOp when generating Cmm in
    
    72 72
     --      GHC/StgToCmm/Prim.hs.
    
    73 73
     --
    
    74
    ---   2. The dummy Prim.hs file, which is used for Haddock and
    
    75
    ---      contains descriptions taken from primops.txt.pp.
    
    76
    ---      All definitions are replaced by placeholders.
    
    77
    ---      See Note [GHC.Prim Docs] in GHC.Builtin.Utils.
    
    78
    ---
    
    79
    ---   3. The module PrimopWrappers.hs, which wraps every call for GHCi;
    
    74
    +--   2. The module PrimopWrappers.hs, which wraps every call for GHCi;
    
    80 75
     --      see Note [Primop wrappers] in GHC.Builtin.Primops for details.
    
    81 76
     --
    
    82 77
     -- * This file does not list internal-only equality types
    

  • hadrian/src/Rules/Generate.hs
    ... ... @@ -49,7 +49,7 @@ ghcInternalDependencies :: Expr [FilePath]
    49 49
     ghcInternalDependencies = do
    
    50 50
         stage <- getStage
    
    51 51
         path  <- expr $ buildPath (vanillaContext stage ghcInternal)
    
    52
    -    return [path -/- "GHC/Internal/Prim.hs", path -/- "GHC/Internal/PrimopWrappers.hs"]
    
    52
    +    return [path -/- "GHC/Internal/PrimopWrappers.hs"]
    
    53 53
     
    
    54 54
     rtsDependencies :: Expr [FilePath]
    
    55 55
     rtsDependencies = do
    
    ... ... @@ -141,7 +141,6 @@ generatePackageCode context@(Context stage pkg _ _) = do
    141 141
                 root -/- "**" -/- dir -/- "GHC/Settings/Config.hs" %> go generateConfigHs
    
    142 142
                 root -/- "**" -/- dir -/- "*.hs-incl" %> genPrimopCode context
    
    143 143
             when (pkg == ghcInternal) $ do
    
    144
    -            root -/- "**" -/- dir -/- "GHC/Internal/Prim.hs" %> genPrimopCode context
    
    145 144
                 root -/- "**" -/- dir -/- "GHC/Internal/PrimopWrappers.hs" %> genPrimopCode context
    
    146 145
             when (pkg == ghcBoot) $ do
    
    147 146
                 root -/- "**" -/- dir -/- "GHC/Version.hs" %> go generateVersionHs
    

  • hadrian/src/Settings/Builders/GenPrimopCode.hs
    ... ... @@ -5,7 +5,6 @@ import Settings.Builders.Common
    5 5
     genPrimopCodeBuilderArgs :: Args
    
    6 6
     genPrimopCodeBuilderArgs = builder GenPrimopCode ? mconcat
    
    7 7
         [ output "//PrimopWrappers.hs"                 ? arg "--make-haskell-wrappers"
    
    8
    -    , output "//Prim.hs"                           ? arg "--make-haskell-source"
    
    9 8
         , output "//primop-data-decl.hs-incl"          ? arg "--data-decl"
    
    10 9
         , output "//primop-tag.hs-incl"                ? arg "--primop-tag"
    
    11 10
         , output "//primop-list.hs-incl"               ? arg "--primop-list"
    

  • libraries/ghc-internal/ghc-internal.cabal.in
    ... ... @@ -357,7 +357,6 @@ Library
    357 357
             GHC.Internal.Types
    
    358 358
     
    
    359 359
         autogen-modules:
    
    360
    -        GHC.Internal.Prim
    
    361 360
             GHC.Internal.PrimopWrappers
    
    362 361
     
    
    363 362
         other-modules:
    

  • libraries/ghc-internal/src/GHC/Internal/Prim.hs
    1
    +{-# LANGUAGE Unsafe #-}
    
    2
    +{-# LANGUAGE NoImplicitPrelude #-}
    
    3
    +
    
    4
    +-- | GHC's primitive types and operations.
    
    5
    +-- Use GHC.Exts from the base package instead of importing this
    
    6
    +-- module directly.
    
    7
    +--
    
    8
    +-- This module has no source-level definitions. All primitive types
    
    9
    +-- and operations are wired-in to GHC. See Note [GHC.Prim] in
    
    10
    +-- primops.txt.pp.
    
    11
    +module GHC.Internal.Prim () where

  • testsuite/tests/pmcheck/should_compile/T11303.hs
    ... ... @@ -24,6 +24,5 @@ main = do
    24 24
                           "--primop-vector-maps"  -> "hmmm"
    
    25 25
                           "--primop-vector-paper"  -> "hmmm"
    
    26 26
                           "--make-haskell-wrappers" -> "123512"
    
    27
    -                      "--make-haskell-source"  -> "as;dg"
    
    28 27
                           "--make-latex-doc" -> "adghiw"
    
    29 28
                           _ -> error "Should not happen, known_args out of sync?"

  • utils/genprimopcode/Main.hs
    ... ... @@ -204,9 +204,6 @@ main = getArgs >>= \args ->
    204 204
                           "--make-haskell-wrappers"
    
    205 205
                              -> putStr (gen_wrappers p_o_specs)
    
    206 206
     
    
    207
    -                      "--make-haskell-source"
    
    208
    -                         -> putStr (gen_hs_source p_o_specs)
    
    209
    -
    
    210 207
                           "--wired-in-docs"
    
    211 208
                              -> putStr (gen_wired_in_docs p_o_specs)
    
    212 209
     
    
    ... ... @@ -238,7 +235,6 @@ known_args
    238 235
            "--primop-vector-tys-exports",
    
    239 236
            "--primop-vector-tycons",
    
    240 237
            "--make-haskell-wrappers",
    
    241
    -       "--make-haskell-source",
    
    242 238
            "--make-latex-doc",
    
    243 239
            "--wired-in-docs",
    
    244 240
            "--wired-in-deprecations",
    
    ... ... @@ -249,149 +245,6 @@ known_args
    249 245
     -- Code generators -----------------------------------------------
    
    250 246
     ------------------------------------------------------------------
    
    251 247
     
    
    252
    -gen_hs_source :: Info -> String
    
    253
    -gen_hs_source (Info defaults entries) =
    
    254
    -       "{-\n"
    
    255
    -    ++ "This is a generated file (generated by genprimopcode).\n"
    
    256
    -    ++ "It is not code to actually be used. Its only purpose is to be\n"
    
    257
    -    ++ "consumed by haddock.\n"
    
    258
    -    ++ "-}\n"
    
    259
    -    ++ "\n"
    
    260
    -        ++ (replicate 77 '-' ++ "\n") -- For 80-col cleanliness
    
    261
    -        ++ "-- |\n"
    
    262
    -        ++ "-- Module      :  GHC.Internal.Prim\n"
    
    263
    -        ++ "-- \n"
    
    264
    -        ++ "-- Maintainer  :  ghc-devs@haskell.org\n"
    
    265
    -        ++ "-- Stability   :  internal\n"
    
    266
    -        ++ "-- Portability :  non-portable (GHC extensions)\n"
    
    267
    -        ++ "--\n"
    
    268
    -        ++ "-- GHC\'s primitive types and operations.\n"
    
    269
    -        ++ "-- Use GHC.Exts from the base package instead of importing this\n"
    
    270
    -        ++ "-- module directly.\n"
    
    271
    -        ++ "--\n"
    
    272
    -        ++ (replicate 77 '-' ++ "\n") -- For 80-col cleanliness
    
    273
    -        ++ "{-# LANGUAGE Unsafe #-}\n"
    
    274
    -        ++ "{-# LANGUAGE MagicHash #-}\n"
    
    275
    -        ++ "{-# LANGUAGE MultiParamTypeClasses #-}\n"
    
    276
    -        ++ "{-# LANGUAGE NoImplicitPrelude #-}\n"
    
    277
    -        ++ "{-# LANGUAGE UnboxedTuples #-}\n"
    
    278
    -        ++ "{-# LANGUAGE NegativeLiterals #-}\n"
    
    279
    -
    
    280
    -        ++ "{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}\n"
    
    281
    -                -- We generate a binding for coerce, like
    
    282
    -                --   coerce :: Coercible a b => a -> b
    
    283
    -                --   coerce = let x = x in x
    
    284
    -                -- and we don't want a complaint that the constraint is redundant
    
    285
    -                -- Remember, this silly file is only for Haddock's consumption
    
    286
    -
    
    287
    -        ++ "{-# OPTIONS_HADDOCK print-explicit-runtime-reps #-}\n"
    
    288
    -        ++ "module GHC.Internal.Prim (\n"
    
    289
    -        ++ unlines (map (("        " ++) . hdr) entries')
    
    290
    -        ++ ") where\n"
    
    291
    -    ++ "\n"
    
    292
    -    ++ "{-\n"
    
    293
    -        ++ unlines (map opt defaults)
    
    294
    -    ++ "-}\n"
    
    295
    -    -- this import introduces a loop between GHC.Internal.Types and
    
    296
    -    -- GHC.Internal.Prim.
    
    297
    -    -- ++ "import GHC.Internal.Types (Coercible)\n"
    
    298
    -
    
    299
    -    ++ "default ()"  -- If we don't say this then the default type include Integer
    
    300
    -                     -- so that runs off and loads modules that are not part of
    
    301
    -                     -- package ghc-prim at all.  And that in turn somehow ends up
    
    302
    -                     -- with Declaration for $fEqMaybe:
    
    303
    -                     --       attempting to use module ‘GHC.Classes’
    
    304
    -                     --       (libraries/ghc-prim/./GHC/Classes.hs) which is not loaded
    
    305
    -                     -- coming from GHC.Iface.Load.homeModError
    
    306
    -                     -- I'm not sure precisely why; but I *am* sure that we don't need
    
    307
    -                     -- any type-class defaulting; and it's clearly wrong to need
    
    308
    -                     -- the base package when haddocking ghc-prim
    
    309
    -
    
    310
    -       -- Now the main payload
    
    311
    -    ++ "\n" ++ unlines (concatMap ent entries') ++ "\n\n\n"
    
    312
    -
    
    313
    -     where entries' = concatMap desugarVectorSpec entries
    
    314
    -
    
    315
    -           opt (OptionFalse n)    = n ++ " = False"
    
    316
    -           opt (OptionTrue n)     = n ++ " = True"
    
    317
    -           opt (OptionString n v) = n ++ " = { " ++ v ++ "}"
    
    318
    -           opt (OptionInteger n v) = n ++ " = " ++ show v
    
    319
    -           opt (OptionVector _)    = ""
    
    320
    -           opt (OptionFixity mf) = "fixity = " ++ show mf
    
    321
    -           opt (OptionEffect eff) = "effect = " ++ show eff
    
    322
    -           opt (OptionDefinedBits bc) = "defined_bits = " ++ show bc
    
    323
    -           opt (OptionCanFailWarnFlag wf) = "can_fail_warning = " ++ show wf
    
    324
    -
    
    325
    -           hdr s@(Section {})                                    = sec s
    
    326
    -           hdr (PrimOpSpec { name = n })                         = wrapOp n ++ ","
    
    327
    -           hdr (PrimVecOpSpec { name = n })                      = wrapOp n ++ ","
    
    328
    -           hdr (PseudoOpSpec { name = n })                       = wrapOp n ++ ","
    
    329
    -           hdr (PrimTypeSpec { ty = TyApp (TyCon n) _ })         = wrapOp n ++ ","
    
    330
    -           hdr (PrimTypeSpec {})                                 = error $ "Illegal type spec"
    
    331
    -           hdr (PrimVecTypeSpec { ty = TyApp (VecTyCon n _) _ }) = wrapOp n ++ ","
    
    332
    -           hdr (PrimVecTypeSpec {})                              = error $ "Illegal type spec"
    
    333
    -
    
    334
    -           sec s = "\n{- * " ++ title s ++ "-}\n{-|" ++ desc s ++ "-}"
    
    335
    -
    
    336
    -
    
    337
    -           ent   (Section {})         = []
    
    338
    -           ent o@(PrimOpSpec {})      = spec o
    
    339
    -           ent o@(PrimVecOpSpec {})   = spec o
    
    340
    -           ent o@(PrimTypeSpec {})    = spec o
    
    341
    -           ent o@(PrimVecTypeSpec {}) = spec o
    
    342
    -           ent o@(PseudoOpSpec {})    = spec o
    
    343
    -
    
    344
    -           spec o = ([ "" ] ++) . concat $
    
    345
    -             -- Doc comments
    
    346
    -             [ case desc o ++ extra (opts o) of
    
    347
    -                 "" -> []
    
    348
    -                 cmmt -> lines ("{-|" ++ cmmt ++ "-}")
    
    349
    -
    
    350
    -             -- Deprecations
    
    351
    -             , [ d | Just n <- [getName o], d <- prim_deprecated (opts o) n ]
    
    352
    -
    
    353
    -             -- Fixity
    
    354
    -             , [ f | Just n <- [getName o], f <- prim_fixity (opts o) n ]
    
    355
    -
    
    356
    -             -- Declarations (see Note [Placeholder declarations])
    
    357
    -             , case o of
    
    358
    -                 PrimOpSpec { name = n, ty = t }    -> prim_func n t
    
    359
    -                 PrimVecOpSpec { name = n, ty = t } -> prim_func n t
    
    360
    -                 PseudoOpSpec { name = n, ty = t }  -> prim_func n t
    
    361
    -                 PrimTypeSpec { ty = t }    -> prim_data t
    
    362
    -                 PrimVecTypeSpec { ty = t } -> prim_data t
    
    363
    -                 Section { } -> error "Section is not an entity"
    
    364
    -             ]
    
    365
    -
    
    366
    -           extra options = case can_fail options of
    
    367
    -             [m] -> "\n\n__/Warning:/__ this " ++ m ++ "."
    
    368
    -             _ -> ""
    
    369
    -
    
    370
    -           can_fail options
    
    371
    -             = [ "can fail with an unchecked exception"
    
    372
    -               | Just (OptionEffect eff) <- [lookup_attrib "effect" options]
    
    373
    -               , Just (OptionCanFailWarnFlag wflag) <- [lookup_attrib "can_fail_warning" options]
    
    374
    -               , wflag /= DoNotWarnCanFail
    
    375
    -               , wflag == YesWarnCanFail || eff == CanFail ]
    
    376
    -
    
    377
    -           prim_deprecated options n
    
    378
    -              = [ "{-# DEPRECATED " ++ wrapOp n ++ " \"" ++ msg ++ "\" #-}"
    
    379
    -                | Just (OptionString _ msg)
    
    380
    -                    <- [lookup_attrib "deprecated_msg" options] ]
    
    381
    -
    
    382
    -           prim_fixity options n
    
    383
    -              = [ pprFixityDir d ++ " " ++ show i ++ " " ++ asInfix n
    
    384
    -                | OptionFixity (Just (Fixity i d)) <- options ]
    
    385
    -
    
    386
    -           prim_func n t = [ wrapOp n ++ " :: " ++ pprTy t,
    
    387
    -                             wrapOp n ++ " = " ++ funcRhs n ]
    
    388
    -
    
    389
    -           funcRhs "tagToEnum#" = "let x = x in x"
    
    390
    -           funcRhs nm           = wrapOp nm
    
    391
    -              -- Special case for tagToEnum#: see Note [Placeholder declarations]
    
    392
    -
    
    393
    -           prim_data t = [ "data " ++ pprTy t ]
    
    394
    -
    
    395 248
     -- | Extract a string representation of the name
    
    396 249
     getName :: Entry -> Maybe String
    
    397 250
     getName PrimOpSpec{ name = n } = Just n
    
    ... ... @@ -401,25 +254,6 @@ getName PrimTypeSpec{ ty = TyApp tc _ } = Just (show tc)
    401 254
     getName PrimVecTypeSpec{ ty = TyApp tc _ } = Just (show tc)
    
    402 255
     getName _ = Nothing
    
    403 256
     
    
    404
    -{- Note [Placeholder declarations]
    
    405
    -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    406
    -We are generating fake declarations for things in GHC.Internal.Prim, just to
    
    407
    -keep GHC's renamer and typechecker happy enough for what Haddock
    
    408
    -needs.  Our main plan is to say
    
    409
    -        foo :: <type>
    
    410
    -        foo = foo
    
    411
    -
    
    412
    -That works for all the primitive functions except tagToEnum#.
    
    413
    -If we generate the binding
    
    414
    -        tagToEnum# = tagToEnum#
    
    415
    -GHC will complain about "tagToEnum# must appear applied to one argument".
    
    416
    -We could hack GHC to silence this complaint when compiling GHC.Internal.Prim,
    
    417
    -but it seems easier to generate
    
    418
    -        tagToEnum# = let x = x in x
    
    419
    -We don't do this for *all* bindings because for ones with an unboxed
    
    420
    -RHS we would get other complaints (e.g.can't unify "*" with "#").
    
    421
    --}
    
    422
    -
    
    423 257
     -- | "Pretty"-print a type
    
    424 258
     pprTy :: Ty -> String
    
    425 259
     pprTy = pty
    
    ... ... @@ -442,11 +276,6 @@ wrapOp :: String -> String
    442 276
     wrapOp nm | isAlpha (head nm) = nm
    
    443 277
               | otherwise         = "(" ++ nm ++ ")"
    
    444 278
     
    
    445
    --- | Turn an identifier or operator into its infix form
    
    446
    -asInfix :: String -> String
    
    447
    -asInfix nm | isAlpha (head nm) = "`" ++ nm ++ "`"
    
    448
    -           | otherwise         = nm
    
    449
    -
    
    450 279
     
    
    451 280
     {- Note [OPTIONS_GHC in GHC.PrimopWrappers]
    
    452 281
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    ... ... @@ -666,11 +495,30 @@ gen_switch_from_attribs attrib_name fn_name (Info defaults entries)
    666 495
     -- See Note [GHC.Prim Docs] in GHC.Builtin.Utils
    
    667 496
     gen_wired_in_docs :: Info -> String
    
    668 497
     gen_wired_in_docs (Info _ entries)
    
    669
    -  = "primOpDocs =\n  [ " ++ intercalate "\n  , " (catMaybes $ map mkDoc $ concatMap desugarVectorSpec entries) ++ "\n  ]\n"
    
    498
    +  = "primOpDocs =\n  [ "
    
    499
    +    ++ intercalate "\n  , " (concatMap mkEntry desugared)
    
    500
    +    ++ "\n  ]\n"
    
    670 501
         where
    
    671
    -      mkDoc po | Just poName <- getName po
    
    672
    -               , not $ null $ desc po = Just $ "(fsLit " ++ show poName ++ "," ++ show (desc po) ++ ")"
    
    673
    -               | otherwise = Nothing
    
    502
    +      desugared = concatMap desugarVectorSpec entries
    
    503
    +
    
    504
    +      mkEntry :: Entry -> [String]
    
    505
    +      mkEntry (Section{title = t, desc = d}) =
    
    506
    +        ["PrimOpSection " ++ show t ++ " " ++ show d]
    
    507
    +      mkEntry po
    
    508
    +        | Just poName <- getName po
    
    509
    +        = ["PrimOpDecl (fsLit " ++ show poName ++ ") " ++ show (desc po ++ extra (opts po))]
    
    510
    +        | otherwise = []
    
    511
    +
    
    512
    +      extra options = case canFail options of
    
    513
    +        [m] -> "\n\n__/Warning:/__ this " ++ m ++ "."
    
    514
    +        _ -> ""
    
    515
    +
    
    516
    +      canFail options
    
    517
    +        = [ "can fail with an unchecked exception"
    
    518
    +          | Just (OptionEffect eff) <- [lookup_attrib "effect" options]
    
    519
    +          , Just (OptionCanFailWarnFlag wflag) <- [lookup_attrib "can_fail_warning" options]
    
    520
    +          , wflag /= DoNotWarnCanFail
    
    521
    +          , wflag == YesWarnCanFail || eff == CanFail ]
    
    674 522
     
    
    675 523
     -- See Note [GHC.Prim Deprecations] in GHC.Builtin.Utils
    
    676 524
     gen_wired_in_deprecations :: Info -> String