ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

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

# 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

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 #
NFData HsDocString Source # |
Instance details Defined in GHC.Hs.DocString Methods rnf :: HsDocString -> () Source #
Binary HsDocString Source # |
Instance details Defined in GHC.Hs.DocString Methods put_ :: BinHandle -> HsDocString -> IO () Source # put :: BinHandle -> HsDocString -> IO (Bin HsDocString) Source # get :: BinHandle -> 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 # (/=) :: HsDocString -> HsDocString -> Bool #

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

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 #
NFData HsDocStringDecorator Source # |
Instance details Defined in GHC.Hs.DocString Methods rnf :: HsDocStringDecorator -> () Source #
Binary HsDocStringDecorator Source # |
Instance details Defined in GHC.Hs.DocString Methods put_ :: BinHandle -> HsDocStringDecorator -> IO () Source # put :: BinHandle -> HsDocStringDecorator -> IO (Bin HsDocStringDecorator) Source # get :: BinHandle -> 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 # (/=) :: HsDocStringDecorator -> HsDocStringDecorator -> Bool #
Ord HsDocStringDecorator Source # |

Instance details

Defined in GHC.Hs.DocString

Methods

compare :: HsDocStringDecorator -> HsDocStringDecorator -> Ordering #

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

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

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

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

max :: HsDocStringDecorator -> HsDocStringDecorator -> HsDocStringDecorator #

min :: HsDocStringDecorator -> HsDocStringDecorator -> HsDocStringDecorator #

newtype HsDocStringChunk Source #

A contiguous chunk of documentation

Constructors

HsDocStringChunk ByteString |

#### Instances

Instances details

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 #
NFData HsDocStringChunk Source # |
Instance details Defined in GHC.Hs.DocString Methods rnf :: HsDocStringChunk -> () Source #
Binary HsDocStringChunk Source # |
Instance details Defined in GHC.Hs.DocString Methods put_ :: BinHandle -> HsDocStringChunk -> IO () Source # put :: BinHandle -> HsDocStringChunk -> IO (Bin HsDocStringChunk) Source # get :: BinHandle -> 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 # (/=) :: HsDocStringChunk -> HsDocStringChunk -> Bool #
Ord HsDocStringChunk Source # |

Instance details

Defined in GHC.Hs.DocString

Methods

compare :: HsDocStringChunk -> HsDocStringChunk -> Ordering #

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

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

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

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

max :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk #

min :: HsDocStringChunk -> HsDocStringChunk -> HsDocStringChunk #

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