| 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.Numbers
Description
Numerical literal values in Python
Synopsis
- data IntLiteral a
- = IntLiteralDec { }
- | IntLiteralBin { }
- | IntLiteralOct { }
- | IntLiteralHex { }
- data Sign
- data E
- data FloatExponent = FloatExponent E (Maybe Sign) (NonEmpty DecDigit)
- data FloatLiteral a
- = FloatLiteralFull { }
- | FloatLiteralPoint { }
- | FloatLiteralWhole { }
- data ImagLiteral a
- showIntLiteral :: IntLiteral a -> Text
- showFloatLiteral :: FloatLiteral a -> Text
- showFloatExponent :: FloatExponent -> Text
- showImagLiteral :: ImagLiteral a -> Text
Datatypes
data IntLiteral a Source #
An integer literal value.
5 is an integer literal.
6.2 is a literal but is not an integer
x might be an integer, but is not a literal
See https://docs.python.org/3.5/reference/lexical_analysis.html#integer-literals
Constructors
| IntLiteralDec | Decimal 1234 |
Fields | |
| IntLiteralBin | Binary 0b10110 |
Fields | |
| IntLiteralOct | Octal 0o1367 |
Fields | |
| IntLiteralHex | Mixed-case hexadecimal 0x18B4f |
Fields | |
Instances
When a floating point literal is in scientific notation, it includes the character
e, which can be lower or upper case.
data FloatExponent Source #
The exponent of a floating point literal.
An e, followed by an optional Sign, followed by at least one digit.
Instances
| Eq FloatExponent Source # | |
Defined in Language.Python.Syntax.Numbers Methods (==) :: FloatExponent -> FloatExponent -> Bool # (/=) :: FloatExponent -> FloatExponent -> Bool # | |
| Ord FloatExponent Source # | |
Defined in Language.Python.Syntax.Numbers Methods compare :: FloatExponent -> FloatExponent -> Ordering # (<) :: FloatExponent -> FloatExponent -> Bool # (<=) :: FloatExponent -> FloatExponent -> Bool # (>) :: FloatExponent -> FloatExponent -> Bool # (>=) :: FloatExponent -> FloatExponent -> Bool # max :: FloatExponent -> FloatExponent -> FloatExponent # min :: FloatExponent -> FloatExponent -> FloatExponent # | |
| Show FloatExponent Source # | |
Defined in Language.Python.Syntax.Numbers Methods showsPrec :: Int -> FloatExponent -> ShowS # show :: FloatExponent -> String # showList :: [FloatExponent] -> ShowS # | |
data FloatLiteral a Source #
A literal floating point value.
Eg. 7.63
See https://docs.python.org/3.5/reference/lexical_analysis.html#floating-point-literals
Constructors
| FloatLiteralFull | 'Complete' floats 12. 12.34 12.e34 12.34e56 |
Fields | |
| FloatLiteralPoint | Floats that begin with a decimal point .12 .12e34 |
| FloatLiteralWhole | Floats with no decimal points 12e34 |
Instances
data ImagLiteral a Source #
Imaginary number literals
See https://docs.python.org/3.5/reference/lexical_analysis.html#imaginary-literals
Constructors
| ImagLiteralInt | A decimal integer followed by a 'j' 12j |
Fields | |
| ImagLiteralFloat | A float followed by a 'j' 12.j 12.3j .3j |
Fields | |
Instances
Rendering
The output of these functions is guaranteed to be valid Python code
showIntLiteral :: IntLiteral a -> Text Source #
showFloatLiteral :: FloatLiteral a -> Text Source #
showImagLiteral :: ImagLiteral a -> Text Source #