ormolu-0.1.2.0: A formatter for Haskell source code

Safe Haskell | None
Language | Haskell2010

Ormolu.Utils

Description

Random utilities used by the code.

Synopsis

- data RelativePos
  - = SinglePos
  - | FirstPos
  - | MiddlePos
  - | LastPos
- attachRelativePos :: [a] -> [(RelativePos, a)]
- combineSrcSpans' :: NonEmpty SrcSpan -> SrcSpan
- notImplemented :: String -> a
- showOutputable :: Outputable o => o -> String
- splitDocString :: HsDocString -> [Text]
- typeArgToType :: LHsTypeArg p -> LHsType p
- unSrcSpan :: SrcSpan -> Maybe RealSrcSpan
- incSpanLine :: Int -> SrcSpan -> SrcSpan
- separatedByBlank :: (a -> SrcSpan) -> a -> a -> Bool
- separatedByBlankNE :: (a -> SrcSpan) -> NonEmpty a -> NonEmpty a -> Bool
- onTheSameLine :: SrcSpan -> SrcSpan -> Bool
- removeIndentation :: String -> (String, Int)

# Documentation

data RelativePos Source #

Relative positions in a list.

Constructors

SinglePos |
FirstPos |
MiddlePos |
LastPos |

#### Instances

Instances details

Eq RelativePos Source # |
Instance details Defined in Ormolu.Utils Methods (==) :: RelativePos -> RelativePos -> Bool Source # (/=) :: RelativePos -> RelativePos -> Bool Source #
Show RelativePos Source # |
Instance details Defined in Ormolu.Utils Methods showsPrec :: Int -> RelativePos -> ShowS Source # show :: RelativePos -> String Source # showList :: [RelativePos] -> ShowS Source #

attachRelativePos :: [a] -> [(RelativePos, a)] Source #

Attach `RelativePos`es to elements of a given list.

combineSrcSpans' :: NonEmpty SrcSpan -> SrcSpan Source #

Combine all source spans from the given list.

notImplemented :: String -> a Source #

Placeholder for things that are not yet implemented.

showOutputable :: Outputable o => o -> String Source #

Pretty-print an `Outputable` thing.

splitDocString :: HsDocString -> [Text] Source #

Split and normalize a doc string. The result is a list of lines that make up the comment.

typeArgToType :: LHsTypeArg p -> LHsType p Source #

Get `LHsType` out of `LHsTypeArg`.

unSrcSpan :: SrcSpan -> Maybe RealSrcSpan Source #

Get `RealSrcSpan` out of `SrcSpan` if the span is “helpful”.

incSpanLine :: Int -> SrcSpan -> SrcSpan Source #

Increment line number in a `SrcSpan`.

separatedByBlank :: (a -> SrcSpan) -> a -> a -> Bool Source #

Do two declarations have a blank between them?

separatedByBlankNE :: (a -> SrcSpan) -> NonEmpty a -> NonEmpty a -> Bool Source #

Do two declaration groups have a blank between them?

onTheSameLine :: SrcSpan -> SrcSpan -> Bool Source #

Return `True` if one span ends on the same line the second one starts.

removeIndentation :: String -> (String, Int) Source #

Remove indentation from a given `String`. Return the input with indentation removed and the detected indentation level.