hpython-0.1: Syntax tree and DSL for Python

Copyright(C) CSIRO 2017-2018
LicenseBSD3
MaintainerIsaac Elliott <isaace71295@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Language.Python.Syntax.Strings

Contents

Description

Synopsis

Datatypes

Characters

data PyChar Source #

A character in a string literal. This is a large sum type, with a catch-all of a Haskell Char.

Constructors

Char_newline
\newline
Char_octal1 OctDigit
\1
Char_octal2 OctDigit OctDigit
\12
Char_octal3 OctDigit OctDigit OctDigit
\123
Char_hex HeXDigit HeXDigit
\xFb
Char_uni16 HeXDigit HeXDigit HeXDigit HeXDigit
\u12aD
Char_uni32 HeXDigit HeXDigit HeXDigit HeXDigit HeXDigit HeXDigit HeXDigit HeXDigit
\Udeadbeef
Char_esc_bslash
\\
Char_esc_singlequote
\'
Char_esc_doublequote
\"
Char_esc_a
\a
Char_esc_b
\b
Char_esc_f
\f
Char_esc_n
\n
Char_esc_r
\r
Char_esc_t
\t
Char_esc_v
\v
Char_lit Char

Any character

Instances
Eq PyChar Source # 
Instance details

Defined in Language.Python.Syntax.Strings

Methods

(==) :: PyChar -> PyChar -> Bool #

(/=) :: PyChar -> PyChar -> Bool #

Ord PyChar Source # 
Instance details

Defined in Language.Python.Syntax.Strings

Show PyChar Source # 
Instance details

Defined in Language.Python.Syntax.Strings

fromHaskellString :: String -> [PyChar] Source #

Convert a Haskell string to a list of PyChar. This is useful when writing Python in Haskell.

String information

data QuoteType Source #

Double or single quotation marks?

"Double quotes"
"""Double quotes"""
'Single quotes'
'''Single quotes'''

Constructors

SingleQuote 
DoubleQuote 

data StringType Source #

Three pairs of quotations or one?

"""Long string"""
'''Also long string'''
"Short string"
'Also short string'

Constructors

ShortString 
LongString 

String prefixes

data StringPrefix Source #

In Python 3.5, a prefix of u or U is allowed, but doesn't have any meaning. They exist for backwards compatibility with Python 2.

See https://www.python.org/dev/peps/pep-0414/

Constructors

Prefix_u 
Prefix_U 

data BytesPrefix Source #

This prefix indicates it's a bytes literal rather than a string literal.

Constructors

Prefix_b 
Prefix_B 

hasPrefix :: StringLiteral a -> Bool Source #

Most types of StringLiteral have prefixes. Plain old strings may have an optional prefix, but it is meaningless.

String literals

data StringLiteral a Source #

A StringLiteral, complete with a prefix, information about quote type and number, and a list of PyChars.

Like many other data types in hpython, it has an annotation and trailing whitespace.

Instances
Functor StringLiteral Source # 
Instance details

Defined in Language.Python.Syntax.Strings

Methods

fmap :: (a -> b) -> StringLiteral a -> StringLiteral b #

(<$) :: a -> StringLiteral b -> StringLiteral a #

Foldable StringLiteral Source # 
Instance details

Defined in Language.Python.Syntax.Strings

Methods

fold :: Monoid m => StringLiteral m -> m #

foldMap :: Monoid m => (a -> m) -> StringLiteral a -> m #

foldr :: (a -> b -> b) -> b -> StringLiteral a -> b #

foldr' :: (a -> b -> b) -> b -> StringLiteral a -> b #

foldl :: (b -> a -> b) -> b -> StringLiteral a -> b #

foldl' :: (b -> a -> b) -> b -> StringLiteral a -> b #

foldr1 :: (a -> a -> a) -> StringLiteral a -> a #

foldl1 :: (a -> a -> a) -> StringLiteral a -> a #

toList :: StringLiteral a -> [a] #

null :: StringLiteral a -> Bool #

length :: StringLiteral a -> Int #

elem :: Eq a => a -> StringLiteral a -> Bool #

maximum :: Ord a => StringLiteral a -> a #

minimum :: Ord a => StringLiteral a -> a #

sum :: Num a => StringLiteral a -> a #

product :: Num a => StringLiteral a -> a #

Traversable StringLiteral Source # 
Instance details

Defined in Language.Python.Syntax.Strings

Methods

traverse :: Applicative f => (a -> f b) -> StringLiteral a -> f (StringLiteral b) #

sequenceA :: Applicative f => StringLiteral (f a) -> f (StringLiteral a) #

mapM :: Monad m => (a -> m b) -> StringLiteral a -> m (StringLiteral b) #

sequence :: Monad m => StringLiteral (m a) -> m (StringLiteral a) #

Eq a => Eq (StringLiteral a) Source # 
Instance details

Defined in Language.Python.Syntax.Strings

Ord a => Ord (StringLiteral a) Source # 
Instance details

Defined in Language.Python.Syntax.Strings

Show a => Show (StringLiteral a) Source # 
Instance details

Defined in Language.Python.Syntax.Strings

HasTrailingWhitespace (StringLiteral a) Source # 
Instance details

Defined in Language.Python.Syntax.Strings

HasNewlines (StringLiteral a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

Methods

_Newlines :: Traversal' (StringLiteral a) Newline Source #

Lenses

Rendering

Extra functions

isEscape :: PyChar -> Bool Source #

Determine whether a PyChar is an escape character or not.