Copyright | (C) CSIRO 2017-2019 |
---|---|
License | BSD3 |
Maintainer | Isaac Elliott <isaace71295@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
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
IntLiteralDec | Decimal 1234 |
IntLiteralBin | Binary 0b10110 |
IntLiteralOct | Octal 0o1367 |
IntLiteralHex | Mixed-case hexadecimal 0x18B4f |
Instances
Positive or negative, as in -7
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
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
FloatLiteralFull | 'Complete' floats 12. 12.34 12.e34 12.34e56 |
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
ImagLiteralInt | A decimal integer followed by a 'j' 12j |
ImagLiteralFloat | A float followed by a 'j' 12.j 12.3j .3j |
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 #