ghc-9.13: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.Hs.DocString

Description

An exactprintable structure for docstrings

Synopsis

Documentation

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 #

Binary HsDocString Source # 
Instance details

Defined in GHC.Hs.DocString

Outputable HsDocString Source # 
Instance details

Defined in GHC.Hs.DocString

Methods

ppr :: HsDocString -> SDoc 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 #

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

toConstr :: HsDocString -> Constr #

dataTypeOf :: HsDocString -> DataType #

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

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

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

gmapQl :: (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 #

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

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

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

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

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

Show HsDocString Source # 
Instance details

Defined in GHC.Hs.DocString

Eq HsDocString Source # 
Instance details

Defined in GHC.Hs.DocString

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

Binary HsDocStringDecorator Source # 
Instance details

Defined in GHC.Hs.DocString

Outputable HsDocStringDecorator Source # 
Instance details

Defined in GHC.Hs.DocString

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 #

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

toConstr :: HsDocStringDecorator -> Constr #

dataTypeOf :: HsDocStringDecorator -> DataType #

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

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

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

gmapQl :: (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 #

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

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

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

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

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

Show HsDocStringDecorator Source # 
Instance details

Defined in GHC.Hs.DocString

Eq HsDocStringDecorator Source # 
Instance details

Defined in GHC.Hs.DocString

Ord HsDocStringDecorator Source # 
Instance details

Defined in GHC.Hs.DocString

newtype HsDocStringChunk Source #

A contiguous chunk of documentation

Instances

Instances details
NFData HsDocStringChunk Source # 
Instance details

Defined in GHC.Hs.DocString

Methods

rnf :: HsDocStringChunk -> () Source #

Binary HsDocStringChunk Source # 
Instance details

Defined in GHC.Hs.DocString

Outputable HsDocStringChunk Source # 
Instance details

Defined in GHC.Hs.DocString

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 #

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

toConstr :: HsDocStringChunk -> Constr #

dataTypeOf :: HsDocStringChunk -> DataType #

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

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

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

gmapQl :: (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 #

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

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

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

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

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

Show HsDocStringChunk Source # 
Instance details

Defined in GHC.Hs.DocString

Eq HsDocStringChunk Source # 
Instance details

Defined in GHC.Hs.DocString

Ord HsDocStringChunk Source # 
Instance details

Defined in GHC.Hs.DocString

pprHsDocString :: HsDocString -> SDoc Source #

Pretty print with decorators, exactly as the user wrote it

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