ghc-9.6.0.20230302: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

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
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

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 #

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
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

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

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
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

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

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