    -- | An exactprintable structure for docstrings
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DerivingStrategies #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}

    module GHC.Hs.DocString
      ( LHsDocString
      , HsDocString(..)
      , HsDocStringDecorator(..)
      , HsDocStringChunk(..)
      , LHsDocStringChunk
      , isEmptyDocString
      , unpackHDSC
      , mkHsDocStringChunk
      , mkHsDocStringChunkUtf8ByteString
      , pprHsDocString
      , pprHsDocStrings
      , mkGeneratedHsDocString
      , docStringChunks
      , renderHsDocString
      , renderHsDocStrings
      , exactPrintHsDocString
      , pprWithDocString
      , printDecorator
      ) where

    import GHC.Prelude

    import GHC.Utils.Binary
    import GHC.Utils.Encoding
    import GHC.Utils.Outputable as Outputable hiding ((<>))
    import GHC.Types.SrcLoc
    import Control.DeepSeq

    import Data.ByteString (ByteString)
    import qualified Data.ByteString as BS
    import Data.Data
    import Data.List.NonEmpty (NonEmpty(..))
    import Data.List (intercalate)

    type LHsDocString = Located HsDocString

    -- | Haskell Documentation String
    --
    -- Rich structure to support exact printing
    -- The location around each chunk doesn't include the decorators
    data HsDocString
      = MultiLineDocString !HsDocStringDecorator !(NonEmpty LHsDocStringChunk)
         -- ^ The first chunk is preceded by "-- <decorator>" and each following chunk is preceded by "--"
         -- Example: -- | This is a docstring for 'foo'. It is the line with the decorator '|' and is always included
         --          -- This continues that docstring and is the second element in the NonEmpty list
         --          foo :: a -> a
      | NestedDocString !HsDocStringDecorator LHsDocStringChunk
         -- ^ The docstring is preceded by "{-<decorator>" and followed by "-}"
         -- The chunk contains balanced pairs of '{-' and '-}'
      | GeneratedDocString HsDocStringChunk
         -- ^ A docstring generated either internally or via TH
         -- Pretty printed with the '-- |' decorator
         -- This is because it may contain unbalanced pairs of '{-' and '-}' and
         -- not form a valid 'NestedDocString'
      deriving (HsDocString -> HsDocString -> Bool
    (HsDocString -> HsDocString -> Bool)
    -> (HsDocString -> HsDocString -> Bool) -> Eq HsDocString
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: HsDocString -> HsDocString -> Bool
    == :: HsDocString -> HsDocString -> Bool
    $c/= :: HsDocString -> HsDocString -> Bool
    /= :: HsDocString -> HsDocString -> Bool
    Eq, Typeable HsDocString
    Typeable HsDocString =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> HsDocString -> c HsDocString)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c HsDocString)
    -> (HsDocString -> Constr)
    -> (HsDocString -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c HsDocString))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c HsDocString))
    -> ((forall b. Data b => b -> b) -> HsDocString -> HsDocString)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> HsDocString -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> HsDocString -> r)
    -> (forall u. (forall d. Data d => d -> u) -> HsDocString -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> HsDocString -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString)
    -> Data HsDocString
    HsDocString -> Constr
    HsDocString -> DataType
    (forall b. Data b => b -> b) -> HsDocString -> HsDocString
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> HsDocString -> u
    forall u. (forall d. Data d => d -> u) -> HsDocString -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocString -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocString -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocString
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HsDocString -> c HsDocString
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocString)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocString)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HsDocString -> c HsDocString
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HsDocString -> c HsDocString
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocString
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocString
    $ctoConstr :: HsDocString -> Constr
    toConstr :: HsDocString -> Constr
    $cdataTypeOf :: HsDocString -> DataType
    dataTypeOf :: HsDocString -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocString)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocString)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocString)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocString)
    $cgmapT :: (forall b. Data b => b -> b) -> HsDocString -> HsDocString
    gmapT :: (forall b. Data b => b -> b) -> HsDocString -> HsDocString
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocString -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocString -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocString -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocString -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> HsDocString -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> HsDocString -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsDocString -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsDocString -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString
    Data, Int -> HsDocString -> ShowS
    [HsDocString] -> ShowS
    HsDocString -> String
    (Int -> HsDocString -> ShowS)
    -> (HsDocString -> String)
    -> ([HsDocString] -> ShowS)
    -> Show HsDocString
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> HsDocString -> ShowS
    showsPrec :: Int -> HsDocString -> ShowS
    $cshow :: HsDocString -> String
    show :: HsDocString -> String
    $cshowList :: [HsDocString] -> ShowS
    showList :: [HsDocString] -> ShowS
    Show)

    instance Outputable HsDocString where
      ppr :: HsDocString -> SDoc
    ppr = String -> SDoc
    forall doc. IsLine doc => String -> doc
    text (String -> SDoc) -> (HsDocString -> String) -> HsDocString -> SDoc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . HsDocString -> String
    renderHsDocString

    instance NFData HsDocString where
      rnf :: HsDocString -> ()
    rnf (MultiLineDocString HsDocStringDecorator
    a NonEmpty LHsDocStringChunk
    b) = HsDocStringDecorator -> ()
    forall a. NFData a => a -> ()
    rnf HsDocStringDecorator
    a () -> () -> ()
    forall a b. a -> b -> b
    `seq` NonEmpty LHsDocStringChunk -> ()
    forall a. NFData a => a -> ()
    rnf NonEmpty LHsDocStringChunk
    b
      rnf (NestedDocString HsDocStringDecorator
    a LHsDocStringChunk
    b) = HsDocStringDecorator -> ()
    forall a. NFData a => a -> ()
    rnf HsDocStringDecorator
    a () -> () -> ()
    forall a b. a -> b -> b
    `seq` LHsDocStringChunk -> ()
    forall a. NFData a => a -> ()
    rnf LHsDocStringChunk
    b
      rnf (GeneratedDocString HsDocStringChunk
    a) = HsDocStringChunk -> ()
    forall a. NFData a => a -> ()
    rnf HsDocStringChunk
    a

    -- | Annotate a pretty printed thing with its doc
    -- The docstring comes after if is 'HsDocStringPrevious'
    -- Otherwise it comes before.
    -- Note - we convert MultiLineDocString HsDocStringPrevious to HsDocStringNext
    -- because we can't control if something else will be pretty printed on the same line
    pprWithDocString :: HsDocString -> SDoc -> SDoc
    pprWithDocString :: HsDocString -> SDoc -> SDoc
    pprWithDocString  (MultiLineDocString HsDocStringDecorator
    HsDocStringPrevious NonEmpty LHsDocStringChunk
    ds) SDoc
    sd = HsDocString -> SDoc -> SDoc
    pprWithDocString (HsDocStringDecorator -> NonEmpty LHsDocStringChunk -> HsDocString
    MultiLineDocString HsDocStringDecorator
    HsDocStringNext NonEmpty LHsDocStringChunk
    ds) SDoc
    sd
    pprWithDocString doc :: HsDocString
    doc@(NestedDocString HsDocStringDecorator
    HsDocStringPrevious  LHsDocStringChunk
    _) SDoc
    sd = SDoc
    sd SDoc -> SDoc -> SDoc
    forall doc. IsLine doc => doc -> doc -> doc
    <+> HsDocString -> SDoc
    pprHsDocString HsDocString
    doc
    pprWithDocString HsDocString
    doc SDoc
    sd = HsDocString -> SDoc
    pprHsDocString HsDocString
    doc SDoc -> SDoc -> SDoc
    $+$ SDoc
    sd

    instance Binary HsDocString where
      put_ :: WriteBinHandle -> HsDocString -> IO ()
    put_ WriteBinHandle
    bh HsDocString
    x = case HsDocString
    x of
        MultiLineDocString HsDocStringDecorator
    dec NonEmpty LHsDocStringChunk
    xs -> do
          WriteBinHandle -> Word8 -> IO ()
    putByte WriteBinHandle
    bh Word8
    0
          WriteBinHandle -> HsDocStringDecorator -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh HsDocStringDecorator
    dec
          WriteBinHandle -> NonEmpty (BinLocated HsDocStringChunk) -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh (NonEmpty (BinLocated HsDocStringChunk) -> IO ())
    -> NonEmpty (BinLocated HsDocStringChunk) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ LHsDocStringChunk -> BinLocated HsDocStringChunk
    forall a. Located a -> BinLocated a
    BinLocated (LHsDocStringChunk -> BinLocated HsDocStringChunk)
    -> NonEmpty LHsDocStringChunk
    -> NonEmpty (BinLocated HsDocStringChunk)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> NonEmpty LHsDocStringChunk
    xs
        NestedDocString HsDocStringDecorator
    dec LHsDocStringChunk
    x -> do
          WriteBinHandle -> Word8 -> IO ()
    putByte WriteBinHandle
    bh Word8
    1
          WriteBinHandle -> HsDocStringDecorator -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh HsDocStringDecorator
    dec
          WriteBinHandle -> BinLocated HsDocStringChunk -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh (BinLocated HsDocStringChunk -> IO ())
    -> BinLocated HsDocStringChunk -> IO ()
    forall a b. (a -> b) -> a -> b
    $ LHsDocStringChunk -> BinLocated HsDocStringChunk
    forall a. Located a -> BinLocated a
    BinLocated LHsDocStringChunk
    x
        GeneratedDocString HsDocStringChunk
    x -> do
          WriteBinHandle -> Word8 -> IO ()
    putByte WriteBinHandle
    bh Word8
    2
          WriteBinHandle -> HsDocStringChunk -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh HsDocStringChunk
    x
      get :: ReadBinHandle -> IO HsDocString
    get ReadBinHandle
    bh = do
        tag <- ReadBinHandle -> IO Word8
    getByte ReadBinHandle
    bh
        case tag of
          Word8
    0 -> HsDocStringDecorator -> NonEmpty LHsDocStringChunk -> HsDocString
    MultiLineDocString (HsDocStringDecorator -> NonEmpty LHsDocStringChunk -> HsDocString)
    -> IO HsDocStringDecorator
    -> IO (NonEmpty LHsDocStringChunk -> HsDocString)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO HsDocStringDecorator
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh IO (NonEmpty LHsDocStringChunk -> HsDocString)
    -> IO (NonEmpty LHsDocStringChunk) -> IO HsDocString
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ((BinLocated HsDocStringChunk -> LHsDocStringChunk)
    -> NonEmpty (BinLocated HsDocStringChunk)
    -> NonEmpty LHsDocStringChunk
    forall a b. (a -> b) -> NonEmpty a -> NonEmpty b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap BinLocated HsDocStringChunk -> LHsDocStringChunk
    forall a. BinLocated a -> Located a
    unBinLocated (NonEmpty (BinLocated HsDocStringChunk)
     -> NonEmpty LHsDocStringChunk)
    -> IO (NonEmpty (BinLocated HsDocStringChunk))
    -> IO (NonEmpty LHsDocStringChunk)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO (NonEmpty (BinLocated HsDocStringChunk))
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh)
          Word8
    1 -> HsDocStringDecorator -> LHsDocStringChunk -> HsDocString
    NestedDocString (HsDocStringDecorator -> LHsDocStringChunk -> HsDocString)
    -> IO HsDocStringDecorator -> IO (LHsDocStringChunk -> HsDocString)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO HsDocStringDecorator
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh IO (LHsDocStringChunk -> HsDocString)
    -> IO LHsDocStringChunk -> IO HsDocString
    forall a b. IO (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (BinLocated HsDocStringChunk -> LHsDocStringChunk
    forall a. BinLocated a -> Located a
    unBinLocated (BinLocated HsDocStringChunk -> LHsDocStringChunk)
    -> IO (BinLocated HsDocStringChunk) -> IO LHsDocStringChunk
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO (BinLocated HsDocStringChunk)
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh)
          Word8
    2 -> HsDocStringChunk -> HsDocString
    GeneratedDocString (HsDocStringChunk -> HsDocString)
    -> IO HsDocStringChunk -> IO HsDocString
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO HsDocStringChunk
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh
          Word8
    t -> String -> IO HsDocString
    forall a. String -> IO a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail (String -> IO HsDocString) -> String -> IO HsDocString
    forall a b. (a -> b) -> a -> b
    $ String
    "HsDocString: invalid tag " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word8 -> String
    forall a. Show a => a -> String
    show Word8
    t

    data HsDocStringDecorator
      = HsDocStringNext -- ^ '|' is the decorator
      | HsDocStringPrevious -- ^ '^' is the decorator
      | HsDocStringNamed !String -- ^ '$<string>' is the decorator
      | HsDocStringGroup !Int -- ^ The decorator is the given number of '*'s
      deriving (HsDocStringDecorator -> HsDocStringDecorator -> Bool
    (HsDocStringDecorator -> HsDocStringDecorator -> Bool)
    -> (HsDocStringDecorator -> HsDocStringDecorator -> Bool)
    -> Eq HsDocStringDecorator
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    == :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    $c/= :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    /= :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    Eq, Eq HsDocStringDecorator
    Eq HsDocStringDecorator =>
    (HsDocStringDecorator -> HsDocStringDecorator -> Ordering)
    -> (HsDocStringDecorator -> HsDocStringDecorator -> Bool)
    -> (HsDocStringDecorator -> HsDocStringDecorator -> Bool)
    -> (HsDocStringDecorator -> HsDocStringDecorator -> Bool)
    -> (HsDocStringDecorator -> HsDocStringDecorator -> Bool)
    -> (HsDocStringDecorator
        -> HsDocStringDecorator -> HsDocStringDecorator)
    -> (HsDocStringDecorator
        -> HsDocStringDecorator -> HsDocStringDecorator)
    -> Ord HsDocStringDecorator
    HsDocStringDecorator -> HsDocStringDecorator -> Bool
    HsDocStringDecorator -> HsDocStringDecorator -> Ordering
    HsDocStringDecorator
    -> HsDocStringDecorator -> HsDocStringDecorator
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: HsDocStringDecorator -> HsDocStringDecorator -> Ordering
    compare :: HsDocStringDecorator -> HsDocStringDecorator -> Ordering
    $c< :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    < :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    $c<= :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    <= :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    $c> :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    > :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    $c>= :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    >= :: HsDocStringDecorator -> HsDocStringDecorator -> Bool
    $cmax :: HsDocStringDecorator
    -> HsDocStringDecorator -> HsDocStringDecorator
    max :: HsDocStringDecorator
    -> HsDocStringDecorator -> HsDocStringDecorator
    $cmin :: HsDocStringDecorator
    -> HsDocStringDecorator -> HsDocStringDecorator
    min :: HsDocStringDecorator
    -> HsDocStringDecorator -> HsDocStringDecorator
    Ord, Int -> HsDocStringDecorator -> ShowS
    [HsDocStringDecorator] -> ShowS
    HsDocStringDecorator -> String
    (Int -> HsDocStringDecorator -> ShowS)
    -> (HsDocStringDecorator -> String)
    -> ([HsDocStringDecorator] -> ShowS)
    -> Show HsDocStringDecorator
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> HsDocStringDecorator -> ShowS
    showsPrec :: Int -> HsDocStringDecorator -> ShowS
    $cshow :: HsDocStringDecorator -> String
    show :: HsDocStringDecorator -> String
    $cshowList :: [HsDocStringDecorator] -> ShowS
    showList :: [HsDocStringDecorator] -> ShowS
    Show, Typeable HsDocStringDecorator
    Typeable HsDocStringDecorator =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g)
     -> HsDocStringDecorator
     -> c HsDocStringDecorator)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c HsDocStringDecorator)
    -> (HsDocStringDecorator -> Constr)
    -> (HsDocStringDecorator -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c HsDocStringDecorator))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c HsDocStringDecorator))
    -> ((forall b. Data b => b -> b)
        -> HsDocStringDecorator -> HsDocStringDecorator)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r)
    -> (forall u.
        (forall d. Data d => d -> u) -> HsDocStringDecorator -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> HsDocStringDecorator -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d)
        -> HsDocStringDecorator -> m HsDocStringDecorator)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> HsDocStringDecorator -> m HsDocStringDecorator)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> HsDocStringDecorator -> m HsDocStringDecorator)
    -> Data HsDocStringDecorator
    HsDocStringDecorator -> Constr
    HsDocStringDecorator -> DataType
    (forall b. Data b => b -> b)
    -> HsDocStringDecorator -> HsDocStringDecorator
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u.
    Int -> (forall d. Data d => d -> u) -> HsDocStringDecorator -> u
    forall u.
    (forall d. Data d => d -> u) -> HsDocStringDecorator -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocStringDecorator
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> HsDocStringDecorator
    -> c HsDocStringDecorator
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocStringDecorator)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocStringDecorator)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> HsDocStringDecorator
    -> c HsDocStringDecorator
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> HsDocStringDecorator
    -> c HsDocStringDecorator
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocStringDecorator
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocStringDecorator
    $ctoConstr :: HsDocStringDecorator -> Constr
    toConstr :: HsDocStringDecorator -> Constr
    $cdataTypeOf :: HsDocStringDecorator -> DataType
    dataTypeOf :: HsDocStringDecorator -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocStringDecorator)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocStringDecorator)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocStringDecorator)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocStringDecorator)
    $cgmapT :: (forall b. Data b => b -> b)
    -> HsDocStringDecorator -> HsDocStringDecorator
    gmapT :: (forall b. Data b => b -> b)
    -> HsDocStringDecorator -> HsDocStringDecorator
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r
    $cgmapQ :: forall u.
    (forall d. Data d => d -> u) -> HsDocStringDecorator -> [u]
    gmapQ :: forall u.
    (forall d. Data d => d -> u) -> HsDocStringDecorator -> [u]
    $cgmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> HsDocStringDecorator -> u
    gmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> HsDocStringDecorator -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringDecorator -> m HsDocStringDecorator
    Data)

    instance Outputable HsDocStringDecorator where
      ppr :: HsDocStringDecorator -> SDoc
    ppr = String -> SDoc
    forall doc. IsLine doc => String -> doc
    text (String -> SDoc)
    -> (HsDocStringDecorator -> String) -> HsDocStringDecorator -> SDoc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . HsDocStringDecorator -> String
    printDecorator

    instance NFData HsDocStringDecorator where
      rnf :: HsDocStringDecorator -> ()
    rnf HsDocStringDecorator
    HsDocStringNext = ()
      rnf HsDocStringDecorator
    HsDocStringPrevious = ()
      rnf (HsDocStringNamed String
    x) = String -> ()
    forall a. NFData a => a -> ()
    rnf String
    x
      rnf (HsDocStringGroup Int
    x) = Int -> ()
    forall a. NFData a => a -> ()
    rnf Int
    x

    printDecorator :: HsDocStringDecorator -> String
    printDecorator :: HsDocStringDecorator -> String
    printDecorator HsDocStringDecorator
    HsDocStringNext = String
    "|"
    printDecorator HsDocStringDecorator
    HsDocStringPrevious = String
    "^"
    printDecorator (HsDocStringNamed String
    n) = Char
    '$'Char -> ShowS
    forall a. a -> [a] -> [a]
    :String
    n
    printDecorator (HsDocStringGroup Int
    n) = Int -> Char -> String
    forall a. Int -> a -> [a]
    replicate Int
    n Char
    '*'

    instance Binary HsDocStringDecorator where
      put_ :: WriteBinHandle -> HsDocStringDecorator -> IO ()
    put_ WriteBinHandle
    bh HsDocStringDecorator
    x = case HsDocStringDecorator
    x of
        HsDocStringDecorator
    HsDocStringNext -> WriteBinHandle -> Word8 -> IO ()
    putByte WriteBinHandle
    bh Word8
    0
        HsDocStringDecorator
    HsDocStringPrevious -> WriteBinHandle -> Word8 -> IO ()
    putByte WriteBinHandle
    bh Word8
    1
        HsDocStringNamed String
    n -> WriteBinHandle -> Word8 -> IO ()
    putByte WriteBinHandle
    bh Word8
    2 IO () -> IO () -> IO ()
    forall a b. IO a -> IO b -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> WriteBinHandle -> String -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh String
    n
        HsDocStringGroup Int
    n -> WriteBinHandle -> Word8 -> IO ()
    putByte WriteBinHandle
    bh Word8
    3 IO () -> IO () -> IO ()
    forall a b. IO a -> IO b -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> WriteBinHandle -> Int -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh Int
    n
      get :: ReadBinHandle -> IO HsDocStringDecorator
    get ReadBinHandle
    bh = do
        tag <- ReadBinHandle -> IO Word8
    getByte ReadBinHandle
    bh
        case tag of
          Word8
    0 -> HsDocStringDecorator -> IO HsDocStringDecorator
    forall a. a -> IO a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure HsDocStringDecorator
    HsDocStringNext
          Word8
    1 -> HsDocStringDecorator -> IO HsDocStringDecorator
    forall a. a -> IO a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure HsDocStringDecorator
    HsDocStringPrevious
          Word8
    2 -> String -> HsDocStringDecorator
    HsDocStringNamed (String -> HsDocStringDecorator)
    -> IO String -> IO HsDocStringDecorator
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO String
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh
          Word8
    3 -> Int -> HsDocStringDecorator
    HsDocStringGroup (Int -> HsDocStringDecorator) -> IO Int -> IO HsDocStringDecorator
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO Int
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh
          Word8
    t -> String -> IO HsDocStringDecorator
    forall a. String -> IO a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail (String -> IO HsDocStringDecorator)
    -> String -> IO HsDocStringDecorator
    forall a b. (a -> b) -> a -> b
    $ String
    "HsDocStringDecorator: invalid tag " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word8 -> String
    forall a. Show a => a -> String
    show Word8
    t

    type LHsDocStringChunk = Located HsDocStringChunk

    -- | A contiguous chunk of documentation
    newtype HsDocStringChunk = HsDocStringChunk ByteString
      deriving stock (HsDocStringChunk -> HsDocStringChunk -> Bool
    (HsDocStringChunk -> HsDocStringChunk -> Bool)
    -> (HsDocStringChunk -> HsDocStringChunk -> Bool)
    -> Eq HsDocStringChunk
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: HsDocStringChunk -> HsDocStringChunk -> Bool
    == :: HsDocStringChunk -> HsDocStringChunk -> Bool
    $c/= :: HsDocStringChunk -> HsDocStringChunk -> Bool
    /= :: HsDocStringChunk -> HsDocStringChunk -> Bool
    Eq,Eq HsDocStringChunk
    Eq HsDocStringChunk =>
    (HsDocStringChunk -> HsDocStringChunk -> Ordering)
    -> (HsDocStringChunk -> HsDocStringChunk -> Bool)
    -> (HsDocStringChunk -> HsDocStringChunk -> Bool)
    -> (HsDocStringChunk -> HsDocStringChunk -> Bool)
    -> (HsDocStringChunk -> HsDocStringChunk -> Bool)
    -> (HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk)
    -> (HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk)
    -> Ord HsDocStringChunk
    HsDocStringChunk -> HsDocStringChunk -> Bool
    HsDocStringChunk -> HsDocStringChunk -> Ordering
    HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: HsDocStringChunk -> HsDocStringChunk -> Ordering
    compare :: HsDocStringChunk -> HsDocStringChunk -> Ordering
    $c< :: HsDocStringChunk -> HsDocStringChunk -> Bool
    < :: HsDocStringChunk -> HsDocStringChunk -> Bool
    $c<= :: HsDocStringChunk -> HsDocStringChunk -> Bool
    <= :: HsDocStringChunk -> HsDocStringChunk -> Bool
    $c> :: HsDocStringChunk -> HsDocStringChunk -> Bool
    > :: HsDocStringChunk -> HsDocStringChunk -> Bool
    $c>= :: HsDocStringChunk -> HsDocStringChunk -> Bool
    >= :: HsDocStringChunk -> HsDocStringChunk -> Bool
    $cmax :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk
    max :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk
    $cmin :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk
    min :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk
    Ord,Typeable HsDocStringChunk
    Typeable HsDocStringChunk =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> HsDocStringChunk -> c HsDocStringChunk)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c HsDocStringChunk)
    -> (HsDocStringChunk -> Constr)
    -> (HsDocStringChunk -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c HsDocStringChunk))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c HsDocStringChunk))
    -> ((forall b. Data b => b -> b)
        -> HsDocStringChunk -> HsDocStringChunk)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r)
    -> (forall u.
        (forall d. Data d => d -> u) -> HsDocStringChunk -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> HsDocStringChunk -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d)
        -> HsDocStringChunk -> m HsDocStringChunk)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> HsDocStringChunk -> m HsDocStringChunk)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> HsDocStringChunk -> m HsDocStringChunk)
    -> Data HsDocStringChunk
    HsDocStringChunk -> Constr
    HsDocStringChunk -> DataType
    (forall b. Data b => b -> b)
    -> HsDocStringChunk -> HsDocStringChunk
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u.
    Int -> (forall d. Data d => d -> u) -> HsDocStringChunk -> u
    forall u. (forall d. Data d => d -> u) -> HsDocStringChunk -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocStringChunk
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HsDocStringChunk -> c HsDocStringChunk
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocStringChunk)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocStringChunk)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HsDocStringChunk -> c HsDocStringChunk
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> HsDocStringChunk -> c HsDocStringChunk
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocStringChunk
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c HsDocStringChunk
    $ctoConstr :: HsDocStringChunk -> Constr
    toConstr :: HsDocStringChunk -> Constr
    $cdataTypeOf :: HsDocStringChunk -> DataType
    dataTypeOf :: HsDocStringChunk -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocStringChunk)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c HsDocStringChunk)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocStringChunk)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c HsDocStringChunk)
    $cgmapT :: (forall b. Data b => b -> b)
    -> HsDocStringChunk -> HsDocStringChunk
    gmapT :: (forall b. Data b => b -> b)
    -> HsDocStringChunk -> HsDocStringChunk
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> HsDocStringChunk -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> HsDocStringChunk -> [u]
    $cgmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> HsDocStringChunk -> u
    gmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> HsDocStringChunk -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> HsDocStringChunk -> m HsDocStringChunk
    Data, Int -> HsDocStringChunk -> ShowS
    [HsDocStringChunk] -> ShowS
    HsDocStringChunk -> String
    (Int -> HsDocStringChunk -> ShowS)
    -> (HsDocStringChunk -> String)
    -> ([HsDocStringChunk] -> ShowS)
    -> Show HsDocStringChunk
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> HsDocStringChunk -> ShowS
    showsPrec :: Int -> HsDocStringChunk -> ShowS
    $cshow :: HsDocStringChunk -> String
    show :: HsDocStringChunk -> String
    $cshowList :: [HsDocStringChunk] -> ShowS
    showList :: [HsDocStringChunk] -> ShowS
    Show)
      deriving newtype (HsDocStringChunk -> ()
    (HsDocStringChunk -> ()) -> NFData HsDocStringChunk
    forall a. (a -> ()) -> NFData a
    $crnf :: HsDocStringChunk -> ()
    rnf :: HsDocStringChunk -> ()
    NFData)

    instance Binary HsDocStringChunk where
      put_ :: WriteBinHandle -> HsDocStringChunk -> IO ()
    put_ WriteBinHandle
    bh (HsDocStringChunk ByteString
    bs) = WriteBinHandle -> ByteString -> IO ()
    forall a. Binary a => WriteBinHandle -> a -> IO ()
    put_ WriteBinHandle
    bh ByteString
    bs
      get :: ReadBinHandle -> IO HsDocStringChunk
    get ReadBinHandle
    bh = ByteString -> HsDocStringChunk
    HsDocStringChunk (ByteString -> HsDocStringChunk)
    -> IO ByteString -> IO HsDocStringChunk
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ReadBinHandle -> IO ByteString
    forall a. Binary a => ReadBinHandle -> IO a
    get ReadBinHandle
    bh

    instance Outputable HsDocStringChunk where
      ppr :: HsDocStringChunk -> SDoc
    ppr = String -> SDoc
    forall doc. IsLine doc => String -> doc
    text (String -> SDoc)
    -> (HsDocStringChunk -> String) -> HsDocStringChunk -> SDoc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . HsDocStringChunk -> String
    unpackHDSC

    mkHsDocStringChunk :: String -> HsDocStringChunk
    mkHsDocStringChunk :: String -> HsDocStringChunk
    mkHsDocStringChunk String
    s = ByteString -> HsDocStringChunk
    HsDocStringChunk (String -> ByteString
    utf8EncodeByteString String
    s)

    -- | Create a 'HsDocString' from a UTF8-encoded 'ByteString'.
    mkHsDocStringChunkUtf8ByteString :: ByteString -> HsDocStringChunk
    mkHsDocStringChunkUtf8ByteString :: ByteString -> HsDocStringChunk
    mkHsDocStringChunkUtf8ByteString = ByteString -> HsDocStringChunk
    HsDocStringChunk

    unpackHDSC :: HsDocStringChunk -> String
    unpackHDSC :: HsDocStringChunk -> String
    unpackHDSC (HsDocStringChunk ByteString
    bs) = ByteString -> String
    utf8DecodeByteString ByteString
    bs

    nullHDSC :: HsDocStringChunk -> Bool
    nullHDSC :: HsDocStringChunk -> Bool
    nullHDSC (HsDocStringChunk ByteString
    bs) = ByteString -> Bool
    BS.null ByteString
    bs

    mkGeneratedHsDocString :: String -> HsDocString
    mkGeneratedHsDocString :: String -> HsDocString
    mkGeneratedHsDocString = HsDocStringChunk -> HsDocString
    GeneratedDocString (HsDocStringChunk -> HsDocString)
    -> (String -> HsDocStringChunk) -> String -> HsDocString
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> HsDocStringChunk
    mkHsDocStringChunk

    isEmptyDocString :: HsDocString -> Bool
    isEmptyDocString :: HsDocString -> Bool
    isEmptyDocString (MultiLineDocString HsDocStringDecorator
    _ NonEmpty LHsDocStringChunk
    xs) = (LHsDocStringChunk -> Bool) -> NonEmpty LHsDocStringChunk -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all (HsDocStringChunk -> Bool
    nullHDSC (HsDocStringChunk -> Bool)
    -> (LHsDocStringChunk -> HsDocStringChunk)
    -> LHsDocStringChunk
    -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LHsDocStringChunk -> HsDocStringChunk
    forall l e. GenLocated l e -> e
    unLoc) NonEmpty LHsDocStringChunk
    xs
    isEmptyDocString (NestedDocString HsDocStringDecorator
    _ LHsDocStringChunk
    s) = HsDocStringChunk -> Bool
    nullHDSC (HsDocStringChunk -> Bool) -> HsDocStringChunk -> Bool
    forall a b. (a -> b) -> a -> b
    $ LHsDocStringChunk -> HsDocStringChunk
    forall l e. GenLocated l e -> e
    unLoc LHsDocStringChunk
    s
    isEmptyDocString (GeneratedDocString HsDocStringChunk
    x) = HsDocStringChunk -> Bool
    nullHDSC HsDocStringChunk
    x

    docStringChunks :: HsDocString -> [LHsDocStringChunk]
    docStringChunks :: HsDocString -> [LHsDocStringChunk]
    docStringChunks (MultiLineDocString HsDocStringDecorator
    _ (LHsDocStringChunk
    x:|[LHsDocStringChunk]
    xs)) = LHsDocStringChunk
    xLHsDocStringChunk -> [LHsDocStringChunk] -> [LHsDocStringChunk]
    forall a. a -> [a] -> [a]
    :[LHsDocStringChunk]
    xs
    docStringChunks (NestedDocString HsDocStringDecorator
    _ LHsDocStringChunk
    x) = [LHsDocStringChunk
    x]
    docStringChunks (GeneratedDocString HsDocStringChunk
    x) = [SrcSpan -> HsDocStringChunk -> LHsDocStringChunk
    forall l e. l -> e -> GenLocated l e
    L (UnhelpfulSpanReason -> SrcSpan
    UnhelpfulSpan UnhelpfulSpanReason
    UnhelpfulGenerated) HsDocStringChunk
    x]

    -- | Pretty print with decorators, exactly as the user wrote it
    pprHsDocString :: HsDocString -> SDoc
    pprHsDocString :: HsDocString -> SDoc
    pprHsDocString = String -> SDoc
    forall doc. IsLine doc => String -> doc
    text (String -> SDoc) -> (HsDocString -> String) -> HsDocString -> SDoc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . HsDocString -> String
    exactPrintHsDocString

    pprHsDocStrings :: [HsDocString] -> SDoc
    pprHsDocStrings :: [HsDocString] -> SDoc
    pprHsDocStrings = String -> SDoc
    forall doc. IsLine doc => String -> doc
    text (String -> SDoc)
    -> ([HsDocString] -> String) -> [HsDocString] -> SDoc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate String
    "\n\n" ([String] -> String)
    -> ([HsDocString] -> [String]) -> [HsDocString] -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (HsDocString -> String) -> [HsDocString] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map HsDocString -> String
    exactPrintHsDocString

    -- | Pretty print with decorators, exactly as the user wrote it
    exactPrintHsDocString :: HsDocString -> String
    exactPrintHsDocString :: HsDocString -> String
    exactPrintHsDocString (MultiLineDocString HsDocStringDecorator
    dec (LHsDocStringChunk
    x :| [LHsDocStringChunk]
    xs))
      = [String] -> String
    unlines' ([String] -> String) -> [String] -> String
    forall a b. (a -> b) -> a -> b
    $ (String
    "-- " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HsDocStringDecorator -> String
    printDecorator HsDocStringDecorator
    dec String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HsDocStringChunk -> String
    unpackHDSC (LHsDocStringChunk -> HsDocStringChunk
    forall l e. GenLocated l e -> e
    unLoc LHsDocStringChunk
    x))
                String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : (LHsDocStringChunk -> String) -> [LHsDocStringChunk] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (\LHsDocStringChunk
    x -> String
    "--" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HsDocStringChunk -> String
    unpackHDSC (LHsDocStringChunk -> HsDocStringChunk
    forall l e. GenLocated l e -> e
    unLoc LHsDocStringChunk
    x)) [LHsDocStringChunk]
    xs
    exactPrintHsDocString (NestedDocString HsDocStringDecorator
    dec (L SrcSpan
    _ HsDocStringChunk
    s))
      = String
    "{-" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HsDocStringDecorator -> String
    printDecorator HsDocStringDecorator
    dec String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HsDocStringChunk -> String
    unpackHDSC HsDocStringChunk
    s String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    "-}"
    exactPrintHsDocString (GeneratedDocString HsDocStringChunk
    x) = case String -> [String]
    lines (HsDocStringChunk -> String
    unpackHDSC HsDocStringChunk
    x) of
      [] -> String
    ""
      (String
    x:[String]
    xs) -> [String] -> String
    unlines' ([String] -> String) -> [String] -> String
    forall a b. (a -> b) -> a -> b
    $ ( String
    "-- |" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    x)
                        String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : ShowS -> [String] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (\String
    y -> String
    "--"String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++String
    y) [String]
    xs

    -- | Just get the docstring, without any decorators
    renderHsDocString :: HsDocString -> String
    renderHsDocString :: HsDocString -> String
    renderHsDocString (MultiLineDocString HsDocStringDecorator
    _ (LHsDocStringChunk
    x :| [LHsDocStringChunk]
    xs)) = [String] -> String
    unlines' ([String] -> String) -> [String] -> String
    forall a b. (a -> b) -> a -> b
    $ (LHsDocStringChunk -> String) -> [LHsDocStringChunk] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (HsDocStringChunk -> String
    unpackHDSC (HsDocStringChunk -> String)
    -> (LHsDocStringChunk -> HsDocStringChunk)
    -> LHsDocStringChunk
    -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . LHsDocStringChunk -> HsDocStringChunk
    forall l e. GenLocated l e -> e
    unLoc) (LHsDocStringChunk
    xLHsDocStringChunk -> [LHsDocStringChunk] -> [LHsDocStringChunk]
    forall a. a -> [a] -> [a]
    :[LHsDocStringChunk]
    xs)
    renderHsDocString (NestedDocString HsDocStringDecorator
    _ LHsDocStringChunk
    ds) = HsDocStringChunk -> String
    unpackHDSC (HsDocStringChunk -> String) -> HsDocStringChunk -> String
    forall a b. (a -> b) -> a -> b
    $ LHsDocStringChunk -> HsDocStringChunk
    forall l e. GenLocated l e -> e
    unLoc LHsDocStringChunk
    ds
    renderHsDocString (GeneratedDocString HsDocStringChunk
    x) = HsDocStringChunk -> String
    unpackHDSC HsDocStringChunk
    x

    -- | Don't add a newline to a single string
    unlines' :: [String] -> String
    unlines' :: [String] -> String
    unlines' = String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate String
    "\n"

    -- | Just get the docstring, without any decorators
    -- Separates docstrings using "\n\n", which is how haddock likes to render them
    renderHsDocStrings :: [HsDocString] -> String
    renderHsDocStrings :: [HsDocString] -> String
    renderHsDocStrings = String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate String
    "\n\n" ([String] -> String)
    -> ([HsDocString] -> [String]) -> [HsDocString] -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (HsDocString -> String) -> [HsDocString] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map HsDocString -> String
    renderHsDocString