ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Hs.DocString

Description

An exactprintable structure for docstrings

Synopsis

- type LHsDocString = Located HsDocString
- data HsDocString
  - = MultiLineDocString !HsDocStringDecorator !(NonEmpty LHsDocStringChunk)
  - | NestedDocString !HsDocStringDecorator LHsDocStringChunk
  - | GeneratedDocString HsDocStringChunk
- data HsDocStringDecorator
  - = HsDocStringNext
  - | HsDocStringPrevious
  - | HsDocStringNamed !String
  - | HsDocStringGroup !Int
- newtype HsDocStringChunk = HsDocStringChunk ByteString
- type LHsDocStringChunk = Located HsDocStringChunk
- isEmptyDocString :: HsDocString -> Bool
- unpackHDSC :: HsDocStringChunk -> String
- mkHsDocStringChunk :: String -> HsDocStringChunk
- mkHsDocStringChunkUtf8ByteString :: ByteString -> HsDocStringChunk
- pprHsDocString :: HsDocString -> SDoc
- pprHsDocStrings :: [HsDocString] -> SDoc
- mkGeneratedHsDocString :: String -> HsDocString
- docStringChunks :: HsDocString -> [LHsDocStringChunk]
- renderHsDocString :: HsDocString -> String
- renderHsDocStrings :: [HsDocString] -> String
- exactPrintHsDocString :: HsDocString -> String
- pprWithDocString :: HsDocString -> SDoc -> SDoc
- printDecorator :: HsDocStringDecorator -> String

# Documentation

type LHsDocString = Located HsDocString Source #

data HsDocString Source #

Haskell Documentation String

Rich structure to support exact printing The location around each chunk doesn't include the decorators

Constructors

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`

#### Instances

Instances details

NFData HsDocString Source # |
Instance details Defined in GHC.Hs.DocString Methods rnf :: HsDocString -> () Source #
Data HsDocString Source # |

Instance details

Defined in GHC.Hs.DocString

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsDocString -> c HsDocString Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c HsDocString Source #

toConstr :: HsDocString -> Constr Source #

dataTypeOf :: HsDocString -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c HsDocString) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsDocString) Source #

gmapT :: (forall b. Data b => b -> b) -> HsDocString -> HsDocString Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsDocString -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsDocString -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> HsDocString -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> HsDocString -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsDocString -> m HsDocString Source #

Show HsDocString Source # |
Instance details Defined in GHC.Hs.DocString Methods showsPrec :: Int -> HsDocString -> ShowS Source # show :: HsDocString -> String Source # showList :: [HsDocString] -> ShowS Source #
Binary HsDocString Source # |
Instance details Defined in GHC.Hs.DocString Methods put_ :: WriteBinHandle -> HsDocString -> IO () Source # put :: WriteBinHandle -> HsDocString -> IO (Bin HsDocString) Source # get :: ReadBinHandle -> IO HsDocString Source #
Outputable HsDocString Source # |
Instance details Defined in GHC.Hs.DocString Methods ppr :: HsDocString -> SDoc Source #
Eq HsDocString Source # |
Instance details Defined in GHC.Hs.DocString Methods (==) :: HsDocString -> HsDocString -> Bool Source # (/=) :: HsDocString -> HsDocString -> Bool Source #

data HsDocStringDecorator Source #

Constructors

HsDocStringNext | '|' is the decorator
HsDocStringPrevious | `^` is the decorator
HsDocStringNamed !String | '$string' is the decorator
HsDocStringGroup !Int | The decorator is the given number of `*`s

#### Instances

Instances details

NFData HsDocStringDecorator Source # |
Instance details Defined in GHC.Hs.DocString Methods rnf :: HsDocStringDecorator -> () Source #
Data HsDocStringDecorator Source # |

Instance details

Defined in GHC.Hs.DocString

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsDocStringDecorator -> c HsDocStringDecorator Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c HsDocStringDecorator Source #

toConstr :: HsDocStringDecorator -> Constr Source #

dataTypeOf :: HsDocStringDecorator -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c HsDocStringDecorator) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsDocStringDecorator) Source #

gmapT :: (forall b. Data b => b -> b) -> HsDocStringDecorator -> HsDocStringDecorator Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsDocStringDecorator -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> HsDocStringDecorator -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> HsDocStringDecorator -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsDocStringDecorator -> m HsDocStringDecorator Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsDocStringDecorator -> m HsDocStringDecorator Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsDocStringDecorator -> m HsDocStringDecorator Source #

Show HsDocStringDecorator Source # |
Instance details Defined in GHC.Hs.DocString Methods showsPrec :: Int -> HsDocStringDecorator -> ShowS Source # show :: HsDocStringDecorator -> String Source # showList :: [HsDocStringDecorator] -> ShowS Source #
Binary HsDocStringDecorator Source # |
Instance details Defined in GHC.Hs.DocString Methods put_ :: WriteBinHandle -> HsDocStringDecorator -> IO () Source # put :: WriteBinHandle -> HsDocStringDecorator -> IO (Bin HsDocStringDecorator) Source # get :: ReadBinHandle -> IO HsDocStringDecorator Source #
Outputable HsDocStringDecorator Source # |
Instance details Defined in GHC.Hs.DocString Methods ppr :: HsDocStringDecorator -> SDoc Source #
Eq HsDocStringDecorator Source # |
Instance details Defined in GHC.Hs.DocString Methods (==) :: HsDocStringDecorator -> HsDocStringDecorator -> Bool Source # (/=) :: HsDocStringDecorator -> HsDocStringDecorator -> Bool Source #
Ord HsDocStringDecorator Source # |

Instance details

Defined in GHC.Hs.DocString

Methods

compare :: HsDocStringDecorator -> HsDocStringDecorator -> Ordering Source #

(<) :: HsDocStringDecorator -> HsDocStringDecorator -> Bool Source #

(<=) :: HsDocStringDecorator -> HsDocStringDecorator -> Bool Source #

(>) :: HsDocStringDecorator -> HsDocStringDecorator -> Bool Source #

(>=) :: HsDocStringDecorator -> HsDocStringDecorator -> Bool Source #

max :: HsDocStringDecorator -> HsDocStringDecorator -> HsDocStringDecorator Source #

min :: HsDocStringDecorator -> HsDocStringDecorator -> HsDocStringDecorator Source #

newtype HsDocStringChunk Source #

A contiguous chunk of documentation

Constructors

HsDocStringChunk ByteString |

#### Instances

Instances details

NFData HsDocStringChunk Source # |
Instance details Defined in GHC.Hs.DocString Methods rnf :: HsDocStringChunk -> () Source #
Data HsDocStringChunk Source # |

Instance details

Defined in GHC.Hs.DocString

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsDocStringChunk -> c HsDocStringChunk Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c HsDocStringChunk Source #

toConstr :: HsDocStringChunk -> Constr Source #

dataTypeOf :: HsDocStringChunk -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c HsDocStringChunk) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsDocStringChunk) Source #

gmapT :: (forall b. Data b => b -> b) -> HsDocStringChunk -> HsDocStringChunk Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsDocStringChunk -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> HsDocStringChunk -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> HsDocStringChunk -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsDocStringChunk -> m HsDocStringChunk Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsDocStringChunk -> m HsDocStringChunk Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsDocStringChunk -> m HsDocStringChunk Source #

Show HsDocStringChunk Source # |
Instance details Defined in GHC.Hs.DocString Methods showsPrec :: Int -> HsDocStringChunk -> ShowS Source # show :: HsDocStringChunk -> String Source # showList :: [HsDocStringChunk] -> ShowS Source #
Binary HsDocStringChunk Source # |
Instance details Defined in GHC.Hs.DocString Methods put_ :: WriteBinHandle -> HsDocStringChunk -> IO () Source # put :: WriteBinHandle -> HsDocStringChunk -> IO (Bin HsDocStringChunk) Source # get :: ReadBinHandle -> IO HsDocStringChunk Source #
Outputable HsDocStringChunk Source # |
Instance details Defined in GHC.Hs.DocString Methods ppr :: HsDocStringChunk -> SDoc Source #
Eq HsDocStringChunk Source # |
Instance details Defined in GHC.Hs.DocString Methods (==) :: HsDocStringChunk -> HsDocStringChunk -> Bool Source # (/=) :: HsDocStringChunk -> HsDocStringChunk -> Bool Source #
Ord HsDocStringChunk Source # |

Instance details

Defined in GHC.Hs.DocString

Methods

compare :: HsDocStringChunk -> HsDocStringChunk -> Ordering Source #

(<) :: HsDocStringChunk -> HsDocStringChunk -> Bool Source #

(<=) :: HsDocStringChunk -> HsDocStringChunk -> Bool Source #

(>) :: HsDocStringChunk -> HsDocStringChunk -> Bool Source #

(>=) :: HsDocStringChunk -> HsDocStringChunk -> Bool Source #

max :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk Source #

min :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk Source #

type LHsDocStringChunk = Located HsDocStringChunk Source #

isEmptyDocString :: HsDocString -> Bool Source #

unpackHDSC :: HsDocStringChunk -> String Source #

mkHsDocStringChunk :: String -> HsDocStringChunk Source #

mkHsDocStringChunkUtf8ByteString :: ByteString -> HsDocStringChunk Source #

Create a `HsDocString` from a UTF8-encoded `ByteString`.

pprHsDocString :: HsDocString -> SDoc Source #

Pretty print with decorators, exactly as the user wrote it

pprHsDocStrings :: [HsDocString] -> SDoc Source #

mkGeneratedHsDocString :: String -> HsDocString Source #

docStringChunks :: HsDocString -> [LHsDocStringChunk] Source #

renderHsDocString :: HsDocString -> String Source #

Just get the docstring, without any decorators

renderHsDocStrings :: [HsDocString] -> String Source #

Just get the docstring, without any decorators Separates docstrings using "nn", which is how haddock likes to render them

exactPrintHsDocString :: HsDocString -> String Source #

Pretty print with decorators, exactly as the user wrote it

pprWithDocString :: HsDocString -> SDoc -> SDoc Source #

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

printDecorator :: HsDocStringDecorator -> String Source #