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' (