| Copyright | (C) CSIRO 2017-2019 | 
|---|---|
| License | BSD3 | 
| Maintainer | Isaac Elliott <isaace71295@gmail.com> | 
| Stability | experimental | 
| Portability | non-portable | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Language.Python.Syntax.Whitespace
Contents
Description
Synopsis
- data Newline
- data Whitespace
- data Blank a = Blank {- _blankAnn :: Ann a
- _blankWhitespaces :: [Whitespace]
- _blankComment :: Maybe (Comment a)
 
- class HasTrailingWhitespace s where
- class HasTrailingNewline (s :: [*] -> * -> *) where
- data IndentLevel
- getIndentLevel :: IndentLevel -> Int
- indentLevel :: Indent -> Int
- absoluteIndentLevel :: Int -> Indent -> Int
- newtype Indent = MkIndent {}
- indentWhitespaces :: Iso' Indent [Whitespace]
- indentIt :: [Whitespace] -> Indents a -> Indents a
- dedentIt :: Indents a -> Indents a
- data Indents a = Indents {- _indentsValue :: [Indent]
- _indentsAnn :: Ann a
 
- indentsValue :: forall a. Lens' (Indents a) [Indent]
- indentsAnn :: forall a a. Lens (Indents a) (Indents a) (Ann a) (Ann a)
- subtractStart :: Indents a -> Indents a -> Maybe (Indents a)
Whitespace
A newline is either a carriage return, a line feed, or a carriage return followed by a line feed.
Instances
| Eq Newline # | |
| Ord Newline # | |
| Defined in Language.Python.Syntax.Whitespace | |
| Show Newline # | |
| HasNewlines Newline # | |
| Defined in Language.Python.Optics.Newlines Methods | |
data Whitespace #
Whitespace is either a space, a tab, a newline that continues the
 logical line (Continued), a newline that ends the logical line (Newline),
 or a Comment.
Despite not literally being whitespace, comments inside enclosed forms are treated as whitespace. See https://docs.python.org/3.5/reference/lexical_analysis.html#implicit-line-joining
Example and counterexample of comments as whitespace
( 1 + # here's a comment 2 + 3 # another comment )
x = 5 + 5 # this line is not considered whitespace y = x * 2
[ 1 , 2 # I'm whitespace , 3 # also whitespace ]
Instances
| Eq Whitespace # | |
| Defined in Language.Python.Syntax.Whitespace | |
| Ord Whitespace # | |
| Defined in Language.Python.Syntax.Whitespace Methods compare :: Whitespace -> Whitespace -> Ordering # (<) :: Whitespace -> Whitespace -> Bool # (<=) :: Whitespace -> Whitespace -> Bool # (>) :: Whitespace -> Whitespace -> Bool # (>=) :: Whitespace -> Whitespace -> Bool # max :: Whitespace -> Whitespace -> Whitespace # min :: Whitespace -> Whitespace -> Whitespace # | |
| Show Whitespace # | |
| Defined in Language.Python.Syntax.Whitespace Methods showsPrec :: Int -> Whitespace -> ShowS # show :: Whitespace -> String # showList :: [Whitespace] -> ShowS # | |
| HasNewlines Whitespace # | |
| Defined in Language.Python.Optics.Newlines Methods | |
| Measured IndentLevel Whitespace # | |
| Defined in Language.Python.Syntax.Whitespace Methods measure :: Whitespace -> IndentLevel # | |
Lines which are "blank", meaning that they contain, if anything, only whitespace and/or a comment.
Constructors
| Blank | |
| Fields 
 | |
Instances
class HasTrailingWhitespace s where #
Every syntactic element contains the whitespace that immediately follows it.
This type class lets us access this trailing whitespace in many different types throughout hpython.
Minimal complete definition
Methods
trailingWhitespace :: Lens' s [Whitespace] #
Instances
class HasTrailingNewline (s :: [*] -> * -> *) where #
A statement-containing thing may have a trailing newline
Some forms always have a trailing newline, which is why this class isn't just
 trailingNewline :: Lens' (s v a) (Maybe Newline)
Minimal complete definition
Methods
trailingNewline :: Traversal' (s v a) Newline #
setTrailingNewline :: s v a -> Newline -> s v a #
Instances
Indentation
data IndentLevel #
Python has rules regarding the expansion of tabs into spaces and how to go about computing indentation after this is done.
See https://docs.python.org/3.5/reference/lexical_analysis.html#indentation
This data structure implements those rules as a monoid.
Instances
| Semigroup IndentLevel # | |
| Defined in Language.Python.Syntax.Whitespace Methods (<>) :: IndentLevel -> IndentLevel -> IndentLevel # sconcat :: NonEmpty IndentLevel -> IndentLevel # stimes :: Integral b => b -> IndentLevel -> IndentLevel # | |
| Monoid IndentLevel # | |
| Defined in Language.Python.Syntax.Whitespace Methods mempty :: IndentLevel # mappend :: IndentLevel -> IndentLevel -> IndentLevel # mconcat :: [IndentLevel] -> IndentLevel # | |
| Measured IndentLevel Whitespace # | |
| Defined in Language.Python.Syntax.Whitespace Methods measure :: Whitespace -> IndentLevel # | |
getIndentLevel :: IndentLevel -> Int #
indentLevel :: Indent -> Int #
absoluteIndentLevel :: Int -> Indent -> Int #
Constructors
| MkIndent | |
| Fields | |
indentWhitespaces :: Iso' Indent [Whitespace] #
An Indent is isomorphic to a list of Whitespace
indentIt :: [Whitespace] -> Indents a -> Indents a #
Indent some indentation by a chunk
A possibly annotated list of Indents.
Constructors
| Indents | |
| Fields 
 | |
Instances
indentsValue :: forall a. Lens' (Indents a) [Indent] #