hpython-0.2: Python language tools

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

Language.Python.DSL

Contents

Description

Passing [] to a function which expects a [Raw Line] is the same as passing [line_ pass_]

Synopsis

Documentation

(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

>>> 5 & (+1) & show
"6"

Since: base-4.8.0.0

type Raw f = f '[] () Source #

Raw represents unvalidated, un-annotated terms.

data Module v a Source #

A Python Module, which is stored as a sequence of statements. A module corresponds to one source file of Python code.

Instances
HasExprs Module Source # 
Instance details

Defined in Language.Python.Syntax.Module

Methods

_Exprs :: Traversal (Module v a) (Module [] a) (Expr v a) (Expr [] a) Source #

HasStatements Module Source # 
Instance details

Defined in Language.Python.Syntax.Module

Methods

_Statements :: Traversal (Module v a) (Module [] a) (Statement v a) (Statement [] a) Source #

HasIdents Module Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (Module v a) (Module [] a) (Ident v a) (Ident [] a) Source #

Functor (Module v) Source # 
Instance details

Defined in Language.Python.Syntax.Module

Methods

fmap :: (a -> b) -> Module v a -> Module v b #

(<$) :: a -> Module v b -> Module v a #

Foldable (Module v) Source # 
Instance details

Defined in Language.Python.Syntax.Module

Methods

fold :: Monoid m => Module v m -> m #

foldMap :: Monoid m => (a -> m) -> Module v a -> m #

foldr :: (a -> b -> b) -> b -> Module v a -> b #

foldr' :: (a -> b -> b) -> b -> Module v a -> b #

foldl :: (b -> a -> b) -> b -> Module v a -> b #

foldl' :: (b -> a -> b) -> b -> Module v a -> b #

foldr1 :: (a -> a -> a) -> Module v a -> a #

foldl1 :: (a -> a -> a) -> Module v a -> a #

toList :: Module v a -> [a] #

null :: Module v a -> Bool #

length :: Module v a -> Int #

elem :: Eq a => a -> Module v a -> Bool #

maximum :: Ord a => Module v a -> a #

minimum :: Ord a => Module v a -> a #

sum :: Num a => Module v a -> a #

product :: Num a => Module v a -> a #

Traversable (Module v) Source # 
Instance details

Defined in Language.Python.Syntax.Module

Methods

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

sequenceA :: Applicative f => Module v (f a) -> f (Module v a) #

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

sequence :: Monad m => Module v (m a) -> m (Module v a) #

Eq a => Eq (Module v a) Source # 
Instance details

Defined in Language.Python.Syntax.Module

Methods

(==) :: Module v a -> Module v a -> Bool #

(/=) :: Module v a -> Module v a -> Bool #

Show a => Show (Module v a) Source # 
Instance details

Defined in Language.Python.Syntax.Module

Methods

showsPrec :: Int -> Module v a -> ShowS #

show :: Module v a -> String #

showList :: [Module v a] -> ShowS #

Generic (Module v a) Source # 
Instance details

Defined in Language.Python.Syntax.Module

Associated Types

type Rep (Module v a) :: Type -> Type #

Methods

from :: Module v a -> Rep (Module v a) x #

to :: Rep (Module v a) x -> Module v a #

HasNewlines (Module v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (Module v a) Source # 
Instance details

Defined in Language.Python.Syntax.Module

data Statement (v :: [*]) a Source #

Instances
Validated Statement Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

unvalidated :: Getter (Statement v a) (Statement [] a) Source #

HasTrailingNewline Statement Source # 
Instance details

Defined in Language.Python.Syntax.Statement

HasExprs Statement Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

_Exprs :: Traversal (Statement v a) (Statement [] a) (Expr v a) (Expr [] a) Source #

HasBlocks Statement Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

_Blocks :: Traversal (Statement v a) (Statement [] a) (Block v a) (Block [] a) Source #

HasStatements Statement Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

_Statements :: Traversal (Statement v a) (Statement [] a) (Statement v a) (Statement [] a) Source #

HasIdents Statement Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (Statement v a) (Statement [] a) (Ident v a) (Ident [] a) Source #

HasWith Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_With :: Prism (Statement v a) (Statement [] a) (With v a) (With [] a) Source #

HasClassDef Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_ClassDef :: Prism (Statement v a) (Statement [] a) (ClassDef v a) (ClassDef [] a) Source #

HasFor Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_For :: Prism (Statement v a) (Statement [] a) (For v a) (For [] a) Source #

HasTryFinally Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_TryFinally :: Prism (Statement v a) (Statement [] a) (TryFinally v a) (TryFinally [] a) Source #

HasTryExcept Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_TryExcept :: Prism (Statement v a) (Statement [] a) (TryExcept v a) (TryExcept [] a) Source #

HasIf Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_If :: Prism (Statement v a) (Statement [] a) (If v a) (If [] a) Source #

HasWhile Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_While :: Prism (Statement v a) (Statement [] a) (While v a) (While [] a) Source #

HasFundef Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_Fundef :: Prism (Statement v a) (Statement [] a) (Fundef v a) (Fundef [] a) Source #

HasCompoundStatement Statement Source # 
Instance details

Defined in Language.Python.Optics

AsLine Statement Source # 
Instance details

Defined in Language.Python.DSL

Functor (Statement v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

fmap :: (a -> b) -> Statement v a -> Statement v b #

(<$) :: a -> Statement v b -> Statement v a #

Foldable (Statement v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

fold :: Monoid m => Statement v m -> m #

foldMap :: Monoid m => (a -> m) -> Statement v a -> m #

foldr :: (a -> b -> b) -> b -> Statement v a -> b #

foldr' :: (a -> b -> b) -> b -> Statement v a -> b #

foldl :: (b -> a -> b) -> b -> Statement v a -> b #

foldl' :: (b -> a -> b) -> b -> Statement v a -> b #

foldr1 :: (a -> a -> a) -> Statement v a -> a #

foldl1 :: (a -> a -> a) -> Statement v a -> a #

toList :: Statement v a -> [a] #

null :: Statement v a -> Bool #

length :: Statement v a -> Int #

elem :: Eq a => a -> Statement v a -> Bool #

maximum :: Ord a => Statement v a -> a #

minimum :: Ord a => Statement v a -> a #

sum :: Num a => Statement v a -> a #

product :: Num a => Statement v a -> a #

Traversable (Statement v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

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

sequenceA :: Applicative f => Statement v (f a) -> f (Statement v a) #

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

sequence :: Monad m => Statement v (m a) -> m (Statement v a) #

Eq a => Eq (Statement v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

(==) :: Statement v a -> Statement v a -> Bool #

(/=) :: Statement v a -> Statement v a -> Bool #

Show a => Show (Statement v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

showsPrec :: Int -> Statement v a -> ShowS #

show :: Statement v a -> String #

showList :: [Statement v a] -> ShowS #

Generic (Statement v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Associated Types

type Rep (Statement v a) :: Type -> Type #

Methods

from :: Statement v a -> Rep (Statement v a) x #

to :: Rep (Statement v a) x -> Statement v a #

Plated (Statement ([] :: [Type]) a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

plate :: Traversal' (Statement [] a) (Statement [] a) #

HasNewlines (Statement v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

HasIndents (Statement ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

type Rep (Statement v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

data Expr (v :: [*]) a Source #

This large sum type covers all valid Python expressions

Instances
Validated Expr Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

unvalidated :: Getter (Expr v a) (Expr [] a) Source #

HasExprs Expr Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

_Exprs :: Traversal (Expr v a) (Expr [] a) (Expr v a) (Expr [] a) Source #

HasIdents Expr Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (Expr v a) (Expr [] a) (Ident v a) (Ident [] a) Source #

AsTupleItem Expr Source # 
Instance details

Defined in Language.Python.DSL

AsWithItem Expr Source # 
Instance details

Defined in Language.Python.DSL

AsExceptAs Expr Source # 
Instance details

Defined in Language.Python.DSL

AsSetItem Expr Source # 
Instance details

Defined in Language.Python.DSL

Methods

si_ :: Raw Expr -> Raw SetItem Source #

AsListItem Expr Source # 
Instance details

Defined in Language.Python.DSL

Methods

li_ :: Raw Expr -> Raw ListItem Source #

AsLine Expr Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw Expr -> Raw Line Source #

DoubleStarSyntax Expr DictItem Source #

See dict_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Expr -> Raw DictItem Source #

DoubleStarSyntax Expr Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Expr -> Raw Arg Source #

StarSyntax Expr TupleItem Source #

See tuple_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw TupleItem Source #

StarSyntax Expr SetItem Source #

See set_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw SetItem Source #

StarSyntax Expr ListItem Source #

See list_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw ListItem Source #

StarSyntax Expr Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw Arg Source #

PositionalSyntax Arg Expr Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

p_ :: Raw Expr -> Raw Arg Source #

ColonSyntax Expr DictItem Source #

Constructing dictionary items

(.:) :: Raw SimpleStatement -> Raw SimpleStatement -> Raw DictItem
Instance details

Defined in Language.Python.DSL

Methods

(.:) :: Raw Expr -> Raw Expr -> Raw DictItem Source #

As Expr Ident ExceptAs Source #

See exceptAs_

Instance details

Defined in Language.Python.DSL

Methods

as_ :: Raw Expr -> Raw Ident -> Raw ExceptAs Source #

As Expr Expr WithItem Source #

See with_

Instance details

Defined in Language.Python.DSL

Methods

as_ :: Raw Expr -> Raw Expr -> Raw WithItem Source #

InSyntax Expr (Raw Expr) Source #
>>> var_ "a" `in_` var_ "b"
a in b
Instance details

Defined in Language.Python.DSL

Methods

in_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

Functor (Expr v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fmap :: (a -> b) -> Expr v a -> Expr v b #

(<$) :: a -> Expr v b -> Expr v a #

Foldable (Expr v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fold :: Monoid m => Expr v m -> m #

foldMap :: Monoid m => (a -> m) -> Expr v a -> m #

foldr :: (a -> b -> b) -> b -> Expr v a -> b #

foldr' :: (a -> b -> b) -> b -> Expr v a -> b #

foldl :: (b -> a -> b) -> b -> Expr v a -> b #

foldl' :: (b -> a -> b) -> b -> Expr v a -> b #

foldr1 :: (a -> a -> a) -> Expr v a -> a #

foldl1 :: (a -> a -> a) -> Expr v a -> a #

toList :: Expr v a -> [a] #

null :: Expr v a -> Bool #

length :: Expr v a -> Int #

elem :: Eq a => a -> Expr v a -> Bool #

maximum :: Ord a => Expr v a -> a #

minimum :: Ord a => Expr v a -> a #

sum :: Num a => Expr v a -> a #

product :: Num a => Expr v a -> a #

Traversable (Expr v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

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

sequenceA :: Applicative f => Expr v (f a) -> f (Expr v a) #

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

sequence :: Monad m => Expr v (m a) -> m (Expr v a) #

HasAnn (Expr v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

annot :: Lens' (Expr v a) (Ann a) Source #

Eq a => Eq (Expr v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(==) :: Expr v a -> Expr v a -> Bool #

(/=) :: Expr v a -> Expr v a -> Bool #

Num (Expr ([] :: [Type]) ()) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(+) :: Expr [] () -> Expr [] () -> Expr [] () #

(-) :: Expr [] () -> Expr [] () -> Expr [] () #

(*) :: Expr [] () -> Expr [] () -> Expr [] () #

negate :: Expr [] () -> Expr [] () #

abs :: Expr [] () -> Expr [] () #

signum :: Expr [] () -> Expr [] () #

fromInteger :: Integer -> Expr [] () #

Show a => Show (Expr v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

showsPrec :: Int -> Expr v a -> ShowS #

show :: Expr v a -> String #

showList :: [Expr v a] -> ShowS #

IsString (Expr ([] :: [Type]) ()) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fromString :: String -> Expr [] () #

Generic (Expr v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Associated Types

type Rep (Expr v a) :: Type -> Type #

Methods

from :: Expr v a -> Rep (Expr v a) x #

to :: Rep (Expr v a) x -> Expr v a #

Plated (Expr ([] :: [Type]) a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

plate :: Traversal' (Expr [] a) (Expr [] a) #

HasTrailingWhitespace (Expr v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

HasNewlines (Expr v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (Expr v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

type Rep (Expr v a) = D1 (MetaData "Expr" "Language.Python.Syntax.Expr" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) ((((C1 (MetaCons "Unit" PrefixI True) (S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeUnitWhitespaceInner") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeUnitWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :+: (C1 (MetaCons "Lambda" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeLambdaWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeLambdaArgs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (CommaSep (Param v a))) :*: (S1 (MetaSel (Just "_unsafeLambdaColon") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Colon) :*: S1 (MetaSel (Just "_unsafeLambdaBody") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))))) :+: C1 (MetaCons "Yield" PrefixI True) (S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeYieldWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeYieldValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (CommaSep (Expr v a))))))) :+: ((C1 (MetaCons "YieldFrom" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeYieldWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeFromWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeYieldFromValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))) :+: C1 (MetaCons "Ternary" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeTernaryValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)) :*: S1 (MetaSel (Just "_unsafeTernaryWhitespaceIf") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :*: (S1 (MetaSel (Just "_unsafeTernaryCond") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)) :*: (S1 (MetaSel (Just "_unsafeTernaryWhitespaceElse") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeTernaryElse") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))) :+: (C1 (MetaCons "ListComp" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeListCompWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeListCompValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Comprehension Expr v a)) :*: S1 (MetaSel (Just "_unsafeListCompWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :+: C1 (MetaCons "List" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeListWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeListValues") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (CommaSep1' (ListItem v a)))) :*: S1 (MetaSel (Just "_unsafeListWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))))) :+: ((C1 (MetaCons "DictComp" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeDictCompWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeDictCompValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Comprehension DictItem v a)) :*: S1 (MetaSel (Just "_unsafeDictCompWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :+: (C1 (MetaCons "Dict" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeDictWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeDictValues") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (CommaSep1' (DictItem v a)))) :*: S1 (MetaSel (Just "_unsafeDictWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :+: C1 (MetaCons "SetComp" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeSetCompWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeSetCompValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Comprehension SetItem v a)) :*: S1 (MetaSel (Just "_unsafeSetCompWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))))) :+: ((C1 (MetaCons "Set" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeSetWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeSetValues") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (CommaSep1' (SetItem v a))) :*: S1 (MetaSel (Just "_unsafeSetWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :+: C1 (MetaCons "Deref" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeDerefValueLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :*: (S1 (MetaSel (Just "_unsafeDerefWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeDerefValueRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a))))) :+: (C1 (MetaCons "Subscript" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeSubscriptValueLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :*: (S1 (MetaSel (Just "_unsafeSubscriptWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: (S1 (MetaSel (Just "_unsafeSubscriptValueRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (CommaSep1' (Subscript v a))) :*: S1 (MetaSel (Just "_unsafeSubscriptWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))) :+: C1 (MetaCons "Call" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeCallFunction") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :*: (S1 (MetaSel (Just "_unsafeCallWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: (S1 (MetaSel (Just "_unsafeCallArguments") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (CommaSep1' (Arg v a)))) :*: S1 (MetaSel (Just "_unsafeCallWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))))))) :+: (((C1 (MetaCons "None" PrefixI True) (S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeNoneWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :+: (C1 (MetaCons "Ellipsis" PrefixI True) (S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeEllipsisWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :+: C1 (MetaCons "BinOp" PrefixI True) ((S1 (MetaSel (Just "_unsafeExprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeBinOpExprLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :*: (S1 (MetaSel (Just "_unsafeBinOpOp") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (BinOp a)) :*: S1 (MetaSel (Just "_unsafeBinOpExprRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))) :+: ((C1 (MetaCons "UnOp" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeUnOpOp") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (UnOp a)) :*: S1 (MetaSel (Just "_unsafeUnOpValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))) :+: C1 (MetaCons "Parens" PrefixI True) ((S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeParensWhitespaceLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeParensValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)) :*: S1 (MetaSel (Just "_unsafeParensWhitespaceAfter") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))) :+: (C1 (MetaCons "Ident" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeIdentValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a))) :+: C1 (MetaCons "Int" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeIntValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (IntLiteral a)) :*: S1 (MetaSel (Just "_unsafeIntWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))))) :+: (((C1 (MetaCons "Float" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeFloatValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (FloatLiteral a)) :*: S1 (MetaSel (Just "_unsafeFloatWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :+: C1 (MetaCons "Imag" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeImagValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ImagLiteral a)) :*: S1 (MetaSel (Just "_unsafeImagWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))) :+: (C1 (MetaCons "Bool" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeBoolValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool) :*: S1 (MetaSel (Just "_unsafeBoolWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))) :+: C1 (MetaCons "String" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeStringValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (NonEmpty (StringLiteral a)))))) :+: ((C1 (MetaCons "Tuple" PrefixI True) ((S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeTupleHead") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (TupleItem v a))) :*: (S1 (MetaSel (Just "_unsafeTupleWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Comma) :*: S1 (MetaSel (Just "_unsafeTupleTail") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (CommaSep1' (TupleItem v a)))))) :+: C1 (MetaCons "Not" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeNotWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeNotValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))))) :+: (C1 (MetaCons "Generator" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_generatorValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Comprehension Expr v a))) :+: C1 (MetaCons "Await" PrefixI True) (S1 (MetaSel (Just "_exprAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeAwaitWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeAwaitValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))))))

Modules

module_ :: [Raw Line] -> Raw Module Source #

Create a Module

>>> module_
>>> [ line_ $ def_ "a" [] [line_ pass_]
>>> , blank_
>>> , line_ $ def_ "b" [] [line_ pass_]
>>> ]
def a():
    pass

def b():
    pass

Lines of code

blank_ :: Raw Line Source #

Create a blank Line

class AsLine s where Source #

Convert some data to a Line

Methods

line_ :: Raw s -> Raw Line Source #

Instances
AsLine Expr Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw Expr -> Raw Line Source #

AsLine CompoundStatement Source # 
Instance details

Defined in Language.Python.DSL

AsLine SimpleStatement Source # 
Instance details

Defined in Language.Python.DSL

AsLine Statement Source # 
Instance details

Defined in Language.Python.DSL

AsLine SmallStatement Source # 
Instance details

Defined in Language.Python.DSL

AsLine Fundef Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw Fundef -> Raw Line Source #

AsLine While Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw While -> Raw Line Source #

AsLine If Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw If -> Raw Line Source #

AsLine For Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw For -> Raw Line Source #

AsLine TryExcept Source # 
Instance details

Defined in Language.Python.DSL

AsLine TryFinally Source # 
Instance details

Defined in Language.Python.DSL

AsLine ClassDef Source # 
Instance details

Defined in Language.Python.DSL

AsLine With Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw With -> Raw Line Source #

newtype Line v a Source #

One or more lines of Python code

Constructors

Line 

Fields

Instances
HasExprs Line Source # 
Instance details

Defined in Language.Python.DSL

Methods

_Exprs :: Traversal (Line v a) (Line [] a) (Expr v a) (Expr [] a) Source #

HasStatements Line Source # 
Instance details

Defined in Language.Python.DSL

Methods

_Statements :: Traversal (Line v a) (Line [] a) (Statement v a) (Statement [] a) Source #

Eq a => Eq (Line v a) Source # 
Instance details

Defined in Language.Python.DSL

Methods

(==) :: Line v a -> Line v a -> Bool #

(/=) :: Line v a -> Line v a -> Bool #

Show a => Show (Line v a) Source # 
Instance details

Defined in Language.Python.DSL

Methods

showsPrec :: Int -> Line v a -> ShowS #

show :: Line v a -> String #

showList :: [Line v a] -> ShowS #

Wrapped (Line v a) Source # 
Instance details

Defined in Language.Python.DSL

Associated Types

type Unwrapped (Line v a) :: Type #

Methods

_Wrapped' :: Iso' (Line v a) (Unwrapped (Line v a)) #

Line v1 a1 ~ t => Rewrapped (Line v2 a2) t Source # 
Instance details

Defined in Language.Python.DSL

type Unwrapped (Line v a) Source # 
Instance details

Defined in Language.Python.DSL

type Unwrapped (Line v a) = Either (Blank a, Newline) (Statement v a)

Identifiers

id_ :: String -> Raw Ident Source #

Expr has an IsString instance, but when a type class dispatches on an Expr we will run into ambiguity if we try to use OverloadedStrings. In these cases we can use id_ to provide the extra type information

data Ident (v :: [*]) a Source #

An identifier. Like many types in hpython, it has an optional annotation and tracks its trailing whitespace.

Raw Idents have an IsString instance.

See https://docs.python.org/3.5/reference/lexical_analysis.html#identifiers

Constructors

MkIdent 
Instances
Validated Ident Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

unvalidated :: Getter (Ident v a) (Ident [] a) Source #

HasIdents Ident Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (Ident v a) (Ident [] a) (Ident v a) (Ident [] a) Source #

DoubleStarSyntax Ident Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Ident -> Raw Param Source #

StarSyntax Ident Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Ident -> Raw Param Source #

PositionalSyntax Param Ident Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

p_ :: Raw Ident -> Raw Param Source #

As Expr Ident ExceptAs Source #

See exceptAs_

Instance details

Defined in Language.Python.DSL

Methods

as_ :: Raw Expr -> Raw Ident -> Raw ExceptAs Source #

Functor (Ident v) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

fmap :: (a -> b) -> Ident v a -> Ident v b #

(<$) :: a -> Ident v b -> Ident v a #

IsString (Raw Ident) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

fromString :: String -> Raw Ident #

Foldable (Ident v) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

fold :: Monoid m => Ident v m -> m #

foldMap :: Monoid m => (a -> m) -> Ident v a -> m #

foldr :: (a -> b -> b) -> b -> Ident v a -> b #

foldr' :: (a -> b -> b) -> b -> Ident v a -> b #

foldl :: (b -> a -> b) -> b -> Ident v a -> b #

foldl' :: (b -> a -> b) -> b -> Ident v a -> b #

foldr1 :: (a -> a -> a) -> Ident v a -> a #

foldl1 :: (a -> a -> a) -> Ident v a -> a #

toList :: Ident v a -> [a] #

null :: Ident v a -> Bool #

length :: Ident v a -> Int #

elem :: Eq a => a -> Ident v a -> Bool #

maximum :: Ord a => Ident v a -> a #

minimum :: Ord a => Ident v a -> a #

sum :: Num a => Ident v a -> a #

product :: Num a => Ident v a -> a #

Traversable (Ident v) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

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

sequenceA :: Applicative f => Ident v (f a) -> f (Ident v a) #

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

sequence :: Monad m => Ident v (m a) -> m (Ident v a) #

HasAnn (Ident v) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

annot :: Lens' (Ident v a) (Ann a) Source #

Eq a => Eq (Ident v a) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

(==) :: Ident v a -> Ident v a -> Bool #

(/=) :: Ident v a -> Ident v a -> Bool #

Show a => Show (Ident v a) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Methods

showsPrec :: Int -> Ident v a -> ShowS #

show :: Ident v a -> String #

showList :: [Ident v a] -> ShowS #

Generic (Ident v a) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

Associated Types

type Rep (Ident v a) :: Type -> Type #

Methods

from :: Ident v a -> Rep (Ident v a) x #

to :: Rep (Ident v a) x -> Ident v a #

HasTrailingWhitespace (Ident v a) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

HasNewlines (Ident v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (Ident v a) Source # 
Instance details

Defined in Language.Python.Syntax.Ident

type Rep (Ident v a) = D1 (MetaData "Ident" "Language.Python.Syntax.Ident" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkIdent" PrefixI True) (S1 (MetaSel (Just "_identAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_identValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String) :*: S1 (MetaSel (Just "_identWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]))))

Lenses

identAnn :: Lens (Ident v a) (Ident v a) a a Source #

Starred values

class StarSyntax s t | t -> s where Source #

Methods

s_ :: Raw s -> Raw t Source #

Instances
StarSyntax Ident Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Ident -> Raw Param Source #

StarSyntax Expr TupleItem Source #

See tuple_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw TupleItem Source #

StarSyntax Expr SetItem Source #

See set_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw SetItem Source #

StarSyntax Expr ListItem Source #

See list_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw ListItem Source #

StarSyntax Expr Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw Arg Source #

star_ :: Raw Param Source #

Unnamed starred parameter

>>> def_ "a" [ p_ "b", star_ ] [ line_ pass_ ]
def a(b, *):
    pass

Double-starred values

class DoubleStarSyntax s t | t -> s where Source #

Methods

ss_ :: Raw s -> Raw t Source #

Instances
DoubleStarSyntax Ident Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Ident -> Raw Param Source #

DoubleStarSyntax Expr DictItem Source #

See dict_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Expr -> Raw DictItem Source #

DoubleStarSyntax Expr Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Expr -> Raw Arg Source #

as syntax

class As s t u | s t -> u, u -> s t where Source #

Methods

as_ :: Raw s -> Raw t -> Raw u Source #

Instances
As Expr Ident ExceptAs Source #

See exceptAs_

Instance details

Defined in Language.Python.DSL

Methods

as_ :: Raw Expr -> Raw Ident -> Raw ExceptAs Source #

As Expr Expr WithItem Source #

See with_

Instance details

Defined in Language.Python.DSL

Methods

as_ :: Raw Expr -> Raw Expr -> Raw WithItem Source #

if syntax

class IfSyntax a where Source #

Methods

if_ :: Raw Expr -> a Source #

Instances
IfSyntax (Raw Guard) Source #
if_ :: Raw SimpleStatement -> Raw Guard
>>> comp_ (var_ "a") (for_ $ var_ "a" `in_` var_ "b") [if_ $ var_ "c" .== var_ "d"]
a for a in b if c == d
Instance details

Defined in Language.Python.DSL

Methods

if_ :: Raw Expr -> Raw Guard Source #

(l ~ Raw Line, s ~ Raw If) => IfSyntax ([l] -> s) Source #
if_ :: Raw SimpleStatement -> [Raw Line] -> Raw If
>>> if_ (var_ "a" .< 10) [var_ "a" .+= 1]
if a < 10:
    a += 1
Instance details

Defined in Language.Python.DSL

Methods

if_ :: Raw Expr -> [l] -> s Source #

for syntax

class ForSyntax a x | a -> x where Source #

Methods

for_ :: Raw x -> a Source #

Instances
ForSyntax (Raw CompFor) In Source #
for_ :: Raw In -> Raw CompFor
>>> comp_ (var_ "a") (for_ $ var_ "a" `in_` var_ "b") []
a for a in b
Instance details

Defined in Language.Python.DSL

Methods

for_ :: Raw In -> Raw CompFor Source #

ForSyntax (Raw Guard) In Source #
for_ :: Raw In -> Raw Guard
>>> comp_ (var_ "a") (for_ $ var_ "a" `in_` var_ "b") [for_ $ var_ "c" `in_` var_ "d"]
a for a in b for c in d
Instance details

Defined in Language.Python.DSL

Methods

for_ :: Raw In -> Raw Guard Source #

(l ~ [Raw Line], s ~ Raw For) => ForSyntax (l -> s) InList Source #
for_ :: Raw InList -> [Raw Line] -> Raw Statement
>>> for_ (var_ "a" `in_` [var_ "b"]) [line_ (var_ "c" .+= var_ "a")]
for a in b:
    c += a
Instance details

Defined in Language.Python.DSL

Methods

for_ :: Raw InList -> l -> s Source #

in syntax

class InSyntax a x | a -> x, x -> a where Source #

Methods

in_ :: Raw Expr -> x -> Raw a infixl 1 Source #

Instances
InSyntax Expr (Raw Expr) Source #
>>> var_ "a" `in_` var_ "b"
a in b
Instance details

Defined in Language.Python.DSL

Methods

in_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

e ~ Raw Expr => InSyntax InList [e] Source #

See for_

Instance details

Defined in Language.Python.DSL

Methods

in_ :: Raw Expr -> [e] -> Raw InList Source #

data In v a Source #

>>> var_ "a" `in_` var_ "b"
a in b

Constructors

MkIn (Expr v a) (Expr v a) 
Instances
ForSyntax (Raw CompFor) In Source #
for_ :: Raw In -> Raw CompFor
>>> comp_ (var_ "a") (for_ $ var_ "a" `in_` var_ "b") []
a for a in b
Instance details

Defined in Language.Python.DSL

Methods

for_ :: Raw In -> Raw CompFor Source #

ForSyntax (Raw Guard) In Source #
for_ :: Raw In -> Raw Guard
>>> comp_ (var_ "a") (for_ $ var_ "a" `in_` var_ "b") [for_ $ var_ "c" `in_` var_ "d"]
a for a in b for c in d
Instance details

Defined in Language.Python.DSL

Methods

for_ :: Raw In -> Raw Guard Source #

data InList v a Source #

>>> var_ "a" `in_` [var_ "b", var_ "c"]
a in b, c

Constructors

MkInList (Expr v a) [Expr v a] 
Instances
e ~ Raw Expr => InSyntax InList [e] Source #

See for_

Instance details

Defined in Language.Python.DSL

Methods

in_ :: Raw Expr -> [e] -> Raw InList Source #

(l ~ [Raw Line], s ~ Raw For) => ForSyntax (l -> s) InList Source #
for_ :: Raw InList -> [Raw Line] -> Raw Statement
>>> for_ (var_ "a" `in_` [var_ "b"]) [line_ (var_ "c" .+= var_ "a")]
for a in b:
    c += a
Instance details

Defined in Language.Python.DSL

Methods

for_ :: Raw InList -> l -> s Source #

: syntax

class ColonSyntax s t | s -> t, t -> s where Source #

Methods

(.:) :: Raw s -> Raw Expr -> Raw t infix 0 Source #

Instances
ColonSyntax Expr DictItem Source #

Constructing dictionary items

(.:) :: Raw SimpleStatement -> Raw SimpleStatement -> Raw DictItem
Instance details

Defined in Language.Python.DSL

Methods

(.:) :: Raw Expr -> Raw Expr -> Raw DictItem Source #

ColonSyntax Param Param Source #

Function parameter type annotations

(.:) :: Raw Param -> Raw SimpleStatement -> Raw Param

star_ can be annotated using .:, but it will have no effect on the output program, as unnamed starred parameters cannot have type annotations.

See def_

Instance details

Defined in Language.Python.DSL

Methods

(.:) :: Raw Param -> Raw Expr -> Raw Param Source #

Comprehensions

newtype Guard v a Source #

Constructors

MkGuard 

Fields

Instances
IfSyntax (Raw Guard) Source #
if_ :: Raw SimpleStatement -> Raw Guard
>>> comp_ (var_ "a") (for_ $ var_ "a" `in_` var_ "b") [if_ $ var_ "c" .== var_ "d"]
a for a in b if c == d
Instance details

Defined in Language.Python.DSL

Methods

if_ :: Raw Expr -> Raw Guard Source #

ForSyntax (Raw Guard) In Source #
for_ :: Raw In -> Raw Guard
>>> comp_ (var_ "a") (for_ $ var_ "a" `in_` var_ "b") [for_ $ var_ "c" `in_` var_ "d"]
a for a in b for c in d
Instance details

Defined in Language.Python.DSL

Methods

for_ :: Raw In -> Raw Guard Source #

Parameters and arguments

Parameters

data Param (v :: [*]) a Source #

Instances
Validated Param Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

unvalidated :: Getter (Param v a) (Param [] a) Source #

HasExprs Param Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

_Exprs :: Traversal (Param v a) (Param [] a) (Expr v a) (Expr [] a) Source #

HasIdents Param Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (Param v a) (Param [] a) (Ident v a) (Ident [] a) Source #

KeywordSyntax Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

k_ :: Raw Ident -> Raw Expr -> Raw Param Source #

DoubleStarSyntax Ident Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Ident -> Raw Param Source #

StarSyntax Ident Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Ident -> Raw Param Source #

PositionalSyntax Param Ident Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

p_ :: Raw Ident -> Raw Param Source #

ColonSyntax Param Param Source #

Function parameter type annotations

(.:) :: Raw Param -> Raw SimpleStatement -> Raw Param

star_ can be annotated using .:, but it will have no effect on the output program, as unnamed starred parameters cannot have type annotations.

See def_

Instance details

Defined in Language.Python.DSL

Methods

(.:) :: Raw Param -> Raw Expr -> Raw Param Source #

Functor (Param v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fmap :: (a -> b) -> Param v a -> Param v b #

(<$) :: a -> Param v b -> Param v a #

Foldable (Param v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fold :: Monoid m => Param v m -> m #

foldMap :: Monoid m => (a -> m) -> Param v a -> m #

foldr :: (a -> b -> b) -> b -> Param v a -> b #

foldr' :: (a -> b -> b) -> b -> Param v a -> b #

foldl :: (b -> a -> b) -> b -> Param v a -> b #

foldl' :: (b -> a -> b) -> b -> Param v a -> b #

foldr1 :: (a -> a -> a) -> Param v a -> a #

foldl1 :: (a -> a -> a) -> Param v a -> a #

toList :: Param v a -> [a] #

null :: Param v a -> Bool #

length :: Param v a -> Int #

elem :: Eq a => a -> Param v a -> Bool #

maximum :: Ord a => Param v a -> a #

minimum :: Ord a => Param v a -> a #

sum :: Num a => Param v a -> a #

product :: Num a => Param v a -> a #

Traversable (Param v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

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

sequenceA :: Applicative f => Param v (f a) -> f (Param v a) #

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

sequence :: Monad m => Param v (m a) -> m (Param v a) #

HasAnn (Param v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

annot :: Lens' (Param v a) (Ann a) Source #

Eq a => Eq (Param v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(==) :: Param v a -> Param v a -> Bool #

(/=) :: Param v a -> Param v a -> Bool #

Show a => Show (Param v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

showsPrec :: Int -> Param v a -> ShowS #

show :: Param v a -> String #

showList :: [Param v a] -> ShowS #

IsString (Param ([] :: [Type]) ()) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fromString :: String -> Param [] () #

Generic (Param v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Associated Types

type Rep (Param v a) :: Type -> Type #

Methods

from :: Param v a -> Rep (Param v a) x #

to :: Rep (Param v a) x -> Param v a #

HasTrailingWhitespace (Param v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

HasNewlines (Param v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (Param v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

type Rep (Param v a) = D1 (MetaData "Param" "Language.Python.Syntax.Expr" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) ((C1 (MetaCons "PositionalParam" PrefixI True) (S1 (MetaSel (Just "_paramAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_paramName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a)) :*: S1 (MetaSel (Just "_paramType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (Colon, Expr v a))))) :+: C1 (MetaCons "KeywordParam" PrefixI True) ((S1 (MetaSel (Just "_paramAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_paramName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a))) :*: (S1 (MetaSel (Just "_paramType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (Colon, Expr v a))) :*: (S1 (MetaSel (Just "_unsafeKeywordParamWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeKeywordParamExpr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))) :+: (C1 (MetaCons "StarParam" PrefixI True) ((S1 (MetaSel (Just "_paramAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeStarParamWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_unsafeStarParamName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a)) :*: S1 (MetaSel (Just "_paramType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (Colon, Expr v a))))) :+: (C1 (MetaCons "UnnamedStarParam" PrefixI True) (S1 (MetaSel (Just "_paramAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeUnnamedStarParamWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :+: C1 (MetaCons "DoubleStarParam" PrefixI True) ((S1 (MetaSel (Just "_paramAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeDoubleStarParamWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_paramName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a)) :*: S1 (MetaSel (Just "_paramType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (Colon, Expr v a))))))))

class ParametersSyntax s where Source #

Methods

parameters_ :: Functor f => ([Raw Param] -> f [Raw Param]) -> Raw s -> f (Raw s) Source #

A faux-Lens that allows targeting Params in-between existing formatting, and adding appropriate formatting when extra parameters are introduced.

>>> showStatement myStatement
"def a(b ,  c   ):\n    pass"
>>> showStatement (myStatement & _Fundef.parameters_ .~ [p_ "d", p_ "e"]
"def a(d ,  e   ):\n    pass"
>>> showStatement (myStatement & _Fundef.parameters_ .~ [p_ "d", p_ "e", p_ "f"]
"def a(d ,  e   , f):\n    pass"

---

It's not a Lens because repeated sets can drop trailing commas, violating the Lens laws. For example:

>>> someFunction
def a(b, c,):
    pass
>>> set parameters_ [var_ "d", var_ "e"] someFunction
def a(d, e,):
    pass
>>> set parameters_ [] someFunction
def a():
    pass
>>> set parameters_ [var_ "d", var_ "e"] (set parameters_ [] someFunction)
def a(d, e):
    pass

parameters :: Lens' (Raw s) (CommaSep (Raw Param)) Source #

Instances
ParametersSyntax Fundef Source # 
Instance details

Defined in Language.Python.DSL

Arguments

data Arg (v :: [*]) a Source #

Actual parameters for functions

In the following examples, x is an actual parameter.

y = foo(x)
y = bar(quux=x)
y = baz(*x)
y = flux(**x)
Instances
Validated Arg Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

unvalidated :: Getter (Arg v a) (Arg [] a) Source #

HasExprs Arg Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

_Exprs :: Traversal (Arg v a) (Arg [] a) (Expr v a) (Expr [] a) Source #

HasIdents Arg Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (Arg v a) (Arg [] a) (Ident v a) (Ident [] a) Source #

KeywordSyntax Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

k_ :: Raw Ident -> Raw Expr -> Raw Arg Source #

DoubleStarSyntax Expr Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Expr -> Raw Arg Source #

StarSyntax Expr Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw Arg Source #

PositionalSyntax Arg Expr Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

p_ :: Raw Expr -> Raw Arg Source #

Functor (Arg v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fmap :: (a -> b) -> Arg v a -> Arg v b #

(<$) :: a -> Arg v b -> Arg v a #

Foldable (Arg v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fold :: Monoid m => Arg v m -> m #

foldMap :: Monoid m => (a -> m) -> Arg v a -> m #

foldr :: (a -> b -> b) -> b -> Arg v a -> b #

foldr' :: (a -> b -> b) -> b -> Arg v a -> b #

foldl :: (b -> a -> b) -> b -> Arg v a -> b #

foldl' :: (b -> a -> b) -> b -> Arg v a -> b #

foldr1 :: (a -> a -> a) -> Arg v a -> a #

foldl1 :: (a -> a -> a) -> Arg v a -> a #

toList :: Arg v a -> [a] #

null :: Arg v a -> Bool #

length :: Arg v a -> Int #

elem :: Eq a => a -> Arg v a -> Bool #

maximum :: Ord a => Arg v a -> a #

minimum :: Ord a => Arg v a -> a #

sum :: Num a => Arg v a -> a #

product :: Num a => Arg v a -> a #

Traversable (Arg v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

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

sequenceA :: Applicative f => Arg v (f a) -> f (Arg v a) #

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

sequence :: Monad m => Arg v (m a) -> m (Arg v a) #

HasAnn (Arg v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

annot :: Lens' (Arg v a) (Ann a) Source #

Eq a => Eq (Arg v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(==) :: Arg v a -> Arg v a -> Bool #

(/=) :: Arg v a -> Arg v a -> Bool #

Show a => Show (Arg v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

showsPrec :: Int -> Arg v a -> ShowS #

show :: Arg v a -> String #

showList :: [Arg v a] -> ShowS #

IsString (Arg ([] :: [Type]) ()) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fromString :: String -> Arg [] () #

Generic (Arg v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Associated Types

type Rep (Arg v a) :: Type -> Type #

Methods

from :: Arg v a -> Rep (Arg v a) x #

to :: Rep (Arg v a) x -> Arg v a #

HasNewlines (Arg v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (Arg v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

type Rep (Arg v a) = D1 (MetaData "Arg" "Language.Python.Syntax.Expr" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) ((C1 (MetaCons "PositionalArg" PrefixI True) (S1 (MetaSel (Just "_argAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_argExpr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :+: C1 (MetaCons "KeywordArg" PrefixI True) ((S1 (MetaSel (Just "_argAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeKeywordArgName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a))) :*: (S1 (MetaSel (Just "_unsafeKeywordArgWhitespaceRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_argExpr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))))) :+: (C1 (MetaCons "StarArg" PrefixI True) (S1 (MetaSel (Just "_argAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeStarArgWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_argExpr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))) :+: C1 (MetaCons "DoubleStarArg" PrefixI True) (S1 (MetaSel (Just "_argAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeDoubleStarArgWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_argExpr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))))))

Positional

class PositionalSyntax p v | p -> v, v -> p where Source #

Positional parameters/arguments

p_ :: Raw SimpleStatement -> Raw Arg
p_ :: Raw Expr -> Raw Param

Methods

p_ :: Raw v -> Raw p Source #

Instances
PositionalSyntax Arg Expr Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

p_ :: Raw Expr -> Raw Arg Source #

PositionalSyntax Param Ident Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

p_ :: Raw Ident -> Raw Param Source #

data PositionalParam v a Source #

Constructors

MkPositionalParam 

Fields

Instances
Functor (PositionalParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> PositionalParam v a -> PositionalParam v b #

(<$) :: a -> PositionalParam v b -> PositionalParam v a #

Foldable (PositionalParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => PositionalParam v m -> m #

foldMap :: Monoid m => (a -> m) -> PositionalParam v a -> m #

foldr :: (a -> b -> b) -> b -> PositionalParam v a -> b #

foldr' :: (a -> b -> b) -> b -> PositionalParam v a -> b #

foldl :: (b -> a -> b) -> b -> PositionalParam v a -> b #

foldl' :: (b -> a -> b) -> b -> PositionalParam v a -> b #

foldr1 :: (a -> a -> a) -> PositionalParam v a -> a #

foldl1 :: (a -> a -> a) -> PositionalParam v a -> a #

toList :: PositionalParam v a -> [a] #

null :: PositionalParam v a -> Bool #

length :: PositionalParam v a -> Int #

elem :: Eq a => a -> PositionalParam v a -> Bool #

maximum :: Ord a => PositionalParam v a -> a #

minimum :: Ord a => PositionalParam v a -> a #

sum :: Num a => PositionalParam v a -> a #

product :: Num a => PositionalParam v a -> a #

Traversable (PositionalParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => PositionalParam v (f a) -> f (PositionalParam v a) #

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

sequence :: Monad m => PositionalParam v (m a) -> m (PositionalParam v a) #

HasAnn (PositionalParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (PositionalParam v a) (Ann a) Source #

Eq a => Eq (PositionalParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Show a => Show (PositionalParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Generic (PositionalParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (PositionalParam v a) :: Type -> Type #

Methods

from :: PositionalParam v a -> Rep (PositionalParam v a) x #

to :: Rep (PositionalParam v a) x -> PositionalParam v a #

type Rep (PositionalParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (PositionalParam v a) = D1 (MetaData "PositionalParam" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkPositionalParam" PrefixI True) (S1 (MetaSel (Just "_ppAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_ppName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a)) :*: S1 (MetaSel (Just "_ppType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (Colon, Expr v a))))))

Lenses

ppAnn :: forall v a. Lens' (PositionalParam v a) (Ann a) Source #

ppName :: forall v a. Lens' (PositionalParam v a) (Ident v a) Source #

ppType :: forall v a. Lens' (PositionalParam v a) (Maybe (Colon, Expr v a)) Source #

Keyword

class KeywordSyntax p where Source #

Keyword parameters/arguments

p_ :: Raw SimpleStatement -> Raw SimpleStatement -> Raw Arg
p_ :: Raw Expr -> Raw SimpleStatement -> Raw Param

Methods

k_ :: Raw Ident -> Raw Expr -> Raw p Source #

Instances
KeywordSyntax Arg Source #

See call_

Instance details

Defined in Language.Python.DSL

Methods

k_ :: Raw Ident -> Raw Expr -> Raw Arg Source #

KeywordSyntax Param Source #

See def_

Instance details

Defined in Language.Python.DSL

Methods

k_ :: Raw Ident -> Raw Expr -> Raw Param Source #

data KeywordParam v a Source #

Constructors

MkKeywordParam 

Fields

Instances
Functor (KeywordParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> KeywordParam v a -> KeywordParam v b #

(<$) :: a -> KeywordParam v b -> KeywordParam v a #

Foldable (KeywordParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => KeywordParam v m -> m #

foldMap :: Monoid m => (a -> m) -> KeywordParam v a -> m #

foldr :: (a -> b -> b) -> b -> KeywordParam v a -> b #

foldr' :: (a -> b -> b) -> b -> KeywordParam v a -> b #

foldl :: (b -> a -> b) -> b -> KeywordParam v a -> b #

foldl' :: (b -> a -> b) -> b -> KeywordParam v a -> b #

foldr1 :: (a -> a -> a) -> KeywordParam v a -> a #

foldl1 :: (a -> a -> a) -> KeywordParam v a -> a #

toList :: KeywordParam v a -> [a] #

null :: KeywordParam v a -> Bool #

length :: KeywordParam v a -> Int #

elem :: Eq a => a -> KeywordParam v a -> Bool #

maximum :: Ord a => KeywordParam v a -> a #

minimum :: Ord a => KeywordParam v a -> a #

sum :: Num a => KeywordParam v a -> a #

product :: Num a => KeywordParam v a -> a #

Traversable (KeywordParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => KeywordParam v (f a) -> f (KeywordParam v a) #

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

sequence :: Monad m => KeywordParam v (m a) -> m (KeywordParam v a) #

HasAnn (KeywordParam v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (KeywordParam v a) (Ann a) Source #

Eq a => Eq (KeywordParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: KeywordParam v a -> KeywordParam v a -> Bool #

(/=) :: KeywordParam v a -> KeywordParam v a -> Bool #

Show a => Show (KeywordParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Generic (KeywordParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (KeywordParam v a) :: Type -> Type #

Methods

from :: KeywordParam v a -> Rep (KeywordParam v a) x #

to :: Rep (KeywordParam v a) x -> KeywordParam v a #

type Rep (KeywordParam v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (KeywordParam v a) = D1 (MetaData "KeywordParam" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkKeywordParam" PrefixI True) ((S1 (MetaSel (Just "_kpAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_kpName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ident v a))) :*: (S1 (MetaSel (Just "_kpType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (Colon, Expr v a))) :*: (S1 (MetaSel (Just "_kpEquals") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_kpExpr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))))))

Lenses

kpAnn :: forall v a. Lens' (KeywordParam v a) (Ann a) Source #

kpName :: forall v a. Lens' (KeywordParam v a) (Ident v a) Source #

kpType :: forall v a. Lens' (KeywordParam v a) (Maybe (Colon, Expr v a)) Source #

kpEquals :: forall v a. Lens' (KeywordParam v a) [Whitespace] Source #

kpExpr :: forall v a. Lens' (KeywordParam v a) (Expr v a) Source #

Decorators

Statements

async

class AsyncSyntax s where Source #

Methods

async_ :: Raw s -> Raw s Source #

Instances
AsyncSyntax Fundef Source # 
Instance details

Defined in Language.Python.DSL

AsyncSyntax For Source # 
Instance details

Defined in Language.Python.DSL

Methods

async_ :: Raw For -> Raw For Source #

AsyncSyntax With Source # 
Instance details

Defined in Language.Python.DSL

Methods

async_ :: Raw With -> Raw With Source #

Block bodies

class BodySyntax s where Source #

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw s -> f (Raw s) Source #

A faux-Lens that targets lines in the body of some statement-piece, but does so 'around' indentation.

>>> def_ "a" [] [ line_ pass_, line_ pass_ ]
def a ():
    pass
    pass
>>> def_ "a" [] [ line_ pass_, line_ pass_ ] ^. body_
pass
pass
>>> def_ "a" [] [ line_ pass_, line_ pass_ ] & body_ .~ [ line_ $ var_ "b" += 1 ]
def a():
    b += 1
>>> def_ "a" [] [ line_ pass_, line_ pass_ ] & body_ <>~ [ line_ $ var_ "b" += 1 ]
def a():
    pass
    pass
    b += 1
>>> def_ "a" [] [ line_ pass_, line_ pass_ ] & body_ .~ []
def a():
    pass

---

It's a fake Lens because it violates some of the laws. The most obvious violation is that setting the body_ to the empty list actually sets it to a singleton list containing pass_. (This is because blocks must contain one or more statements)

body :: Lens' (Raw s) (Raw Suite) Source #

Instances
BodySyntax Fundef Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw Fundef -> f (Raw Fundef) Source #

body :: Lens' (Raw Fundef) (Raw Suite) Source #

BodySyntax Else Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw Else -> f (Raw Else) Source #

body :: Lens' (Raw Else) (Raw Suite) Source #

BodySyntax While Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw While -> f (Raw While) Source #

body :: Lens' (Raw While) (Raw Suite) Source #

BodySyntax Elif Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw Elif -> f (Raw Elif) Source #

body :: Lens' (Raw Elif) (Raw Suite) Source #

BodySyntax If Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw If -> f (Raw If) Source #

body :: Lens' (Raw If) (Raw Suite) Source #

BodySyntax For Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw For -> f (Raw For) Source #

body :: Lens' (Raw For) (Raw Suite) Source #

BodySyntax TryExcept Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax TryFinally Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax ClassDef Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw ClassDef -> f (Raw ClassDef) Source #

body :: Lens' (Raw ClassDef) (Raw Suite) Source #

BodySyntax With Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw With -> f (Raw With) Source #

body :: Lens' (Raw With) (Raw Suite) Source #

Function definitions

def_ :: Raw Ident -> [Raw Param] -> [Raw Line] -> Raw Fundef Source #

>>> def_ "f" [p_ "x"] [line_ $ return_ "x"]
def f(x):
    return x
>>> def_ "f" [p_ "x", k_ "y" 2] [line_ $ return_ "x"]
def f(x, y=2):
    return x
>>> def_ "f" [p_ "x", k_ "y" 2, s_ "z"] [line_ $ return_ "x"]
def f(x, y=2, *z):
    return x
>>> def_ "f" [p_ "x", k_ "y" 2, s_ "z", ss_ "w"] [line_ $ return_ "x"]
def f(x, y=2, *z, **w)
    return x
>>> def_ "f" [p_ "x" .: "String"] [line_ $ return_ "x"]
def f(x: String):
    return x

data Fundef v a Source #

Instances
HasFundef Fundef Source # 
Instance details

Defined in Language.Python.Optics

Methods

_Fundef :: Prism (Fundef v a) (Fundef [] a) (Fundef v a) (Fundef [] a) Source #

AsyncSyntax Fundef Source # 
Instance details

Defined in Language.Python.DSL

DecoratorsSyntax Fundef Source # 
Instance details

Defined in Language.Python.DSL

ParametersSyntax Fundef Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax Fundef Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw Fundef -> f (Raw Fundef) Source #

body :: Lens' (Raw Fundef) (Raw Suite) Source #

AsLine Fundef Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw Fundef -> Raw Line Source #

Functor (Fundef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> Fundef v a -> Fundef v b #

(<$) :: a -> Fundef v b -> Fundef v a #

Foldable (Fundef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => Fundef v m -> m #

foldMap :: Monoid m => (a -> m) -> Fundef v a -> m #

foldr :: (a -> b -> b) -> b -> Fundef v a -> b #

foldr' :: (a -> b -> b) -> b -> Fundef v a -> b #

foldl :: (b -> a -> b) -> b -> Fundef v a -> b #

foldl' :: (b -> a -> b) -> b -> Fundef v a -> b #

foldr1 :: (a -> a -> a) -> Fundef v a -> a #

foldl1 :: (a -> a -> a) -> Fundef v a -> a #

toList :: Fundef v a -> [a] #

null :: Fundef v a -> Bool #

length :: Fundef v a -> Int #

elem :: Eq a => a -> Fundef v a -> Bool #

maximum :: Ord a => Fundef v a -> a #

minimum :: Ord a => Fundef v a -> a #

sum :: Num a => Fundef v a -> a #

product :: Num a => Fundef v a -> a #

Traversable (Fundef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => Fundef v (f a) -> f (Fundef v a) #

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

sequence :: Monad m => Fundef v (m a) -> m (Fundef v a) #

HasAnn (Fundef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (Fundef v a) (Ann a) Source #

Eq a => Eq (Fundef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: Fundef v a -> Fundef v a -> Bool #

(/=) :: Fundef v a -> Fundef v a -> Bool #

Show a => Show (Fundef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> Fundef v a -> ShowS #

show :: Fundef v a -> String #

showList :: [Fundef v a] -> ShowS #

Generic (Fundef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (Fundef v a) :: Type -> Type #

Methods

from :: Fundef v a -> Rep (Fundef v a) x #

to :: Rep (Fundef v a) x -> Fundef v a #

HasIndents (Fundef ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (Fundef [] a) (Indents a) Source #

type Rep (Fundef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

mkFundef :: Raw Ident -> [Raw Line] -> Raw Fundef Source #

Create a minimal valid function definition

Lenses

fdAnn :: forall v a. Lens' (Fundef v a) (Ann a) Source #

fdDecorators :: forall v a. Lens' (Fundef v a) [Decorator v a] Source #

fdIndents :: forall v a. Lens' (Fundef v a) (Indents a) Source #

fdAsync :: forall v a. Lens' (Fundef v a) (Maybe (NonEmpty Whitespace)) Source #

fdName :: forall v a. Lens' (Fundef v a) (Ident v a) Source #

fdParameters :: forall v a. Lens' (Fundef v a) (CommaSep (Param v a)) Source #

fdReturnType :: forall v a. Lens' (Fundef v a) (Maybe ([Whitespace], Expr v a)) Source #

fdBody :: forall v a. Lens' (Fundef v a) (Suite v a) Source #

Class definitions

class_ :: Raw Ident -> [Raw Arg] -> [Raw Line] -> Raw ClassDef Source #

>>> class_ "A" [] [line_ pass_]
class A:
    pass

data ClassDef v a Source #

Instances
HasClassDef ClassDef Source # 
Instance details

Defined in Language.Python.Optics

Methods

_ClassDef :: Prism (ClassDef v a) (ClassDef [] a) (ClassDef v a) (ClassDef [] a) Source #

DecoratorsSyntax ClassDef Source # 
Instance details

Defined in Language.Python.DSL

ArgumentsSyntax ClassDef Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax ClassDef Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw ClassDef -> f (Raw ClassDef) Source #

body :: Lens' (Raw ClassDef) (Raw Suite) Source #

AsLine ClassDef Source # 
Instance details

Defined in Language.Python.DSL

Functor (ClassDef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> ClassDef v a -> ClassDef v b #

(<$) :: a -> ClassDef v b -> ClassDef v a #

Foldable (ClassDef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => ClassDef v m -> m #

foldMap :: Monoid m => (a -> m) -> ClassDef v a -> m #

foldr :: (a -> b -> b) -> b -> ClassDef v a -> b #

foldr' :: (a -> b -> b) -> b -> ClassDef v a -> b #

foldl :: (b -> a -> b) -> b -> ClassDef v a -> b #

foldl' :: (b -> a -> b) -> b -> ClassDef v a -> b #

foldr1 :: (a -> a -> a) -> ClassDef v a -> a #

foldl1 :: (a -> a -> a) -> ClassDef v a -> a #

toList :: ClassDef v a -> [a] #

null :: ClassDef v a -> Bool #

length :: ClassDef v a -> Int #

elem :: Eq a => a -> ClassDef v a -> Bool #

maximum :: Ord a => ClassDef v a -> a #

minimum :: Ord a => ClassDef v a -> a #

sum :: Num a => ClassDef v a -> a #

product :: Num a => ClassDef v a -> a #

Traversable (ClassDef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => ClassDef v (f a) -> f (ClassDef v a) #

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

sequence :: Monad m => ClassDef v (m a) -> m (ClassDef v a) #

HasAnn (ClassDef v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (ClassDef v a) (Ann a) Source #

Eq a => Eq (ClassDef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: ClassDef v a -> ClassDef v a -> Bool #

(/=) :: ClassDef v a -> ClassDef v a -> Bool #

Show a => Show (ClassDef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> ClassDef v a -> ShowS #

show :: ClassDef v a -> String #

showList :: [ClassDef v a] -> ShowS #

Generic (ClassDef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (ClassDef v a) :: Type -> Type #

Methods

from :: ClassDef v a -> Rep (ClassDef v a) x #

to :: Rep (ClassDef v a) x -> ClassDef v a #

HasIndents (ClassDef ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

type Rep (ClassDef v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

mkClassDef :: Raw Ident -> [Raw Line] -> Raw ClassDef Source #

Create a minimal ClassDef

Lenses

cdAnn :: forall v a. Lens' (ClassDef v a) (Ann a) Source #

cdDecorators :: forall v a. Lens' (ClassDef v a) [Decorator v a] Source #

cdIndents :: forall v a. Lens' (ClassDef v a) (Indents a) Source #

cdName :: forall v a. Lens' (ClassDef v a) (Ident v a) Source #

cdBody :: forall v a. Lens' (ClassDef v a) (Suite v a) Source #

Assignment

chainEq :: Raw Expr -> [Raw Expr] -> Raw Statement Source #

Chained assignment

>>> chainEq (var_ "a") []
a
>>> chainEq (var_ "a") [var_ "b", var_ "c"]
a = b = c

(.=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a = b

(.+=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a += b

(.-=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a -= b

(.*=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a *= b

(.@=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a = b@

(./=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a /= b

(.%=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a %= b

(.&=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a &= b

(.|=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a |= b

(.^=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a ^= b

(.<<=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a <<= b

(.>>=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a >>= b

(.**=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a **= b

(.//=) :: Raw Expr -> Raw Expr -> Raw Statement infix 0 Source #

a //= b

Exceptions

tryE_ :: [Raw Line] -> Raw Except -> Raw TryExcept Source #

try ... except with optional else and optional finally

>>> tryE_ [line_ pass_] [line_ ("a" .+= 1)]
try:
    pass
except
    a += 1

tryF_ :: [Raw Line] -> [Raw Line] -> Raw TryFinally Source #

try ... finally
>>> tryF_ [line_ pass_] [line_ ("a" .+= 1)]
try:
    pass
finally:
    a += 1

class ExceptSyntax s where Source #

Methods

except_ :: [Raw Line] -> s -> Raw TryExcept Source #

exceptAs_ :: AsExceptAs e => Raw e -> [Raw Line] -> s -> Raw TryExcept Source #

You can use exceptAs_ without a binder:

exceptAs_ :: Raw SimpleStatement -> [Raw Line] -> Raw s -> Raw TryExcept
exceptAs_ (var_ "Exception") body

or with a binder:

exceptAs_ :: Raw ExceptAs -> [Raw Line] -> Raw s -> Raw TryExcept
exceptAs_ (var_ "Exception" `as_` id_ "a") body
Instances
ExceptSyntax (Raw TryExcept) Source #
except_ :: [Raw Line] -> Raw TryExcept -> Raw TryExcept
exceptAs_ :: AsExceptAs => Raw e -> [Raw Line] -> Raw TryExcept -> Raw TryExcept
(someTryStatement :: Raw TryExcept) &
  except_ [line_ pass_]
(someTryStatement :: Raw TryExcept) &
  exceptAs_ (var_ "Exception" `as_` id_ "b") [line_ pass_]
Instance details

Defined in Language.Python.DSL

ExceptSyntax (Raw TryFinally) Source #
except_ :: [Raw Line] -> Raw TryFinally -> Raw TryExcept
exceptAs_ :: AsExceptAs => Raw e -> [Raw Line] -> Raw TryFinally -> Raw TryExcept
(someTryStatement :: Raw TryFinally) &
  except_ [line_ pass_]
(someTryStatement :: Raw TryFinally) &
  exceptAs_ (var_ "Exception" `as_` id_ "b") [line_ pass_]
Instance details

Defined in Language.Python.DSL

(e ~ Raw Except, s ~ Raw TryExcept) => ExceptSyntax (e -> s) Source #
except_ :: [Raw Line] -> (Raw Except -> Raw TryExcept) -> Raw TryExcept
exceptAs_ :: AsExceptAs e => Raw e -> [Raw Line] -> (Raw Except -> Raw TryExcept) -> Raw TryExcept
>>> tryE_ [var_ "a" .= 2] & except_ [var_ "a" .= 3]
try:
    a = 2
except:
    a = 3
>>> tryE_ [var_ "a" .= 2] & exceptAs_ (var_ "Exception" `as_` id_ "b") [var_ "a" .= 3]
try:
    a = 2
except Exception as b:
    a = 3
Instance details

Defined in Language.Python.DSL

Methods

except_ :: [Raw Line] -> (e -> s) -> Raw TryExcept Source #

exceptAs_ :: AsExceptAs e0 => Raw e0 -> [Raw Line] -> (e -> s) -> Raw TryExcept Source #

class FinallySyntax s t | s -> t where Source #

Methods

finally_ :: [Raw Line] -> s -> Raw t Source #

Instances
FinallySyntax (Raw TryExcept) TryExcept Source #
>>> tryE_ [line_ pass_] & finally_ [line_ pass_]
try:
    pass
finally:
    pass
>>> tryF_ [line_ pass_] [line_ (a .+= 1)] & finally_ [line_ pass_]
try:
    pass
finally:
    pass
>>> tryF_ [line_ pass_] & finally_ [line_ pass_]
try:
    pass
finally:
    pass
Instance details

Defined in Language.Python.DSL

FinallySyntax (Raw TryFinally) TryFinally Source # 
Instance details

Defined in Language.Python.DSL

(a ~ [Raw Line], b ~ Raw TryFinally) => FinallySyntax (a -> b) TryFinally Source # 
Instance details

Defined in Language.Python.DSL

Methods

finally_ :: [Raw Line] -> (a -> b) -> Raw TryFinally Source #

data TryExcept v a Source #

Constructors

MkTryExcept 

Fields

Instances
HasTryExcept TryExcept Source # 
Instance details

Defined in Language.Python.Optics

Methods

_TryExcept :: Prism (TryExcept v a) (TryExcept [] a) (TryExcept v a) (TryExcept [] a) Source #

ElseSyntax TryExcept Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax TryExcept Source # 
Instance details

Defined in Language.Python.DSL

AsLine TryExcept Source # 
Instance details

Defined in Language.Python.DSL

Functor (TryExcept v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> TryExcept v a -> TryExcept v b #

(<$) :: a -> TryExcept v b -> TryExcept v a #

Foldable (TryExcept v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => TryExcept v m -> m #

foldMap :: Monoid m => (a -> m) -> TryExcept v a -> m #

foldr :: (a -> b -> b) -> b -> TryExcept v a -> b #

foldr' :: (a -> b -> b) -> b -> TryExcept v a -> b #

foldl :: (b -> a -> b) -> b -> TryExcept v a -> b #

foldl' :: (b -> a -> b) -> b -> TryExcept v a -> b #

foldr1 :: (a -> a -> a) -> TryExcept v a -> a #

foldl1 :: (a -> a -> a) -> TryExcept v a -> a #

toList :: TryExcept v a -> [a] #

null :: TryExcept v a -> Bool #

length :: TryExcept v a -> Int #

elem :: Eq a => a -> TryExcept v a -> Bool #

maximum :: Ord a => TryExcept v a -> a #

minimum :: Ord a => TryExcept v a -> a #

sum :: Num a => TryExcept v a -> a #

product :: Num a => TryExcept v a -> a #

Traversable (TryExcept v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => TryExcept v (f a) -> f (TryExcept v a) #

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

sequence :: Monad m => TryExcept v (m a) -> m (TryExcept v a) #

HasAnn (TryExcept v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (TryExcept v a) (Ann a) Source #

ExceptSyntax (Raw TryExcept) Source #
except_ :: [Raw Line] -> Raw TryExcept -> Raw TryExcept
exceptAs_ :: AsExceptAs => Raw e -> [Raw Line] -> Raw TryExcept -> Raw TryExcept
(someTryStatement :: Raw TryExcept) &
  except_ [line_ pass_]
(someTryStatement :: Raw TryExcept) &
  exceptAs_ (var_ "Exception" `as_` id_ "b") [line_ pass_]
Instance details

Defined in Language.Python.DSL

FinallySyntax (Raw TryExcept) TryExcept Source #
>>> tryE_ [line_ pass_] & finally_ [line_ pass_]
try:
    pass
finally:
    pass
>>> tryF_ [line_ pass_] [line_ (a .+= 1)] & finally_ [line_ pass_]
try:
    pass
finally:
    pass
>>> tryF_ [line_ pass_] & finally_ [line_ pass_]
try:
    pass
finally:
    pass
Instance details

Defined in Language.Python.DSL

Eq a => Eq (TryExcept v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: TryExcept v a -> TryExcept v a -> Bool #

(/=) :: TryExcept v a -> TryExcept v a -> Bool #

Show a => Show (TryExcept v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> TryExcept v a -> ShowS #

show :: TryExcept v a -> String #

showList :: [TryExcept v a] -> ShowS #

Generic (TryExcept v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (TryExcept v a) :: Type -> Type #

Methods

from :: TryExcept v a -> Rep (TryExcept v a) x #

to :: Rep (TryExcept v a) x -> TryExcept v a #

HasIndents (TryExcept ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

type Rep (TryExcept v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

mkTryExcept :: [Raw Line] -> Raw Except -> Raw TryExcept Source #

Create a minimal valid TryExcept

data TryFinally v a Source #

Constructors

MkTryFinally 

Fields

Instances
HasTryFinally TryFinally Source # 
Instance details

Defined in Language.Python.Optics

Methods

_TryFinally :: Prism (TryFinally v a) (TryFinally [] a) (TryFinally v a) (TryFinally [] a) Source #

BodySyntax TryFinally Source # 
Instance details

Defined in Language.Python.DSL

AsLine TryFinally Source # 
Instance details

Defined in Language.Python.DSL

Functor (TryFinally v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> TryFinally v a -> TryFinally v b #

(<$) :: a -> TryFinally v b -> TryFinally v a #

Foldable (TryFinally v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => TryFinally v m -> m #

foldMap :: Monoid m => (a -> m) -> TryFinally v a -> m #

foldr :: (a -> b -> b) -> b -> TryFinally v a -> b #

foldr' :: (a -> b -> b) -> b -> TryFinally v a -> b #

foldl :: (b -> a -> b) -> b -> TryFinally v a -> b #

foldl' :: (b -> a -> b) -> b -> TryFinally v a -> b #

foldr1 :: (a -> a -> a) -> TryFinally v a -> a #

foldl1 :: (a -> a -> a) -> TryFinally v a -> a #

toList :: TryFinally v a -> [a] #

null :: TryFinally v a -> Bool #

length :: TryFinally v a -> Int #

elem :: Eq a => a -> TryFinally v a -> Bool #

maximum :: Ord a => TryFinally v a -> a #

minimum :: Ord a => TryFinally v a -> a #

sum :: Num a => TryFinally v a -> a #

product :: Num a => TryFinally v a -> a #

Traversable (TryFinally v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => TryFinally v (f a) -> f (TryFinally v a) #

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

sequence :: Monad m => TryFinally v (m a) -> m (TryFinally v a) #

HasAnn (TryFinally v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (TryFinally v a) (Ann a) Source #

ExceptSyntax (Raw TryFinally) Source #
except_ :: [Raw Line] -> Raw TryFinally -> Raw TryExcept
exceptAs_ :: AsExceptAs => Raw e -> [Raw Line] -> Raw TryFinally -> Raw TryExcept
(someTryStatement :: Raw TryFinally) &
  except_ [line_ pass_]
(someTryStatement :: Raw TryFinally) &
  exceptAs_ (var_ "Exception" `as_` id_ "b") [line_ pass_]
Instance details

Defined in Language.Python.DSL

FinallySyntax (Raw TryFinally) TryFinally Source # 
Instance details

Defined in Language.Python.DSL

Eq a => Eq (TryFinally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: TryFinally v a -> TryFinally v a -> Bool #

(/=) :: TryFinally v a -> TryFinally v a -> Bool #

Show a => Show (TryFinally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> TryFinally v a -> ShowS #

show :: TryFinally v a -> String #

showList :: [TryFinally v a] -> ShowS #

Generic (TryFinally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (TryFinally v a) :: Type -> Type #

Methods

from :: TryFinally v a -> Rep (TryFinally v a) x #

to :: Rep (TryFinally v a) x -> TryFinally v a #

HasIndents (TryFinally ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

(a ~ [Raw Line], b ~ Raw TryFinally) => FinallySyntax (a -> b) TryFinally Source # 
Instance details

Defined in Language.Python.DSL

Methods

finally_ :: [Raw Line] -> (a -> b) -> Raw TryFinally Source #

type Rep (TryFinally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

mkTryFinally :: [Raw Line] -> [Raw Line] -> Raw TryFinally Source #

Create a minimal valid TryFinally

data ExceptAs (v :: [*]) a Source #

Constructors

ExceptAs 

Fields

Instances
Validated ExceptAs Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

unvalidated :: Getter (ExceptAs v a) (ExceptAs [] a) Source #

HasExprs ExceptAs Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

_Exprs :: Traversal (ExceptAs v a) (ExceptAs [] a) (Expr v a) (Expr [] a) Source #

HasIdents ExceptAs Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (ExceptAs v a) (ExceptAs [] a) (Ident v a) (Ident [] a) Source #

AsExceptAs ExceptAs Source # 
Instance details

Defined in Language.Python.DSL

As Expr Ident ExceptAs Source #

See exceptAs_

Instance details

Defined in Language.Python.DSL

Methods

as_ :: Raw Expr -> Raw Ident -> Raw ExceptAs Source #

Functor (ExceptAs v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

fmap :: (a -> b) -> ExceptAs v a -> ExceptAs v b #

(<$) :: a -> ExceptAs v b -> ExceptAs v a #

Foldable (ExceptAs v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

fold :: Monoid m => ExceptAs v m -> m #

foldMap :: Monoid m => (a -> m) -> ExceptAs v a -> m #

foldr :: (a -> b -> b) -> b -> ExceptAs v a -> b #

foldr' :: (a -> b -> b) -> b -> ExceptAs v a -> b #

foldl :: (b -> a -> b) -> b -> ExceptAs v a -> b #

foldl' :: (b -> a -> b) -> b -> ExceptAs v a -> b #

foldr1 :: (a -> a -> a) -> ExceptAs v a -> a #

foldl1 :: (a -> a -> a) -> ExceptAs v a -> a #

toList :: ExceptAs v a -> [a] #

null :: ExceptAs v a -> Bool #

length :: ExceptAs v a -> Int #

elem :: Eq a => a -> ExceptAs v a -> Bool #

maximum :: Ord a => ExceptAs v a -> a #

minimum :: Ord a => ExceptAs v a -> a #

sum :: Num a => ExceptAs v a -> a #

product :: Num a => ExceptAs v a -> a #

Traversable (ExceptAs v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

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

sequenceA :: Applicative f => ExceptAs v (f a) -> f (ExceptAs v a) #

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

sequence :: Monad m => ExceptAs v (m a) -> m (ExceptAs v a) #

HasAnn (ExceptAs v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

annot :: Lens' (ExceptAs v a) (Ann a) Source #

Eq a => Eq (ExceptAs v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

(==) :: ExceptAs v a -> ExceptAs v a -> Bool #

(/=) :: ExceptAs v a -> ExceptAs v a -> Bool #

Show a => Show (ExceptAs v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

showsPrec :: Int -> ExceptAs v a -> ShowS #

show :: ExceptAs v a -> String #

showList :: [ExceptAs v a] -> ShowS #

Generic (ExceptAs v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Associated Types

type Rep (ExceptAs v a) :: Type -> Type #

Methods

from :: ExceptAs v a -> Rep (ExceptAs v a) x #

to :: Rep (ExceptAs v a) x -> ExceptAs v a #

HasNewlines (ExceptAs v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (ExceptAs v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

type Rep (ExceptAs v a) = D1 (MetaData "ExceptAs" "Language.Python.Syntax.Statement" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "ExceptAs" PrefixI True) (S1 (MetaSel (Just "_exceptAsAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_exceptAsExpr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)) :*: S1 (MetaSel (Just "_exceptAsName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe ([Whitespace], Ident v a))))))

class AsExceptAs s where Source #

Instances
AsExceptAs Expr Source # 
Instance details

Defined in Language.Python.DSL

AsExceptAs ExceptAs Source # 
Instance details

Defined in Language.Python.DSL

data Except v a Source #

Instances
Functor (Except v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> Except v a -> Except v b #

(<$) :: a -> Except v b -> Except v a #

Foldable (Except v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => Except v m -> m #

foldMap :: Monoid m => (a -> m) -> Except v a -> m #

foldr :: (a -> b -> b) -> b -> Except v a -> b #

foldr' :: (a -> b -> b) -> b -> Except v a -> b #

foldl :: (b -> a -> b) -> b -> Except v a -> b #

foldl' :: (b -> a -> b) -> b -> Except v a -> b #

foldr1 :: (a -> a -> a) -> Except v a -> a #

foldl1 :: (a -> a -> a) -> Except v a -> a #

toList :: Except v a -> [a] #

null :: Except v a -> Bool #

length :: Except v a -> Int #

elem :: Eq a => a -> Except v a -> Bool #

maximum :: Ord a => Except v a -> a #

minimum :: Ord a => Except v a -> a #

sum :: Num a => Except v a -> a #

product :: Num a => Except v a -> a #

Traversable (Except v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => Except v (f a) -> f (Except v a) #

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

sequence :: Monad m => Except v (m a) -> m (Except v a) #

Eq a => Eq (Except v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: Except v a -> Except v a -> Bool #

(/=) :: Except v a -> Except v a -> Bool #

Show a => Show (Except v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> Except v a -> ShowS #

show :: Except v a -> String #

showList :: [Except v a] -> ShowS #

Generic (Except v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (Except v a) :: Type -> Type #

Methods

from :: Except v a -> Rep (Except v a) x #

to :: Rep (Except v a) x -> Except v a #

HasIndents (Except ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (Except [] a) (Indents a) Source #

type Rep (Except v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (Except v a) = D1 (MetaData "Except" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkExcept" PrefixI True) ((S1 (MetaSel (Just "_exceptIndents") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Indents a)) :*: S1 (MetaSel (Just "_exceptExcept") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_exceptExceptAs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (ExceptAs v a))) :*: S1 (MetaSel (Just "_exceptBody") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Suite v a)))))

mkExcept :: [Raw Line] -> Raw Except Source #

Create a minimal valid Except

data Finally v a Source #

Instances
Functor (Finally v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> Finally v a -> Finally v b #

(<$) :: a -> Finally v b -> Finally v a #

Foldable (Finally v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => Finally v m -> m #

foldMap :: Monoid m => (a -> m) -> Finally v a -> m #

foldr :: (a -> b -> b) -> b -> Finally v a -> b #

foldr' :: (a -> b -> b) -> b -> Finally v a -> b #

foldl :: (b -> a -> b) -> b -> Finally v a -> b #

foldl' :: (b -> a -> b) -> b -> Finally v a -> b #

foldr1 :: (a -> a -> a) -> Finally v a -> a #

foldl1 :: (a -> a -> a) -> Finally v a -> a #

toList :: Finally v a -> [a] #

null :: Finally v a -> Bool #

length :: Finally v a -> Int #

elem :: Eq a => a -> Finally v a -> Bool #

maximum :: Ord a => Finally v a -> a #

minimum :: Ord a => Finally v a -> a #

sum :: Num a => Finally v a -> a #

product :: Num a => Finally v a -> a #

Traversable (Finally v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => Finally v (f a) -> f (Finally v a) #

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

sequence :: Monad m => Finally v (m a) -> m (Finally v a) #

Eq a => Eq (Finally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: Finally v a -> Finally v a -> Bool #

(/=) :: Finally v a -> Finally v a -> Bool #

Show a => Show (Finally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> Finally v a -> ShowS #

show :: Finally v a -> String #

showList :: [Finally v a] -> ShowS #

Generic (Finally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (Finally v a) :: Type -> Type #

Methods

from :: Finally v a -> Rep (Finally v a) x #

to :: Rep (Finally v a) x -> Finally v a #

HasIndents (Finally ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (Finally [] a) (Indents a) Source #

type Rep (Finally v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (Finally v a) = D1 (MetaData "Finally" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkFinally" PrefixI True) (S1 (MetaSel (Just "_finallyIndents") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Indents a)) :*: (S1 (MetaSel (Just "_finallyFinally") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_finallyBody") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Suite v a)))))

mkFinally :: [Raw Line] -> Raw Finally Source #

Create a minimal valid Finally

Lenses

teAnn :: forall v a. Lens' (TryExcept v a) (Ann a) Source #

teIndents :: forall v a. Lens' (TryExcept v a) (Indents a) Source #

teTry :: forall v a. Lens' (TryExcept v a) [Whitespace] Source #

teBody :: forall v a. Lens' (TryExcept v a) (Suite v a) Source #

teExcepts :: forall v a. Lens' (TryExcept v a) (NonEmpty (Except v a)) Source #

teElse :: forall v a. Lens' (TryExcept v a) (Maybe (Else v a)) Source #

teFinally :: forall v a. Lens' (TryExcept v a) (Maybe (Finally v a)) Source #

exceptIndents :: forall v a. Lens' (Except v a) (Indents a) Source #

exceptExcept :: forall v a. Lens' (Except v a) [Whitespace] Source #

exceptExceptAs :: forall v a. Lens' (Except v a) (Maybe (ExceptAs v a)) Source #

exceptBody :: forall v a. Lens' (Except v a) (Suite v a) Source #

finallyIndents :: forall v a. Lens' (Finally v a) (Indents a) Source #

finallyBody :: forall v a v. Lens (Finally v a) (Finally v a) (Suite v a) (Suite v a) Source #

With statements

with_ :: AsWithItem e => NonEmpty (Raw e) -> [Raw Line] -> Raw With Source #

with_ :: NonEmpty (Raw SimpleStatement) -> [Raw Line] -> Raw Statement
with_ :: NonEmpty (Raw WithItem) -> [Raw Line] -> Raw Statement
>>> with_ [var_ "a"] [line_ $ var_ "b"]
with a:
    b
>>> with_ [var_ "a" `as_` id_ "name"] [line_ $ var_ "b"]
with a as name:
    b
>>> with_ [withItem_ e Nothing] [line_ $ var_ "b"]
with a:
    b

data With v a Source #

Instances
HasWith With Source # 
Instance details

Defined in Language.Python.Optics

Methods

_With :: Prism (With v a) (With [] a) (With v a) (With [] a) Source #

AsyncSyntax With Source # 
Instance details

Defined in Language.Python.DSL

Methods

async_ :: Raw With -> Raw With Source #

BodySyntax With Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw With -> f (Raw With) Source #

body :: Lens' (Raw With) (Raw Suite) Source #

AsLine With Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw With -> Raw Line Source #

Functor (With v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> With v a -> With v b #

(<$) :: a -> With v b -> With v a #

Foldable (With v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => With v m -> m #

foldMap :: Monoid m => (a -> m) -> With v a -> m #

foldr :: (a -> b -> b) -> b -> With v a -> b #

foldr' :: (a -> b -> b) -> b -> With v a -> b #

foldl :: (b -> a -> b) -> b -> With v a -> b #

foldl' :: (b -> a -> b) -> b -> With v a -> b #

foldr1 :: (a -> a -> a) -> With v a -> a #

foldl1 :: (a -> a -> a) -> With v a -> a #

toList :: With v a -> [a] #

null :: With v a -> Bool #

length :: With v a -> Int #

elem :: Eq a => a -> With v a -> Bool #

maximum :: Ord a => With v a -> a #

minimum :: Ord a => With v a -> a #

sum :: Num a => With v a -> a #

product :: Num a => With v a -> a #

Traversable (With v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => With v (f a) -> f (With v a) #

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

sequence :: Monad m => With v (m a) -> m (With v a) #

HasAnn (With v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (With v a) (Ann a) Source #

Eq a => Eq (With v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: With v a -> With v a -> Bool #

(/=) :: With v a -> With v a -> Bool #

Show a => Show (With v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> With v a -> ShowS #

show :: With v a -> String #

showList :: [With v a] -> ShowS #

Generic (With v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (With v a) :: Type -> Type #

Methods

from :: With v a -> Rep (With v a) x #

to :: Rep (With v a) x -> With v a #

HasIndents (With ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (With [] a) (Indents a) Source #

type Rep (With v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

mkWith :: NonEmpty (Raw WithItem) -> [Raw Line] -> Raw With Source #

Create a minimal valid With

class AsWithItem s where Source #

Instances
AsWithItem Expr Source # 
Instance details

Defined in Language.Python.DSL

AsWithItem WithItem Source # 
Instance details

Defined in Language.Python.DSL

data WithItem (v :: [*]) a Source #

Constructors

WithItem 

Fields

Instances
Validated WithItem Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

unvalidated :: Getter (WithItem v a) (WithItem [] a) Source #

HasExprs WithItem Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

_Exprs :: Traversal (WithItem v a) (WithItem [] a) (Expr v a) (Expr [] a) Source #

HasIdents WithItem Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (WithItem v a) (WithItem [] a) (Ident v a) (Ident [] a) Source #

AsWithItem WithItem Source # 
Instance details

Defined in Language.Python.DSL

As Expr Expr WithItem Source #

See with_

Instance details

Defined in Language.Python.DSL

Methods

as_ :: Raw Expr -> Raw Expr -> Raw WithItem Source #

Functor (WithItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

fmap :: (a -> b) -> WithItem v a -> WithItem v b #

(<$) :: a -> WithItem v b -> WithItem v a #

Foldable (WithItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

fold :: Monoid m => WithItem v m -> m #

foldMap :: Monoid m => (a -> m) -> WithItem v a -> m #

foldr :: (a -> b -> b) -> b -> WithItem v a -> b #

foldr' :: (a -> b -> b) -> b -> WithItem v a -> b #

foldl :: (b -> a -> b) -> b -> WithItem v a -> b #

foldl' :: (b -> a -> b) -> b -> WithItem v a -> b #

foldr1 :: (a -> a -> a) -> WithItem v a -> a #

foldl1 :: (a -> a -> a) -> WithItem v a -> a #

toList :: WithItem v a -> [a] #

null :: WithItem v a -> Bool #

length :: WithItem v a -> Int #

elem :: Eq a => a -> WithItem v a -> Bool #

maximum :: Ord a => WithItem v a -> a #

minimum :: Ord a => WithItem v a -> a #

sum :: Num a => WithItem v a -> a #

product :: Num a => WithItem v a -> a #

Traversable (WithItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

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

sequenceA :: Applicative f => WithItem v (f a) -> f (WithItem v a) #

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

sequence :: Monad m => WithItem v (m a) -> m (WithItem v a) #

HasAnn (WithItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

annot :: Lens' (WithItem v a) (Ann a) Source #

Eq a => Eq (WithItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

(==) :: WithItem v a -> WithItem v a -> Bool #

(/=) :: WithItem v a -> WithItem v a -> Bool #

Show a => Show (WithItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Methods

showsPrec :: Int -> WithItem v a -> ShowS #

show :: WithItem v a -> String #

showList :: [WithItem v a] -> ShowS #

Generic (WithItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

Associated Types

type Rep (WithItem v a) :: Type -> Type #

Methods

from :: WithItem v a -> Rep (WithItem v a) x #

to :: Rep (WithItem v a) x -> WithItem v a #

HasNewlines (WithItem v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (WithItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Statement

type Rep (WithItem v a) = D1 (MetaData "WithItem" "Language.Python.Syntax.Statement" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "WithItem" PrefixI True) (S1 (MetaSel (Just "_withItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_withItemValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)) :*: S1 (MetaSel (Just "_withItemBinder") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe ([Whitespace], Expr v a))))))

Lenses

withAnn :: forall v a. Lens' (With v a) (Ann a) Source #

withIndents :: forall v a. Lens' (With v a) (Indents a) Source #

withAsync :: forall v a. Lens' (With v a) (Maybe (NonEmpty Whitespace)) Source #

withWith :: forall v a. Lens' (With v a) [Whitespace] Source #

withItems :: forall v a. Lens' (With v a) (CommaSep1 (WithItem v a)) Source #

withBody :: forall v a. Lens' (With v a) (Suite v a) Source #

Flow control

Else clauses

If, While, For, and TryExcept statements can have an Else component.

else_ is considered to be a modifier on these structures.

---

If ... Else:

>>> if_ false_ [line_ pass_] & else_ [line_ pass_]
if False:
    pass
else:
    pass

---

While ... Else:

>>> while_ false_ [line_ pass_] & else_ [line_ pass_]
while False:
    pass
else:
    pass

---

For ... Else:

>>> for_ (var_ "a" `in_` [var_ b]) [line_ pass_] & else_ [line_ pass_]
for a in b:
    pass
else:
    pass

---

TryExcept ... Else:

>>> tryE_ [line_ pass_] & except_ [line_ pass_] & else_ [line_ pass_]
try:
    pass
except:
    pass
else:
    pass

else_ :: ElseSyntax s => [Raw Line] -> Raw s -> Raw s Source #

class ElseSyntax s where Source #

Methods

getElse :: Raw s -> Maybe (Raw Else) Source #

setElse :: [Whitespace] -> Maybe (Raw Else) -> Raw s -> Raw s Source #

Instances
ElseSyntax While Source # 
Instance details

Defined in Language.Python.DSL

ElseSyntax If Source # 
Instance details

Defined in Language.Python.DSL

ElseSyntax For Source # 
Instance details

Defined in Language.Python.DSL

ElseSyntax TryExcept Source # 
Instance details

Defined in Language.Python.DSL

Break

For loops

For loops are built using for_ syntax:

>>> for_ (var_ "a" `in_` [1, 2, 3]) [line_ (call_ "print" [var_ "a"])]
for a in 1, 2, 3:
    print(a)

See also: ForSyntax

data For v a Source #

Instances
HasFor For Source # 
Instance details

Defined in Language.Python.Optics

Methods

_For :: Prism (For v a) (For [] a) (For v a) (For [] a) Source #

AsyncSyntax For Source # 
Instance details

Defined in Language.Python.DSL

Methods

async_ :: Raw For -> Raw For Source #

ElseSyntax For Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax For Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw For -> f (Raw For) Source #

body :: Lens' (Raw For) (Raw Suite) Source #

AsLine For Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw For -> Raw Line Source #

Functor (For v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> For v a -> For v b #

(<$) :: a -> For v b -> For v a #

Foldable (For v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => For v m -> m #

foldMap :: Monoid m => (a -> m) -> For v a -> m #

foldr :: (a -> b -> b) -> b -> For v a -> b #

foldr' :: (a -> b -> b) -> b -> For v a -> b #

foldl :: (b -> a -> b) -> b -> For v a -> b #

foldl' :: (b -> a -> b) -> b -> For v a -> b #

foldr1 :: (a -> a -> a) -> For v a -> a #

foldl1 :: (a -> a -> a) -> For v a -> a #

toList :: For v a -> [a] #

null :: For v a -> Bool #

length :: For v a -> Int #

elem :: Eq a => a -> For v a -> Bool #

maximum :: Ord a => For v a -> a #

minimum :: Ord a => For v a -> a #

sum :: Num a => For v a -> a #

product :: Num a => For v a -> a #

Traversable (For v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => For v (f a) -> f (For v a) #

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

sequence :: Monad m => For v (m a) -> m (For v a) #

HasAnn (For v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (For v a) (Ann a) Source #

Eq a => Eq (For v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: For v a -> For v a -> Bool #

(/=) :: For v a -> For v a -> Bool #

Show a => Show (For v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> For v a -> ShowS #

show :: For v a -> String #

showList :: [For v a] -> ShowS #

Generic (For v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (For v a) :: Type -> Type #

Methods

from :: For v a -> Rep (For v a) x #

to :: Rep (For v a) x -> For v a #

HasIndents (For ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (For [] a) (Indents a) Source #

type Rep (For v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

_For :: HasFor s => Prism (s v a) (s '[] a) (For v a) (For '[] a) Source #

mkFor :: Raw Expr -> [Raw Expr] -> [Raw Line] -> Raw For Source #

If statements

elif_ :: Raw Expr -> [Raw Line] -> Raw If -> Raw If Source #

data If v a Source #

Constructors

MkIf 

Fields

Instances
HasIf If Source # 
Instance details

Defined in Language.Python.Optics

Methods

_If :: Prism (If v a) (If [] a) (If v a) (If [] a) Source #

ElseSyntax If Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax If Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw If -> f (Raw If) Source #

body :: Lens' (Raw If) (Raw Suite) Source #

AsLine If Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw If -> Raw Line Source #

Functor (If v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> If v a -> If v b #

(<$) :: a -> If v b -> If v a #

Foldable (If v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => If v m -> m #

foldMap :: Monoid m => (a -> m) -> If v a -> m #

foldr :: (a -> b -> b) -> b -> If v a -> b #

foldr' :: (a -> b -> b) -> b -> If v a -> b #

foldl :: (b -> a -> b) -> b -> If v a -> b #

foldl' :: (b -> a -> b) -> b -> If v a -> b #

foldr1 :: (a -> a -> a) -> If v a -> a #

foldl1 :: (a -> a -> a) -> If v a -> a #

toList :: If v a -> [a] #

null :: If v a -> Bool #

length :: If v a -> Int #

elem :: Eq a => a -> If v a -> Bool #

maximum :: Ord a => If v a -> a #

minimum :: Ord a => If v a -> a #

sum :: Num a => If v a -> a #

product :: Num a => If v a -> a #

Traversable (If v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => If v (f a) -> f (If v a) #

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

sequence :: Monad m => If v (m a) -> m (If v a) #

HasAnn (If v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (If v a) (Ann a) Source #

Eq a => Eq (If v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: If v a -> If v a -> Bool #

(/=) :: If v a -> If v a -> Bool #

Show a => Show (If v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> If v a -> ShowS #

show :: If v a -> String #

showList :: [If v a] -> ShowS #

Generic (If v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (If v a) :: Type -> Type #

Methods

from :: If v a -> Rep (If v a) x #

to :: Rep (If v a) x -> If v a #

HasIndents (If ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (If [] a) (Indents a) Source #

type Rep (If v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

mkIf :: Raw Expr -> [Raw Line] -> Raw If Source #

Create a minimal valid If

data Elif v a Source #

Constructors

MkElif 
Instances
BodySyntax Elif Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw Elif -> f (Raw Elif) Source #

body :: Lens' (Raw Elif) (Raw Suite) Source #

Functor (Elif v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> Elif v a -> Elif v b #

(<$) :: a -> Elif v b -> Elif v a #

Foldable (Elif v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => Elif v m -> m #

foldMap :: Monoid m => (a -> m) -> Elif v a -> m #

foldr :: (a -> b -> b) -> b -> Elif v a -> b #

foldr' :: (a -> b -> b) -> b -> Elif v a -> b #

foldl :: (b -> a -> b) -> b -> Elif v a -> b #

foldl' :: (b -> a -> b) -> b -> Elif v a -> b #

foldr1 :: (a -> a -> a) -> Elif v a -> a #

foldl1 :: (a -> a -> a) -> Elif v a -> a #

toList :: Elif v a -> [a] #

null :: Elif v a -> Bool #

length :: Elif v a -> Int #

elem :: Eq a => a -> Elif v a -> Bool #

maximum :: Ord a => Elif v a -> a #

minimum :: Ord a => Elif v a -> a #

sum :: Num a => Elif v a -> a #

product :: Num a => Elif v a -> a #

Traversable (Elif v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => Elif v (f a) -> f (Elif v a) #

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

sequence :: Monad m => Elif v (m a) -> m (Elif v a) #

Eq a => Eq (Elif v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: Elif v a -> Elif v a -> Bool #

(/=) :: Elif v a -> Elif v a -> Bool #

Show a => Show (Elif v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> Elif v a -> ShowS #

show :: Elif v a -> String #

showList :: [Elif v a] -> ShowS #

Generic (Elif v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (Elif v a) :: Type -> Type #

Methods

from :: Elif v a -> Rep (Elif v a) x #

to :: Rep (Elif v a) x -> Elif v a #

HasIndents (Elif ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (Elif [] a) (Indents a) Source #

type Rep (Elif v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (Elif v a) = D1 (MetaData "Elif" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkElif" PrefixI True) ((S1 (MetaSel (Just "_elifIndents") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Indents a)) :*: S1 (MetaSel (Just "_elifElif") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])) :*: (S1 (MetaSel (Just "_elifCond") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)) :*: S1 (MetaSel (Just "_elifBody") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Suite v a)))))

mkElif :: Raw Expr -> [Raw Line] -> Raw Elif Source #

Create a minimal valid Elif

data Else v a Source #

Constructors

MkElse 
Instances
BodySyntax Else Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw Else -> f (Raw Else) Source #

body :: Lens' (Raw Else) (Raw Suite) Source #

Functor (Else v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> Else v a -> Else v b #

(<$) :: a -> Else v b -> Else v a #

Foldable (Else v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => Else v m -> m #

foldMap :: Monoid m => (a -> m) -> Else v a -> m #

foldr :: (a -> b -> b) -> b -> Else v a -> b #

foldr' :: (a -> b -> b) -> b -> Else v a -> b #

foldl :: (b -> a -> b) -> b -> Else v a -> b #

foldl' :: (b -> a -> b) -> b -> Else v a -> b #

foldr1 :: (a -> a -> a) -> Else v a -> a #

foldl1 :: (a -> a -> a) -> Else v a -> a #

toList :: Else v a -> [a] #

null :: Else v a -> Bool #

length :: Else v a -> Int #

elem :: Eq a => a -> Else v a -> Bool #

maximum :: Ord a => Else v a -> a #

minimum :: Ord a => Else v a -> a #

sum :: Num a => Else v a -> a #

product :: Num a => Else v a -> a #

Traversable (Else v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => Else v (f a) -> f (Else v a) #

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

sequence :: Monad m => Else v (m a) -> m (Else v a) #

Eq a => Eq (Else v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: Else v a -> Else v a -> Bool #

(/=) :: Else v a -> Else v a -> Bool #

Show a => Show (Else v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> Else v a -> ShowS #

show :: Else v a -> String #

showList :: [Else v a] -> ShowS #

Generic (Else v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (Else v a) :: Type -> Type #

Methods

from :: Else v a -> Rep (Else v a) x #

to :: Rep (Else v a) x -> Else v a #

HasIndents (Else ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (Else [] a) (Indents a) Source #

type Rep (Else v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (Else v a) = D1 (MetaData "Else" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkElse" PrefixI True) (S1 (MetaSel (Just "_elseIndents") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Indents a)) :*: (S1 (MetaSel (Just "_elseElse") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_elseBody") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Suite v a)))))

mkElse :: [Raw Line] -> Raw Else Source #

Create a minimal valid Else

Lenses

ifAnn :: forall v a. Lens' (If v a) (Ann a) Source #

ifIndents :: forall v a. Lens' (If v a) (Indents a) Source #

ifIf :: forall v a. Lens' (If v a) [Whitespace] Source #

ifCond :: forall v a. Lens' (If v a) (Expr v a) Source #

ifBody :: forall v a. Lens' (If v a) (Suite v a) Source #

ifElifs :: forall v a. Lens' (If v a) [Elif v a] Source #

ifElse :: forall v a. Lens' (If v a) (Maybe (Else v a)) Source #

elifIndents :: forall v a. Lens' (Elif v a) (Indents a) Source #

elifElif :: forall v a. Lens' (Elif v a) [Whitespace] Source #

elifCond :: forall v a. Lens' (Elif v a) (Expr v a) Source #

elifBody :: forall v a. Lens' (Elif v a) (Suite v a) Source #

elseIndents :: forall v a. Lens' (Else v a) (Indents a) Source #

elseElse :: forall v a. Lens' (Else v a) [Whitespace] Source #

elseBody :: forall v a v. Lens (Else v a) (Else v a) (Suite v a) (Suite v a) Source #

Pass

pass_ :: Raw Statement Source #

>>> pass_
pass

Return

return_ :: Raw Expr -> Raw Statement Source #

>>> return_ (var_ "a")
return a

While loops

data While v a Source #

Constructors

MkWhile 
Instances
HasWhile While Source # 
Instance details

Defined in Language.Python.Optics

Methods

_While :: Prism (While v a) (While [] a) (While v a) (While [] a) Source #

ElseSyntax While Source # 
Instance details

Defined in Language.Python.DSL

BodySyntax While Source # 
Instance details

Defined in Language.Python.DSL

Methods

body_ :: Functor f => ([Raw Line] -> f [Raw Line]) -> Raw While -> f (Raw While) Source #

body :: Lens' (Raw While) (Raw Suite) Source #

AsLine While Source # 
Instance details

Defined in Language.Python.DSL

Methods

line_ :: Raw While -> Raw Line Source #

Functor (While v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> While v a -> While v b #

(<$) :: a -> While v b -> While v a #

Foldable (While v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => While v m -> m #

foldMap :: Monoid m => (a -> m) -> While v a -> m #

foldr :: (a -> b -> b) -> b -> While v a -> b #

foldr' :: (a -> b -> b) -> b -> While v a -> b #

foldl :: (b -> a -> b) -> b -> While v a -> b #

foldl' :: (b -> a -> b) -> b -> While v a -> b #

foldr1 :: (a -> a -> a) -> While v a -> a #

foldl1 :: (a -> a -> a) -> While v a -> a #

toList :: While v a -> [a] #

null :: While v a -> Bool #

length :: While v a -> Int #

elem :: Eq a => a -> While v a -> Bool #

maximum :: Ord a => While v a -> a #

minimum :: Ord a => While v a -> a #

sum :: Num a => While v a -> a #

product :: Num a => While v a -> a #

Traversable (While v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => While v (f a) -> f (While v a) #

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

sequence :: Monad m => While v (m a) -> m (While v a) #

HasAnn (While v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (While v a) (Ann a) Source #

Eq a => Eq (While v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: While v a -> While v a -> Bool #

(/=) :: While v a -> While v a -> Bool #

Show a => Show (While v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> While v a -> ShowS #

show :: While v a -> String #

showList :: [While v a] -> ShowS #

Generic (While v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (While v a) :: Type -> Type #

Methods

from :: While v a -> Rep (While v a) x #

to :: Rep (While v a) x -> While v a #

HasIndents (While ([] :: [Type]) a) a Source # 
Instance details

Defined in Language.Python.Optics.Indents

Methods

_Indents :: Traversal' (While [] a) (Indents a) Source #

type Rep (While v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

mkWhile :: Raw Expr -> [Raw Line] -> Raw While Source #

Create a minimal valid While

Lenses

whileAnn :: forall v a. Lens' (While v a) (Ann a) Source #

whileIndents :: forall v a. Lens' (While v a) (Indents a) Source #

whileWhile :: forall v a. Lens' (While v a) [Whitespace] Source #

whileCond :: forall v a. Lens' (While v a) (Expr v a) Source #

whileBody :: forall v a. Lens' (While v a) (Suite v a) Source #

Expressions

expr_ :: Raw Expr -> Raw Statement Source #

Turns an SimpleStatement into a Statement

>>> expr_ (int_ 3)
3

await

await_ :: Raw Expr -> Raw Expr Source #

>>> await (var_ "a")
await a

... if ... else ...

ifThenElse_ :: Raw Expr -> Raw Expr -> Raw Expr -> Raw Expr Source #

>>> ifThenElse_ (var_ "a") (var_ "b") (var_ "c")
a if b else c

Generators

gen_ :: Raw (Comprehension Expr) -> Raw Expr Source #

>>> gen_ $ comp_ (var_ "a") (for_ $ var_ "a" `in_` list_ [li_ $ int_ 1, li_ $ int_ 2, li_ $ int_ 3]) [if_ $ var_ "a" .== 2]
(a for a in [1, 2, 3] if a == 2)

yield

yield_ :: [Raw Expr] -> Raw Expr Source #

>>> yield_ []
yield
>>> yield_ [var_ "a"]
yield a
>>> yield_ [var_ "a", var_ "b"]
yield a, b

yield from ...

yieldFrom_ :: Raw Expr -> Raw Expr Source #

>>> yieldFrom_ (var_ "a")
yield from a

Tuples

tuple_ :: [Raw TupleItem] -> Raw Expr Source #

>>> tuple_ []
()
>>> tuple_ [ti_ $ var_ "a"]
a,
>>> tuple_ [s_ $ var_ "a"]
(*a),
>>> tuple_ [ti_ $ var_ "a", ti_ $ var_ "b"]
a, b
>>> tuple_ [ti_ $ var_ "a", s_ $ var_ "b"]
a, *b

data Tuple v a Source #

Constructors

MkTuple 
Instances
Functor (Tuple v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> Tuple v a -> Tuple v b #

(<$) :: a -> Tuple v b -> Tuple v a #

Foldable (Tuple v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => Tuple v m -> m #

foldMap :: Monoid m => (a -> m) -> Tuple v a -> m #

foldr :: (a -> b -> b) -> b -> Tuple v a -> b #

foldr' :: (a -> b -> b) -> b -> Tuple v a -> b #

foldl :: (b -> a -> b) -> b -> Tuple v a -> b #

foldl' :: (b -> a -> b) -> b -> Tuple v a -> b #

foldr1 :: (a -> a -> a) -> Tuple v a -> a #

foldl1 :: (a -> a -> a) -> Tuple v a -> a #

toList :: Tuple v a -> [a] #

null :: Tuple v a -> Bool #

length :: Tuple v a -> Int #

elem :: Eq a => a -> Tuple v a -> Bool #

maximum :: Ord a => Tuple v a -> a #

minimum :: Ord a => Tuple v a -> a #

sum :: Num a => Tuple v a -> a #

product :: Num a => Tuple v a -> a #

Traversable (Tuple v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => Tuple v (f a) -> f (Tuple v a) #

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

sequence :: Monad m => Tuple v (m a) -> m (Tuple v a) #

HasAnn (Tuple v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (Tuple v a) (Ann a) Source #

Eq a => Eq (Tuple v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: Tuple v a -> Tuple v a -> Bool #

(/=) :: Tuple v a -> Tuple v a -> Bool #

Show a => Show (Tuple v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> Tuple v a -> ShowS #

show :: Tuple v a -> String #

showList :: [Tuple v a] -> ShowS #

Generic (Tuple v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (Tuple v a) :: Type -> Type #

Methods

from :: Tuple v a -> Rep (Tuple v a) x #

to :: Rep (Tuple v a) x -> Tuple v a #

type Rep (Tuple v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (Tuple v a) = D1 (MetaData "Tuple" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkTuple" PrefixI True) ((S1 (MetaSel (Just "_tupleAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_tupleHead") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (TupleItem v a))) :*: (S1 (MetaSel (Just "_tupleComma") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Comma) :*: S1 (MetaSel (Just "_tupleTail") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (CommaSep1' (TupleItem v a)))))))

class AsTupleItem e where Source #

Methods

ti_ :: Raw e -> Raw TupleItem Source #

Create a TupleItem

Instances
AsTupleItem Expr Source # 
Instance details

Defined in Language.Python.DSL

AsTupleItem TupleItem Source # 
Instance details

Defined in Language.Python.DSL

data TupleItem (v :: [*]) a Source #

a or *a

Used to construct tuples, e.g. (1, x, **c)

Instances
Validated TupleItem Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

unvalidated :: Getter (TupleItem v a) (TupleItem [] a) Source #

HasExprs TupleItem Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

_Exprs :: Traversal (TupleItem v a) (TupleItem [] a) (Expr v a) (Expr [] a) Source #

HasIdents TupleItem Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (TupleItem v a) (TupleItem [] a) (Ident v a) (Ident [] a) Source #

AsTupleItem TupleItem Source # 
Instance details

Defined in Language.Python.DSL

StarSyntax Expr TupleItem Source #

See tuple_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw TupleItem Source #

Functor (TupleItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fmap :: (a -> b) -> TupleItem v a -> TupleItem v b #

(<$) :: a -> TupleItem v b -> TupleItem v a #

Foldable (TupleItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fold :: Monoid m => TupleItem v m -> m #

foldMap :: Monoid m => (a -> m) -> TupleItem v a -> m #

foldr :: (a -> b -> b) -> b -> TupleItem v a -> b #

foldr' :: (a -> b -> b) -> b -> TupleItem v a -> b #

foldl :: (b -> a -> b) -> b -> TupleItem v a -> b #

foldl' :: (b -> a -> b) -> b -> TupleItem v a -> b #

foldr1 :: (a -> a -> a) -> TupleItem v a -> a #

foldl1 :: (a -> a -> a) -> TupleItem v a -> a #

toList :: TupleItem v a -> [a] #

null :: TupleItem v a -> Bool #

length :: TupleItem v a -> Int #

elem :: Eq a => a -> TupleItem v a -> Bool #

maximum :: Ord a => TupleItem v a -> a #

minimum :: Ord a => TupleItem v a -> a #

sum :: Num a => TupleItem v a -> a #

product :: Num a => TupleItem v a -> a #

Traversable (TupleItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

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

sequenceA :: Applicative f => TupleItem v (f a) -> f (TupleItem v a) #

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

sequence :: Monad m => TupleItem v (m a) -> m (TupleItem v a) #

HasAnn (TupleItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

annot :: Lens' (TupleItem v a) (Ann a) Source #

Eq a => Eq (TupleItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(==) :: TupleItem v a -> TupleItem v a -> Bool #

(/=) :: TupleItem v a -> TupleItem v a -> Bool #

Show a => Show (TupleItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

showsPrec :: Int -> TupleItem v a -> ShowS #

show :: TupleItem v a -> String #

showList :: [TupleItem v a] -> ShowS #

Generic (TupleItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Associated Types

type Rep (TupleItem v a) :: Type -> Type #

Methods

from :: TupleItem v a -> Rep (TupleItem v a) x #

to :: Rep (TupleItem v a) x -> TupleItem v a #

HasTrailingWhitespace (TupleItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

HasNewlines (TupleItem v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (TupleItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

type Rep (TupleItem v a) = D1 (MetaData "TupleItem" "Language.Python.Syntax.Expr" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "TupleItem" PrefixI True) (S1 (MetaSel (Just "_tupleItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeTupleItemValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :+: C1 (MetaCons "TupleUnpack" PrefixI True) ((S1 (MetaSel (Just "_tupleItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeTupleUnpackParens") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [([Whitespace], [Whitespace])])) :*: (S1 (MetaSel (Just "_unsafeTupleUnpackWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeTupleUnpackValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))

Function calls

call_ :: Raw Expr -> [Raw Arg] -> Raw Expr Source #

>>> call_ "f" [p_ $ var_ "x"]
f(x)
>>> call_ "f" [p_ $ var_ "x", k_ "y" 2]
f(x, y=2)
>>> call_ "f" [p_ $ var_ "x", k_ "y" 2, s_ "z"]
f(x, y=2, *z)
>>> call_ "f" [p_ $ var_ "x", k_ "y" 2, s_ "z", ss_ "w"]
f(x, y=2, *z, **w)

data Call v a Source #

Instances
ArgumentsSyntax Call Source # 
Instance details

Defined in Language.Python.DSL

Functor (Call v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> Call v a -> Call v b #

(<$) :: a -> Call v b -> Call v a #

Foldable (Call v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => Call v m -> m #

foldMap :: Monoid m => (a -> m) -> Call v a -> m #

foldr :: (a -> b -> b) -> b -> Call v a -> b #

foldr' :: (a -> b -> b) -> b -> Call v a -> b #

foldl :: (b -> a -> b) -> b -> Call v a -> b #

foldl' :: (b -> a -> b) -> b -> Call v a -> b #

foldr1 :: (a -> a -> a) -> Call v a -> a #

foldl1 :: (a -> a -> a) -> Call v a -> a #

toList :: Call v a -> [a] #

null :: Call v a -> Bool #

length :: Call v a -> Int #

elem :: Eq a => a -> Call v a -> Bool #

maximum :: Ord a => Call v a -> a #

minimum :: Ord a => Call v a -> a #

sum :: Num a => Call v a -> a #

product :: Num a => Call v a -> a #

Traversable (Call v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => Call v (f a) -> f (Call v a) #

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

sequence :: Monad m => Call v (m a) -> m (Call v a) #

HasAnn (Call v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (Call v a) (Ann a) Source #

Eq a => Eq (Call v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: Call v a -> Call v a -> Bool #

(/=) :: Call v a -> Call v a -> Bool #

Show a => Show (Call v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> Call v a -> ShowS #

show :: Call v a -> String #

showList :: [Call v a] -> ShowS #

Generic (Call v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (Call v a) :: Type -> Type #

Methods

from :: Call v a -> Rep (Call v a) x #

to :: Rep (Call v a) x -> Call v a #

type Rep (Call v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (Call v a) = D1 (MetaData "Call" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkCall" PrefixI True) ((S1 (MetaSel (Just "_callAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_callFunction") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :*: (S1 (MetaSel (Just "_callLeftParen") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: (S1 (MetaSel (Just "_callArguments") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (CommaSep1' (Arg v a)))) :*: S1 (MetaSel (Just "_callRightParen") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))))

mkCall :: Raw Expr -> Raw Call Source #

Create a minimal valid Call

Lenses

callAnn :: forall v a. Lens' (Call v a) (Ann a) Source #

callFunction :: forall v a. Lens' (Call v a) (Expr v a) Source #

callLeftParen :: forall v a. Lens' (Call v a) [Whitespace] Source #

callArguments :: forall v a. Lens' (Call v a) (Maybe (CommaSep1' (Arg v a))) Source #

callRightParen :: forall v a. Lens' (Call v a) [Whitespace] Source #

Literals

None

none_ :: Raw Expr Source #

>>> none_
None

data None (v :: [*]) a Source #

Constructors

MkNone 
Instances
Functor (None v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fmap :: (a -> b) -> None v a -> None v b #

(<$) :: a -> None v b -> None v a #

Foldable (None v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

fold :: Monoid m => None v m -> m #

foldMap :: Monoid m => (a -> m) -> None v a -> m #

foldr :: (a -> b -> b) -> b -> None v a -> b #

foldr' :: (a -> b -> b) -> b -> None v a -> b #

foldl :: (b -> a -> b) -> b -> None v a -> b #

foldl' :: (b -> a -> b) -> b -> None v a -> b #

foldr1 :: (a -> a -> a) -> None v a -> a #

foldl1 :: (a -> a -> a) -> None v a -> a #

toList :: None v a -> [a] #

null :: None v a -> Bool #

length :: None v a -> Int #

elem :: Eq a => a -> None v a -> Bool #

maximum :: Ord a => None v a -> a #

minimum :: Ord a => None v a -> a #

sum :: Num a => None v a -> a #

product :: Num a => None v a -> a #

Traversable (None v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

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

sequenceA :: Applicative f => None v (f a) -> f (None v a) #

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

sequence :: Monad m => None v (m a) -> m (None v a) #

HasAnn (None v) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

annot :: Lens' (None v a) (Ann a) Source #

Eq a => Eq (None v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

(==) :: None v a -> None v a -> Bool #

(/=) :: None v a -> None v a -> Bool #

Show a => Show (None v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Methods

showsPrec :: Int -> None v a -> ShowS #

show :: None v a -> String #

showList :: [None v a] -> ShowS #

Generic (None v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

Associated Types

type Rep (None v a) :: Type -> Type #

Methods

from :: None v a -> Rep (None v a) x #

to :: Rep (None v a) x -> None v a #

type Rep (None v a) Source # 
Instance details

Defined in Language.Python.Syntax.Types

type Rep (None v a) = D1 (MetaData "None" "Language.Python.Syntax.Types" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "MkNone" PrefixI True) (S1 (MetaSel (Just "_noneAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_noneWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace])))

_None :: Prism (Expr v a) (Expr '[] a) (None v a) (None '[] a) Source #

Lenses

noneAnn :: forall v a v a. Lens (None v a) (None v a) (Ann a) (Ann a) Source #

noneWhitespace :: forall v a v. Lens (None v a) (None v a) [Whitespace] [Whitespace] Source #

Strings

str_ :: String -> Raw Expr Source #

Double-quoted string

>>> str_ "asdf"
"asdf"

str'_ :: String -> Raw Expr Source #

Single-quoted string

>>> str_ "asdf"
'asdf'

longStr_ :: String -> Raw Expr Source #

Long double-quoted string

>>> longStr_ "asdf"
"""asdf"""

longStr'_ :: String -> Raw Expr Source #

Long single-quoted string

>>> longStr'_ "asdf"
'''asdf'''

Integers

int_ :: Integer -> Raw Expr Source #

Raw SimpleStatement has a Num instance, but sometimes we need to name integers explicitly

>>> int_ 10
10

Booleans

true_ :: Raw Expr Source #

>>> true_
True

false_ :: Raw Expr Source #

>>> false_
False

Ellipses

ellipsis_ :: Raw Expr Source #

>>> ellipsis_
...

Lists

class AsList s where Source #

>>> list_ [li_ $ var_ "a"]
[a]
>>> list_ [s_ $ var_ "a"]
[*a]
>>> list_ [li_ $ var_ "a", s_ $ var_ "b"]
[a, *b]
>>> list_ $ comp_ (var_ "a") (for_ $ var_ "a" `in_` list_ [li_ $ int_ 1, li_ $ int_ 2, li_ $ int_ 3]) [if_ $ var_ "a" .== 2]
[a for a in [1, 2, 3] if a == 2]

Methods

list_ :: s -> Raw Expr Source #

Instances
e ~ Raw ListItem => AsList [e] Source # 
Instance details

Defined in Language.Python.DSL

Methods

list_ :: [e] -> Raw Expr Source #

e ~ Comprehension Expr => AsList (Raw e) Source # 
Instance details

Defined in Language.Python.DSL

Methods

list_ :: Raw e -> Raw Expr Source #

class AsListItem s where Source #

Methods

li_ :: Raw s -> Raw ListItem Source #

Create a ListItem

Instances
AsListItem Expr Source # 
Instance details

Defined in Language.Python.DSL

Methods

li_ :: Raw Expr -> Raw ListItem Source #

AsListItem ListItem Source # 
Instance details

Defined in Language.Python.DSL

data ListItem (v :: [*]) a Source #

a or *a

Used to construct lists, e.g. [ 1, x, **c ]

https://docs.python.org/3/reference/expressions.html#list-displays

Instances
Validated ListItem Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

unvalidated :: Getter (ListItem v a) (ListItem [] a) Source #

HasExprs ListItem Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

_Exprs :: Traversal (ListItem v a) (ListItem [] a) (Expr v a) (Expr [] a) Source #

HasIdents ListItem Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (ListItem v a) (ListItem [] a) (Ident v a) (Ident [] a) Source #

AsListItem ListItem Source # 
Instance details

Defined in Language.Python.DSL

StarSyntax Expr ListItem Source #

See list_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw ListItem Source #

Functor (ListItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fmap :: (a -> b) -> ListItem v a -> ListItem v b #

(<$) :: a -> ListItem v b -> ListItem v a #

Foldable (ListItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fold :: Monoid m => ListItem v m -> m #

foldMap :: Monoid m => (a -> m) -> ListItem v a -> m #

foldr :: (a -> b -> b) -> b -> ListItem v a -> b #

foldr' :: (a -> b -> b) -> b -> ListItem v a -> b #

foldl :: (b -> a -> b) -> b -> ListItem v a -> b #

foldl' :: (b -> a -> b) -> b -> ListItem v a -> b #

foldr1 :: (a -> a -> a) -> ListItem v a -> a #

foldl1 :: (a -> a -> a) -> ListItem v a -> a #

toList :: ListItem v a -> [a] #

null :: ListItem v a -> Bool #

length :: ListItem v a -> Int #

elem :: Eq a => a -> ListItem v a -> Bool #

maximum :: Ord a => ListItem v a -> a #

minimum :: Ord a => ListItem v a -> a #

sum :: Num a => ListItem v a -> a #

product :: Num a => ListItem v a -> a #

Traversable (ListItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

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

sequenceA :: Applicative f => ListItem v (f a) -> f (ListItem v a) #

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

sequence :: Monad m => ListItem v (m a) -> m (ListItem v a) #

HasAnn (ListItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

annot :: Lens' (ListItem v a) (Ann a) Source #

Eq a => Eq (ListItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(==) :: ListItem v a -> ListItem v a -> Bool #

(/=) :: ListItem v a -> ListItem v a -> Bool #

Show a => Show (ListItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

showsPrec :: Int -> ListItem v a -> ShowS #

show :: ListItem v a -> String #

showList :: [ListItem v a] -> ShowS #

Generic (ListItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Associated Types

type Rep (ListItem v a) :: Type -> Type #

Methods

from :: ListItem v a -> Rep (ListItem v a) x #

to :: Rep (ListItem v a) x -> ListItem v a #

HasTrailingWhitespace (ListItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

HasNewlines (ListItem v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (ListItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

type Rep (ListItem v a) = D1 (MetaData "ListItem" "Language.Python.Syntax.Expr" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "ListItem" PrefixI True) (S1 (MetaSel (Just "_listItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeListItemValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :+: C1 (MetaCons "ListUnpack" PrefixI True) ((S1 (MetaSel (Just "_listItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeListUnpackParens") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [([Whitespace], [Whitespace])])) :*: (S1 (MetaSel (Just "_unsafeListUnpackWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeListUnpackValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))

Dictionaries

class AsDict s where Source #

>>> dict_ [var_ "a" .: 1]
{a: 1}
>>> dict_ [ss_ $ var_ "a"]
{**a}
>>> dict_ [var_ "a" .: 1, ss_ $ var_ "b"]
{a: 1, **b}
>>> dict_ $ comp_ (var_ "a" .: 1) (for_ $ var_ "a" `in_` list_ [li_ $ int_ 1, li_ $ int_ 2, li_ $ int_ 3]) [if_ $ var_ "a" .== 2]
{a: 1 for a in [1, 2, 3] if a == 2}

Methods

dict_ :: s -> Raw Expr Source #

Instances
e ~ Raw DictItem => AsDict [e] Source #
dict_ :: [Raw DictItem] -> Raw SimpleStatement
Instance details

Defined in Language.Python.DSL

Methods

dict_ :: [e] -> Raw Expr Source #

e ~ Comprehension DictItem => AsDict (Raw e) Source #
dict_ :: Raw (Comprehension DictItem) -> Raw SimpleStatement
Instance details

Defined in Language.Python.DSL

Methods

dict_ :: Raw e -> Raw Expr Source #

data DictItem (v :: [*]) a Source #

a : b or **a

Used to construct dictionaries, e.g. { 1: a, 2: b, **c }

https://docs.python.org/3/reference/expressions.html#dictionary-displays

Instances
Validated DictItem Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

unvalidated :: Getter (DictItem v a) (DictItem [] a) Source #

HasIdents DictItem Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (DictItem v a) (DictItem [] a) (Ident v a) (Ident [] a) Source #

DoubleStarSyntax Expr DictItem Source #

See dict_

Instance details

Defined in Language.Python.DSL

Methods

ss_ :: Raw Expr -> Raw DictItem Source #

ColonSyntax Expr DictItem Source #

Constructing dictionary items

(.:) :: Raw SimpleStatement -> Raw SimpleStatement -> Raw DictItem
Instance details

Defined in Language.Python.DSL

Methods

(.:) :: Raw Expr -> Raw Expr -> Raw DictItem Source #

Functor (DictItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fmap :: (a -> b) -> DictItem v a -> DictItem v b #

(<$) :: a -> DictItem v b -> DictItem v a #

Foldable (DictItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fold :: Monoid m => DictItem v m -> m #

foldMap :: Monoid m => (a -> m) -> DictItem v a -> m #

foldr :: (a -> b -> b) -> b -> DictItem v a -> b #

foldr' :: (a -> b -> b) -> b -> DictItem v a -> b #

foldl :: (b -> a -> b) -> b -> DictItem v a -> b #

foldl' :: (b -> a -> b) -> b -> DictItem v a -> b #

foldr1 :: (a -> a -> a) -> DictItem v a -> a #

foldl1 :: (a -> a -> a) -> DictItem v a -> a #

toList :: DictItem v a -> [a] #

null :: DictItem v a -> Bool #

length :: DictItem v a -> Int #

elem :: Eq a => a -> DictItem v a -> Bool #

maximum :: Ord a => DictItem v a -> a #

minimum :: Ord a => DictItem v a -> a #

sum :: Num a => DictItem v a -> a #

product :: Num a => DictItem v a -> a #

Traversable (DictItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

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

sequenceA :: Applicative f => DictItem v (f a) -> f (DictItem v a) #

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

sequence :: Monad m => DictItem v (m a) -> m (DictItem v a) #

HasAnn (DictItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

annot :: Lens' (DictItem v a) (Ann a) Source #

Eq a => Eq (DictItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(==) :: DictItem v a -> DictItem v a -> Bool #

(/=) :: DictItem v a -> DictItem v a -> Bool #

Show a => Show (DictItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

showsPrec :: Int -> DictItem v a -> ShowS #

show :: DictItem v a -> String #

showList :: [DictItem v a] -> ShowS #

Generic (DictItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Associated Types

type Rep (DictItem v a) :: Type -> Type #

Methods

from :: DictItem v a -> Rep (DictItem v a) x #

to :: Rep (DictItem v a) x -> DictItem v a #

HasTrailingWhitespace (DictItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

HasNewlines (DictItem v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (DictItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

type Rep (DictItem v a) = D1 (MetaData "DictItem" "Language.Python.Syntax.Expr" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "DictItem" PrefixI True) ((S1 (MetaSel (Just "_dictItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeDictItemKey") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :*: (S1 (MetaSel (Just "_unsafeDictItemColon") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Colon) :*: S1 (MetaSel (Just "_unsafeDictItemValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))) :+: C1 (MetaCons "DictUnpack" PrefixI True) (S1 (MetaSel (Just "_dictItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: (S1 (MetaSel (Just "_unsafeDictItemUnpackWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeDictItemUnpackValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))

Sets

class AsSet s where Source #

>>> set_ []
set()
>>> set_ [si_ $ var_ "a"]
{a}
>>> set_ [s_ $ var_ "a"]
{*a}
>>> set_ [si_ $ var_ "a", s_ $ var_ "b"]
{a, *b}
>>> set_ $ comp_ (var_ "a") (for_ $ var_ "a" `in_` set_ [si_ $ int_ 1, si_ $ int_ 2, si_ $ int_ 3]) [if_ $ var_ "a" .== 2]
{a for a in [1, 2, 3] if a == 2}

Methods

set_ :: s -> Raw Expr Source #

Instances
e ~ Raw SetItem => AsSet [e] Source # 
Instance details

Defined in Language.Python.DSL

Methods

set_ :: [e] -> Raw Expr Source #

e ~ Comprehension SetItem => AsSet (Raw e) Source # 
Instance details

Defined in Language.Python.DSL

Methods

set_ :: Raw e -> Raw Expr Source #

class AsSetItem s where Source #

Methods

si_ :: Raw s -> Raw SetItem Source #

Create a SetItem

Instances
AsSetItem Expr Source # 
Instance details

Defined in Language.Python.DSL

Methods

si_ :: Raw Expr -> Raw SetItem Source #

AsSetItem SetItem Source # 
Instance details

Defined in Language.Python.DSL

data SetItem (v :: [*]) a Source #

a or *a

Used to construct sets, e.g. { 1, x, **c }

https://docs.python.org/3/reference/expressions.html#set-displays

Instances
Validated SetItem Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

unvalidated :: Getter (SetItem v a) (SetItem [] a) Source #

HasExprs SetItem Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

_Exprs :: Traversal (SetItem v a) (SetItem [] a) (Expr v a) (Expr [] a) Source #

HasIdents SetItem Source # 
Instance details

Defined in Language.Python.Optics.Idents

Methods

_Idents :: Traversal (SetItem v a) (SetItem [] a) (Ident v a) (Ident [] a) Source #

AsSetItem SetItem Source # 
Instance details

Defined in Language.Python.DSL

StarSyntax Expr SetItem Source #

See set_

Instance details

Defined in Language.Python.DSL

Methods

s_ :: Raw Expr -> Raw SetItem Source #

Functor (SetItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fmap :: (a -> b) -> SetItem v a -> SetItem v b #

(<$) :: a -> SetItem v b -> SetItem v a #

Foldable (SetItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

fold :: Monoid m => SetItem v m -> m #

foldMap :: Monoid m => (a -> m) -> SetItem v a -> m #

foldr :: (a -> b -> b) -> b -> SetItem v a -> b #

foldr' :: (a -> b -> b) -> b -> SetItem v a -> b #

foldl :: (b -> a -> b) -> b -> SetItem v a -> b #

foldl' :: (b -> a -> b) -> b -> SetItem v a -> b #

foldr1 :: (a -> a -> a) -> SetItem v a -> a #

foldl1 :: (a -> a -> a) -> SetItem v a -> a #

toList :: SetItem v a -> [a] #

null :: SetItem v a -> Bool #

length :: SetItem v a -> Int #

elem :: Eq a => a -> SetItem v a -> Bool #

maximum :: Ord a => SetItem v a -> a #

minimum :: Ord a => SetItem v a -> a #

sum :: Num a => SetItem v a -> a #

product :: Num a => SetItem v a -> a #

Traversable (SetItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

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

sequenceA :: Applicative f => SetItem v (f a) -> f (SetItem v a) #

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

sequence :: Monad m => SetItem v (m a) -> m (SetItem v a) #

HasAnn (SetItem v) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

annot :: Lens' (SetItem v a) (Ann a) Source #

Eq a => Eq (SetItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

(==) :: SetItem v a -> SetItem v a -> Bool #

(/=) :: SetItem v a -> SetItem v a -> Bool #

Show a => Show (SetItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Methods

showsPrec :: Int -> SetItem v a -> ShowS #

show :: SetItem v a -> String #

showList :: [SetItem v a] -> ShowS #

Generic (SetItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

Associated Types

type Rep (SetItem v a) :: Type -> Type #

Methods

from :: SetItem v a -> Rep (SetItem v a) x #

to :: Rep (SetItem v a) x -> SetItem v a #

HasTrailingWhitespace (SetItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

HasNewlines (SetItem v a) Source # 
Instance details

Defined in Language.Python.Optics.Newlines

type Rep (SetItem v a) Source # 
Instance details

Defined in Language.Python.Syntax.Expr

type Rep (SetItem v a) = D1 (MetaData "SetItem" "Language.Python.Syntax.Expr" "hpython-0.2-7fNN6PEHntyHCqZaN2NGK0" False) (C1 (MetaCons "SetItem" PrefixI True) (S1 (MetaSel (Just "_setItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeSetItemValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a))) :+: C1 (MetaCons "SetUnpack" PrefixI True) ((S1 (MetaSel (Just "_setItemAnn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ann a)) :*: S1 (MetaSel (Just "_unsafeSetUnpackParens") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [([Whitespace], [Whitespace])])) :*: (S1 (MetaSel (Just "_unsafeSetUnpackWhitespace") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Whitespace]) :*: S1 (MetaSel (Just "_unsafeSetUnpackValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Expr v a)))))

Lambdas

lambda_ :: [Raw Param] -> Raw Expr -> Raw Expr Source #

>>> lambda_ [p_ "x"] "x"
lambda x: x
>>> lambda_ [p_ "x", k_ "y" 2] ("x" .+ "y")
lambda x, y=2: x + y
>>> lambda_ [p_ "x", k_ "y" 2, s_ "z"] "a"
lambda x, y=2, *z: a
>>> lambda_ [p_ "x", k_ "y" 2, s_ "z", ss_ "w"] "a"
lambda x, y=2, *z, **w: a

Subscripting

subs_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

>>> subs_ (var_ "a") (int_ 1)
a[1]
>>> subs_ (var_ "a") (tuple_ [ti_ $ int_ 1])
a[1,]
>>> subs_ (var_ "a") (tuple_ [ti_ $ int_ 1, ti_ $ int_ 2])
a[1, 2]
>>> subs_ (var_ "a") (tuple_ [s_ $ var_ "b"])
a[((*b),)]
>>> subs_ (var_ "a") (tuple_ [ti_ $ int_ 1, s_ $ var_ "b"])
a[(1, *b)]

Slicing

sliceF_ :: Raw Expr -> Raw Expr Source #

Slice *from* x

>>> subs_ (var_ "a") (sliceF_ $ int_ 0)
a[1:]
>>> sliceF_ $ int_ 0
slice(1, None, None)

sliceFS_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

Slice *from* x, with *step* y

>>> subs_ (var_ "a") (sliceFS_ (int_ 0) (int_ 2))
a[1::2]
>>> sliceFS_ (int_ 0) (int_ 2)
slice(1, None, 2)

sliceT_ :: Raw Expr -> Raw Expr Source #

Slice To x

>>> subs_ (var_ "a") (sliceT_ $ int_ 10)
a[:10]
>>> sliceT_ $ int_ 10
slice(None, 10, None)

sliceTS_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

Slice To x, with Step y

>>> subs_ (var_ "a") (sliceTS_ (int_ 10) (int_ 2))
a[:10:2]
>>> sliceTS_ (int_ 10) (int_ 2)
slice(None, 10, 2)

sliceFT_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

Slice From x To y

>>> subs_ (var_ "a") (sliceFT_ (int_ 1) (int_ 10))
a[1:10]
>>> sliceFT_ (int_ 1) (int_ 10)
slice(1, 10, None)

sliceFTS_ :: Raw Expr -> Raw Expr -> Raw Expr -> Raw Expr Source #

Slice From x To y, with Step z

>>> subs_ (var_ "a") (sliceFTS_ (int_ 1) (int_ 10) (int_ 2))
a[1:10:2]
>>> sliceFTS_ (int_ 1) (int_ 10) (int_ 2)
slice(1, 10, 2)

sliceS_ :: Raw Expr -> Raw Expr Source #

Slice with *step* x

>>> subs_ (var_ "a") (sliceS_ $ int_ (-1))
a[::-1]
>>> sliceS_ $ int_ (-1)
slice(None, None, -1)

fullSlice_ :: Raw Expr Source #

The slice with no bounds

>>> subs_ (var_ "a") fullSlice_
a[:]
>>> fullSlice_
slice(None, None, None)

slice_ :: Maybe (Raw Expr) -> Maybe (Raw Expr) -> Maybe (Raw Expr) -> Raw Expr Source #

A slice object

Represents a call to a function named slice, with 3 arguments. If an argument is a Nothing then it becomes None, and if the argument is a Just then the contents are extracted.

Dereferencing

(/>) :: Raw Expr -> Raw Ident -> Raw Expr infixl 9 Source #

>>> var_ "a" /> var_ "b"
a.b

Unary operators

not_ :: Raw Expr -> Raw Expr Source #

not a

Binary operators

Comparison, bitwise, and arithmetic operators have precedences that are consistent with their Python counterparts. This meansPython expressions can be translated to kellSyntax with minimal parentheses.

Note: this doesn't apply to unary operators (because kellSyntax doesn't have unary operators), or the boolean operations and_ and or_ (because we ran out of precedence levels)

Boolean operations

or_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

a or b

Does not have a precedence

and_ :: Raw Expr -> Raw Expr -> Raw Expr Source #

a and b

Does not have a precedence

Comparison operations

is_ :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a is b

isNot_ :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a is not b

notIn_ :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a not in b

(.==) :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a == b

(.>) :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a > b

(.>=) :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a >= b

(.<) :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a < b

(.<=) :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a <= b

(.!=) :: Raw Expr -> Raw Expr -> Raw Expr infixl 1 Source #

a != b

Bitwise operations

(.|) :: Raw Expr -> Raw Expr -> Raw Expr infixl 2 Source #

a | b

(.^) :: Raw Expr -> Raw Expr -> Raw Expr infixl 3 Source #

a ^ b

(.&) :: Raw Expr -> Raw Expr -> Raw Expr infixl 4 Source #

a & b

(.<<) :: Raw Expr -> Raw Expr -> Raw Expr infixl 5 Source #

a << b

(.>>) :: Raw Expr -> Raw Expr -> Raw Expr infixl 5 Source #

a >> b

Arithmetic operations

(.-) :: Raw Expr -> Raw Expr -> Raw Expr infixl 6 Source #

a - b

(.+) :: Raw Expr -> Raw Expr -> Raw Expr infixl 6 Source #

a + b

(.*) :: Raw Expr -> Raw Expr -> Raw Expr infixl 7 Source #

a * b

(.@) :: Raw Expr -> Raw Expr -> Raw Expr infixl 7 Source #

a @ b

(./) :: Raw Expr -> Raw Expr -> Raw Expr infixl 7 Source #

a / b

(.//) :: Raw Expr -> Raw Expr -> Raw Expr infixl 7 Source #

a // b

(.%) :: Raw Expr -> Raw Expr -> Raw Expr infixl 7 Source #

a % b

(.**) :: Raw Expr -> Raw Expr -> Raw Expr infixr 8 Source #

a ** b

Miscellaneous

linesToBlock :: [Raw Line] -> Raw Block Source #

Convert a list of Lines to a Block, without indenting them