Copyright | (C) CSIRO 2017-2019 |
---|---|
License | BSD3 |
Maintainer | Isaac Elliott <isaace71295@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Optics for manipulating Python syntax trees
Synopsis
- module Language.Python.Optics.Validated
- module Language.Python.Optics.Idents
- module Language.Python.Optics.Indents
- module Language.Python.Optics.Newlines
- assignTargets :: Traversal (Expr v a) (Expr '[] a) (Ident v a) (Ident '[] a)
- class HasCompoundStatement s where
- class HasFundef s where
- class HasClassDef s where
- class HasWhile s where
- class HasFor s where
- class HasWith s where
- class HasIf s where
- _Elif :: Iso' (Elif v a) (Indents a, [Whitespace], Expr v a, Suite v a)
- class HasTryExcept s where
- class HasTryFinally s where
- _Finally :: Iso' (Finally v a) (Indents a, [Whitespace], Suite v a)
- _Except :: Iso' (Except v a) (Indents a, [Whitespace], Maybe (ExceptAs v a), Suite v a)
- _Else :: Iso' (Else v a) (Indents a, [Whitespace], Suite v a)
- _PositionalParam :: Prism (Param v a) (Param '[] a) (PositionalParam v a) (PositionalParam '[] a)
- _KeywordParam :: Prism (Param v a) (Param '[] a) (KeywordParam v a) (KeywordParam '[] a)
- _UnnamedStarParam :: Prism (Param v a) (Param '[] a) (UnnamedStarParam v a) (UnnamedStarParam '[] a)
- _StarParam :: Prism (Param v a) (Param '[] a) (StarParam v a) (StarParam '[] a)
- _Ident :: (Choice p, Applicative f) => p (Ident v a) (f (Ident '[] a)) -> p (Expr v a) (f (Expr '[] a))
- _None :: Prism (Expr v a) (Expr '[] a) (None v a) (None '[] a)
- _Call :: Prism (Expr v a) (Expr '[] a) (Call v a) (Call '[] a)
- _Tuple :: Prism (Expr v a) (Expr '[] a) (Tuple v a) (Tuple '[] a)
- _TupleUnpack :: Prism (TupleItem v a) (TupleItem '[] a) (TupleUnpack v a) (TupleUnpack '[] a)
- tupleItems :: Traversal (Tuple v a) (Tuple '[] a) (TupleItem v a) (TupleItem '[] a)
- _List :: Prism (Expr v a) (Expr '[] a) (List v a) (List '[] a)
- _ListUnpack :: Prism (ListItem v a) (ListItem '[] a) (ListUnpack v a) (ListUnpack '[] a)
- listItems :: Traversal (List v a) (List '[] a) (ListItem v a) (ListItem '[] a)
Documentation
Identifiers
Indentation
Newlines
Simple statements
Assignment
assignTargets :: Traversal (Expr v a) (Expr '[] a) (Ident v a) (Ident '[] a) #
Traversal
targeting the variables that would modified as a result of an assignment
Here are some examples of assignment targets:
a = b ^
(a, b, c) = d ^ ^ ^
[a, b, *c] = d ^ ^ ^
These expressions have variables on the left hand side of the =
, but those variables
don't count as assignment targets:
a[b] = c
a(b) = c
{a: b} = c
Compound statements
class HasCompoundStatement s where #
_CompoundStatement :: Prism (s v a) (s '[] a) (CompoundStatement v a) (CompoundStatement '[] a) #
Instances
HasCompoundStatement CompoundStatement # | |
Defined in Language.Python.Optics _CompoundStatement :: (Choice p, Applicative f) => p (CompoundStatement v a) (f (CompoundStatement [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasCompoundStatement Statement # | |
Defined in Language.Python.Optics _CompoundStatement :: (Choice p, Applicative f) => p (CompoundStatement v a) (f (CompoundStatement [] a)) -> p (Statement v a) (f (Statement [] a)) # |
Function definitions
Instances
HasFundef CompoundStatement # | |
Defined in Language.Python.Optics _Fundef :: (Choice p, Applicative f) => p (Fundef v a) (f (Fundef [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasFundef Statement # | |
Defined in Language.Python.Optics | |
HasFundef Fundef # | |
Defined in Language.Python.Optics |
Class defintions
class HasClassDef s where #
Instances
HasClassDef CompoundStatement # | |
Defined in Language.Python.Optics _ClassDef :: (Choice p, Applicative f) => p (ClassDef v a) (f (ClassDef [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasClassDef Statement # | |
Defined in Language.Python.Optics | |
HasClassDef ClassDef # | |
Defined in Language.Python.Optics |
while
statements
Instances
HasWhile CompoundStatement # | |
Defined in Language.Python.Optics _While :: (Choice p, Applicative f) => p (While v a) (f (While [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasWhile Statement # | |
Defined in Language.Python.Optics | |
HasWhile While # | |
Defined in Language.Python.Optics |
for
statements
Instances
HasFor CompoundStatement # | |
Defined in Language.Python.Optics _For :: (Choice p, Applicative f) => p (For v a) (f (For [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasFor Statement # | |
Defined in Language.Python.Optics | |
HasFor For # | |
Defined in Language.Python.Optics |
with
statements
Instances
HasWith CompoundStatement # | |
Defined in Language.Python.Optics _With :: (Choice p, Applicative f) => p (With v a) (f (With [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasWith Statement # | |
Defined in Language.Python.Optics | |
HasWith With # | |
Defined in Language.Python.Optics |
if
statements
Instances
HasIf CompoundStatement # | |
Defined in Language.Python.Optics _If :: (Choice p, Applicative f) => p (If v a) (f (If [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasIf Statement # | |
Defined in Language.Python.Optics | |
HasIf If # | |
Defined in Language.Python.Optics |
try
statements
class HasTryExcept s where #
_TryExcept :: Prism (s v a) (s '[] a) (TryExcept v a) (TryExcept '[] a) #
Instances
HasTryExcept CompoundStatement # | |
Defined in Language.Python.Optics _TryExcept :: (Choice p, Applicative f) => p (TryExcept v a) (f (TryExcept [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasTryExcept Statement # | |
Defined in Language.Python.Optics _TryExcept :: (Choice p, Applicative f) => p (TryExcept v a) (f (TryExcept [] a)) -> p (Statement v a) (f (Statement [] a)) # | |
HasTryExcept TryExcept # | |
Defined in Language.Python.Optics _TryExcept :: (Choice p, Applicative f) => p (TryExcept v a) (f (TryExcept [] a)) -> p (TryExcept v a) (f (TryExcept [] a)) # |
class HasTryFinally s where #
_TryFinally :: Prism (s v a) (s '[] a) (TryFinally v a) (TryFinally '[] a) #
Instances
HasTryFinally CompoundStatement # | |
Defined in Language.Python.Optics _TryFinally :: (Choice p, Applicative f) => p (TryFinally v a) (f (TryFinally [] a)) -> p (CompoundStatement v a) (f (CompoundStatement [] a)) # | |
HasTryFinally Statement # | |
Defined in Language.Python.Optics _TryFinally :: (Choice p, Applicative f) => p (TryFinally v a) (f (TryFinally [] a)) -> p (Statement v a) (f (Statement [] a)) # | |
HasTryFinally TryFinally # | |
Defined in Language.Python.Optics _TryFinally :: (Choice p, Applicative f) => p (TryFinally v a) (f (TryFinally [] a)) -> p (TryFinally v a) (f (TryFinally [] a)) # |
else
Parameters
_PositionalParam :: Prism (Param v a) (Param '[] a) (PositionalParam v a) (PositionalParam '[] a) #
_KeywordParam :: Prism (Param v a) (Param '[] a) (KeywordParam v a) (KeywordParam '[] a) #
_UnnamedStarParam :: Prism (Param v a) (Param '[] a) (UnnamedStarParam v a) (UnnamedStarParam '[] a) #
Expressions
Identifiers
_Ident :: (Choice p, Applicative f) => p (Ident v a) (f (Ident '[] a)) -> p (Expr v a) (f (Expr '[] a)) #
None
Function calls
Tuples
_TupleUnpack :: Prism (TupleItem v a) (TupleItem '[] a) (TupleUnpack v a) (TupleUnpack '[] a) #
Lists
_ListUnpack :: Prism (ListItem v a) (ListItem '[] a) (ListUnpack v a) (ListUnpack '[] a) #