floskell-0.11.1: A flexible Haskell source code pretty printer

Safe Haskell | None
Language | Haskell2010

Floskell.Types

Description

All types.

Synopsis

- data OutputRestriction
  - = Anything
  - | NoOverflow
  - | NoOverflowOrLinebreak
- data TypeLayout
  - = TypeFree
  - | TypeFlex
  - | TypeVertical
- newtype Penalty = Penalty Int
- newtype TabStop = TabStop String
- newtype Printer a = Printer {
  - unPrinter :: StateT PrintState (Search Penalty) a
  }
- execPrinter :: Printer a -> PrintState -> Maybe (Penalty, PrintState)
- runPrinter :: Printer a -> PrintState -> Maybe (Penalty, (a, PrintState))
- data PrintState = PrintState {
  - psBuffer :: !Buffer
  - psIndentLevel :: !Int
  - psOnside :: !Int
  - psTabStops :: !(Map TabStop Int)
  - psConfig :: !Config
  - psEolComment :: !Bool
  - psOutputRestriction :: !OutputRestriction
  - psTypeLayout :: !TypeLayout
  }
- psLine :: PrintState -> Int
- psColumn :: PrintState -> Int
- psNewline :: PrintState -> Bool
- initialPrintState :: Config -> PrintState
- data Config = Config {
  - cfgPenalty :: !PenaltyConfig
  - cfgAlign :: !AlignConfig
  - cfgIndent :: !IndentConfig
  - cfgLayout :: !LayoutConfig
  - cfgOp :: !OpConfig
  - cfgGroup :: !GroupConfig
  - cfgOptions :: !OptionConfig
  }
- data SrcSpan = SrcSpan {
  - srcSpanFilename :: String
  - srcSpanStartLine :: Int
  - srcSpanStartColumn :: Int
  - srcSpanEndLine :: Int
  - srcSpanEndColumn :: Int
  }
- data CommentType
  - = InlineComment
  - | LineComment
  - | PreprocessorDirective
  - | IgnoredLine
- data Comment = Comment {
  - commentType :: !CommentType
  - commentSpan :: !SrcSpan
  - commentText :: !String
  }
- data NodeInfo = NodeInfo {
  - nodeInfoSpan :: !SrcSpan
  - nodeInfoLeadingComments :: ![Comment]
  - nodeInfoTrailingComments :: ![Comment]
  }
- noNodeInfo :: NodeInfo
- nodeSpan :: Annotated ast => ast NodeInfo -> SrcSpan
- data Location
  - = Before
  - | After

# Documentation

data OutputRestriction #

Constructors

Anything |
NoOverflow |
NoOverflowOrLinebreak |

#### Instances

Instances details

Show OutputRestriction # |
Instance details Defined in Floskell.Types Methods showsPrec :: Int -> OutputRestriction -> ShowS # show :: OutputRestriction -> String # showList :: [OutputRestriction] -> ShowS #
Eq OutputRestriction # |
Instance details Defined in Floskell.Types Methods (==) :: OutputRestriction -> OutputRestriction -> Bool # (/=) :: OutputRestriction -> OutputRestriction -> Bool #
Ord OutputRestriction # |
Instance details Defined in Floskell.Types Methods compare :: OutputRestriction -> OutputRestriction -> Ordering # (<) :: OutputRestriction -> OutputRestriction -> Bool # (<=) :: OutputRestriction -> OutputRestriction -> Bool # (>) :: OutputRestriction -> OutputRestriction -> Bool # (>=) :: OutputRestriction -> OutputRestriction -> Bool # max :: OutputRestriction -> OutputRestriction -> OutputRestriction # min :: OutputRestriction -> OutputRestriction -> OutputRestriction #

data TypeLayout #

Constructors

TypeFree |
TypeFlex |
TypeVertical |

#### Instances

Instances details

Show TypeLayout # |
Instance details Defined in Floskell.Types Methods showsPrec :: Int -> TypeLayout -> ShowS # show :: TypeLayout -> String # showList :: [TypeLayout] -> ShowS #
Eq TypeLayout # |
Instance details Defined in Floskell.Types Methods (==) :: TypeLayout -> TypeLayout -> Bool # (/=) :: TypeLayout -> TypeLayout -> Bool #
Ord TypeLayout # |
Instance details Defined in Floskell.Types Methods compare :: TypeLayout -> TypeLayout -> Ordering # (<) :: TypeLayout -> TypeLayout -> Bool # (<=) :: TypeLayout -> TypeLayout -> Bool # (>) :: TypeLayout -> TypeLayout -> Bool # (>=) :: TypeLayout -> TypeLayout -> Bool # max :: TypeLayout -> TypeLayout -> TypeLayout # min :: TypeLayout -> TypeLayout -> TypeLayout #

newtype Penalty #

Constructors

Penalty Int |

#### Instances

Instances details

Monoid Penalty # |
Instance details Defined in Floskell.Types Methods mempty :: Penalty # mappend :: Penalty -> Penalty -> Penalty # mconcat :: [Penalty] -> Penalty #
Semigroup Penalty # |
Instance details Defined in Floskell.Types Methods (<>) :: Penalty -> Penalty -> Penalty # sconcat :: NonEmpty Penalty -> Penalty # stimes :: Integral b => b -> Penalty -> Penalty #
Num Penalty # |
Instance details Defined in Floskell.Types Methods (+) :: Penalty -> Penalty -> Penalty # (-) :: Penalty -> Penalty -> Penalty # (*) :: Penalty -> Penalty -> Penalty # negate :: Penalty -> Penalty # abs :: Penalty -> Penalty # signum :: Penalty -> Penalty # fromInteger :: Integer -> Penalty #
Show Penalty # |
Instance details Defined in Floskell.Types Methods showsPrec :: Int -> Penalty -> ShowS # show :: Penalty -> String # showList :: [Penalty] -> ShowS #
Eq Penalty # |
Instance details Defined in Floskell.Types Methods (==) :: Penalty -> Penalty -> Bool # (/=) :: Penalty -> Penalty -> Bool #
Ord Penalty # |
Instance details Defined in Floskell.Types Methods compare :: Penalty -> Penalty -> Ordering # (<) :: Penalty -> Penalty -> Bool # (<=) :: Penalty -> Penalty -> Bool # (>) :: Penalty -> Penalty -> Bool # (>=) :: Penalty -> Penalty -> Bool # max :: Penalty -> Penalty -> Penalty # min :: Penalty -> Penalty -> Penalty #
MonadSearch Penalty Printer # |
Instance details Defined in Floskell.Types Methods cost :: Penalty -> Penalty -> Printer () # junction :: Printer a -> Printer a -> Printer a # abandon :: Printer a # seal :: Printer a -> Printer a # collapse :: Printer () #

newtype TabStop #

Constructors

TabStop String |

#### Instances

Instances details

Show TabStop # |
Instance details Defined in Floskell.Types Methods showsPrec :: Int -> TabStop -> ShowS # show :: TabStop -> String # showList :: [TabStop] -> ShowS #
Eq TabStop # |
Instance details Defined in Floskell.Types Methods (==) :: TabStop -> TabStop -> Bool # (/=) :: TabStop -> TabStop -> Bool #
Ord TabStop # |
Instance details Defined in Floskell.Types Methods compare :: TabStop -> TabStop -> Ordering # (<) :: TabStop -> TabStop -> Bool # (<=) :: TabStop -> TabStop -> Bool # (>) :: TabStop -> TabStop -> Bool # (>=) :: TabStop -> TabStop -> Bool # max :: TabStop -> TabStop -> TabStop # min :: TabStop -> TabStop -> TabStop #

newtype Printer a #

A pretty printing monad.

Constructors

Printer |
Fields unPrinter :: StateT PrintState (Search Penalty) a

#### Instances

Instances details

Alternative Printer # |
Instance details Defined in Floskell.Types Methods empty :: Printer a # (<|>) :: Printer a -> Printer a -> Printer a # some :: Printer a -> Printer [a] # many :: Printer a -> Printer [a] #
Applicative Printer # |
Instance details Defined in Floskell.Types Methods pure :: a -> Printer a # (<*>) :: Printer (a -> b) -> Printer a -> Printer b # liftA2 :: (a -> b -> c) -> Printer a -> Printer b -> Printer c # (*>) :: Printer a -> Printer b -> Printer b # (<*) :: Printer a -> Printer b -> Printer a #
Functor Printer # |
Instance details Defined in Floskell.Types Methods fmap :: (a -> b) -> Printer a -> Printer b # (<$) :: a -> Printer b -> Printer a #
Monad Printer # |
Instance details Defined in Floskell.Types Methods (>>=) :: Printer a -> (a -> Printer b) -> Printer b # (>>) :: Printer a -> Printer b -> Printer b # return :: a -> Printer a #
MonadPlus Printer # |
Instance details Defined in Floskell.Types Methods mzero :: Printer a # mplus :: Printer a -> Printer a -> Printer a #
MonadSearch Penalty Printer # |
Instance details Defined in Floskell.Types Methods cost :: Penalty -> Penalty -> Printer () # junction :: Printer a -> Printer a -> Printer a # abandon :: Printer a # seal :: Printer a -> Printer a # collapse :: Printer () #
MonadState PrintState Printer # |
Instance details Defined in Floskell.Types Methods get :: Printer PrintState # put :: PrintState -> Printer () # state :: (PrintState -> (a, PrintState)) -> Printer a #

execPrinter :: Printer a -> PrintState -> Maybe (Penalty, PrintState) #

runPrinter :: Printer a -> PrintState -> Maybe (Penalty, (a, PrintState)) #

data PrintState #

The state of the pretty printer.

Constructors

PrintState |
Fields psBuffer :: !Buffer Output buffer psIndentLevel :: !Int Current indentation level. psOnside :: !Int Extra indentation is necessary with next line break. psTabStops :: !(Map TabStop Int) Tab stops for alignment. psConfig :: !Config Style definition. psEolComment :: !Bool An end of line comment has just been outputted. psOutputRestriction :: !OutputRestriction psTypeLayout :: !TypeLayout

#### Instances

Instances details

MonadState PrintState Printer # |
Instance details Defined in Floskell.Types Methods get :: Printer PrintState # put :: PrintState -> Printer () # state :: (PrintState -> (a, PrintState)) -> Printer a #

psLine :: PrintState -> Int #

psColumn :: PrintState -> Int #

psNewline :: PrintState -> Bool #

initialPrintState :: Config -> PrintState #

data Config #

Constructors

Config |
Fields cfgPenalty :: !PenaltyConfig cfgAlign :: !AlignConfig cfgIndent :: !IndentConfig cfgLayout :: !LayoutConfig cfgOp :: !OpConfig cfgGroup :: !GroupConfig cfgOptions :: !OptionConfig

#### Instances

Instances details

FromJSON Config # |
Instance details Defined in Floskell.Config Methods parseJSON :: Value -> Parser Config # parseJSONList :: Value -> Parser [Config] # omittedField :: Maybe Config #
ToJSON Config # |
Instance details Defined in Floskell.Config Methods toJSON :: Config -> Value # toEncoding :: Config -> Encoding # toJSONList :: [Config] -> Value # toEncodingList :: [Config] -> Encoding # omitField :: Config -> Bool #
Default Config # |
Instance details Defined in Floskell.Config Methods def :: Config #
Generic Config # |
Instance details Defined in Floskell.Config Associated Types
type Rep Config |
Instance details Defined in Floskell.Config type Rep Config = D1 ('MetaData "Config" "Floskell.Config" "floskell-0.11.1-If3Z75J2neZ5JNi0eSSCAs" 'False) (C1 ('MetaCons "Config" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cfgPenalty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PenaltyConfig) :*: (S1 ('MetaSel ('Just "cfgAlign") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AlignConfig) :*: S1 ('MetaSel ('Just "cfgIndent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IndentConfig))) :*: ((S1 ('MetaSel ('Just "cfgLayout") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LayoutConfig) :*: S1 ('MetaSel ('Just "cfgOp") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OpConfig)) :*: (S1 ('MetaSel ('Just "cfgGroup") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 GroupConfig) :*: S1 ('MetaSel ('Just "cfgOptions") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OptionConfig)))))
Methods from :: Config -> Rep Config x # to :: Rep Config x -> Config #
type Rep Config # |
Instance details Defined in Floskell.Config type Rep Config = D1 ('MetaData "Config" "Floskell.Config" "floskell-0.11.1-If3Z75J2neZ5JNi0eSSCAs" 'False) (C1 ('MetaCons "Config" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cfgPenalty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PenaltyConfig) :*: (S1 ('MetaSel ('Just "cfgAlign") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AlignConfig) :*: S1 ('MetaSel ('Just "cfgIndent") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IndentConfig))) :*: ((S1 ('MetaSel ('Just "cfgLayout") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LayoutConfig) :*: S1 ('MetaSel ('Just "cfgOp") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OpConfig)) :*: (S1 ('MetaSel ('Just "cfgGroup") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 GroupConfig) :*: S1 ('MetaSel ('Just "cfgOptions") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OptionConfig)))))

data SrcSpan #

A portion of the source, spanning one or more lines and zero or more columns.

Constructors

SrcSpan |
Fields srcSpanFilename :: String srcSpanStartLine :: Int srcSpanStartColumn :: Int srcSpanEndLine :: Int srcSpanEndColumn :: Int

#### Instances

Instances details

Data SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SrcSpan -> c SrcSpan # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcSpan # toConstr :: SrcSpan -> Constr # dataTypeOf :: SrcSpan -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SrcSpan) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcSpan) # gmapT :: (forall b. Data b => b -> b) -> SrcSpan -> SrcSpan # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcSpan -> r # gmapQ :: (forall d. Data d => d -> u) -> SrcSpan -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcSpan -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcSpan -> m SrcSpan #
Generic SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc Associated Types
type Rep SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc type Rep SrcSpan = D1 ('MetaData "SrcSpan" "Language.Haskell.Exts.SrcLoc" "haskell-src-exts-1.23.1-FOI5Fu7za2w1QQR9FkfSpN" 'False) (C1 ('MetaCons "SrcSpan" 'PrefixI 'True) ((S1 ('MetaSel ('Just "srcSpanFilename") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "srcSpanStartLine") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "srcSpanStartColumn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: (S1 ('MetaSel ('Just "srcSpanEndLine") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "srcSpanEndColumn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))))
Methods from :: SrcSpan -> Rep SrcSpan x # to :: Rep SrcSpan x -> SrcSpan #
Show SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc Methods showsPrec :: Int -> SrcSpan -> ShowS # show :: SrcSpan -> String # showList :: [SrcSpan] -> ShowS #
Eq SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc Methods (==) :: SrcSpan -> SrcSpan -> Bool # (/=) :: SrcSpan -> SrcSpan -> Bool #
Ord SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc Methods compare :: SrcSpan -> SrcSpan -> Ordering # (<) :: SrcSpan -> SrcSpan -> Bool # (<=) :: SrcSpan -> SrcSpan -> Bool # (>) :: SrcSpan -> SrcSpan -> Bool # (>=) :: SrcSpan -> SrcSpan -> Bool # max :: SrcSpan -> SrcSpan -> SrcSpan # min :: SrcSpan -> SrcSpan -> SrcSpan #
Pretty SrcSpan |
Instance details Defined in Language.Haskell.Exts.Pretty Methods pretty :: SrcSpan -> Doc prettyPrec :: Int -> SrcSpan -> Doc
SrcInfo SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc Methods toSrcInfo :: SrcLoc -> [SrcSpan] -> SrcLoc -> SrcSpan # fromSrcInfo :: SrcSpanInfo -> SrcSpan # getPointLoc :: SrcSpan -> SrcLoc # fileName :: SrcSpan -> String # startLine :: SrcSpan -> Int # startColumn :: SrcSpan -> Int #
type Rep SrcSpan |
Instance details Defined in Language.Haskell.Exts.SrcLoc type Rep SrcSpan = D1 ('MetaData "SrcSpan" "Language.Haskell.Exts.SrcLoc" "haskell-src-exts-1.23.1-FOI5Fu7za2w1QQR9FkfSpN" 'False) (C1 ('MetaCons "SrcSpan" 'PrefixI 'True) ((S1 ('MetaSel ('Just "srcSpanFilename") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "srcSpanStartLine") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "srcSpanStartColumn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: (S1 ('MetaSel ('Just "srcSpanEndLine") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "srcSpanEndColumn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))))

data CommentType #

Constructors

InlineComment |
LineComment |
PreprocessorDirective |
IgnoredLine |

#### Instances

Instances details

Show CommentType # |
Instance details Defined in Floskell.Types Methods showsPrec :: Int -> CommentType -> ShowS # show :: CommentType -> String # showList :: [CommentType] -> ShowS #

data Comment #

Constructors

Comment |
Fields commentType :: !CommentType commentSpan :: !SrcSpan commentText :: !String

#### Instances

Instances details

Show Comment # |
Instance details Defined in Floskell.Types Methods showsPrec :: Int -> Comment -> ShowS # show :: Comment -> String # showList :: [Comment] -> ShowS #

data NodeInfo #

Information for each node in the AST.

Constructors

NodeInfo |
Fields nodeInfoSpan :: !SrcSpan Location info from the parser. nodeInfoLeadingComments :: ![Comment] Leading comments attached to this node. nodeInfoTrailingComments :: ![Comment] Trailing comments attached to this node.

#### Instances

Instances details

Show NodeInfo # |
Instance details Defined in Floskell.Types Methods showsPrec :: Int -> NodeInfo -> ShowS # show :: NodeInfo -> String # showList :: [NodeInfo] -> ShowS #

noNodeInfo :: NodeInfo #

Empty NodeInfo

nodeSpan :: Annotated ast => ast NodeInfo -> SrcSpan #

data Location #

Constructors

Before |
After |

#### Instances

Instances details

Bounded Location # |
Instance details Defined in Floskell.Config Methods minBound :: Location # maxBound :: Location #
Enum Location # |
Instance details Defined in Floskell.Config Methods succ :: Location -> Location # pred :: Location -> Location # toEnum :: Int -> Location # fromEnum :: Location -> Int # enumFrom :: Location -> [Location] # enumFromThen :: Location -> Location -> [Location] # enumFromTo :: Location -> Location -> [Location] # enumFromThenTo :: Location -> Location -> Location -> [Location] #
Generic Location # |
Instance details Defined in Floskell.Config Associated Types
type Rep Location |
Instance details Defined in Floskell.Config type Rep Location = D1 ('MetaData "Location" "Floskell.Config" "floskell-0.11.1-If3Z75J2neZ5JNi0eSSCAs" 'False) (C1 ('MetaCons "Before" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "After" 'PrefixI 'False) (U1 :: Type -> Type))
Methods from :: Location -> Rep Location x # to :: Rep Location x -> Location #
Show Location # |
Instance details Defined in Floskell.Config Methods showsPrec :: Int -> Location -> ShowS # show :: Location -> String # showList :: [Location] -> ShowS #
Eq Location # |
Instance details Defined in Floskell.Config Methods (==) :: Location -> Location -> Bool # (/=) :: Location -> Location -> Bool #
Ord Location # |
Instance details Defined in Floskell.Config Methods compare :: Location -> Location -> Ordering # (<) :: Location -> Location -> Bool # (<=) :: Location -> Location -> Bool # (>) :: Location -> Location -> Bool # (>=) :: Location -> Location -> Bool # max :: Location -> Location -> Location # min :: Location -> Location -> Location #
type Rep Location # |
Instance details Defined in Floskell.Config type Rep Location = D1 ('MetaData "Location" "Floskell.Config" "floskell-0.11.1-If3Z75J2neZ5JNi0eSSCAs" 'False) (C1 ('MetaCons "Before" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "After" 'PrefixI 'False) (U1 :: Type -> Type))