Copyright | (C) CSIRO 2017-2018 |
---|---|
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.Indents
- module Language.Python.Optics.Newlines
- assignTargets :: Traversal (Expr v a) (Expr '[] a) (Ident v a) (Ident '[] a)
- class HasCompoundStatement s where
- _CompoundStatement :: Prism (s v a) (s '[] a) (CompoundStatement v a) (CompoundStatement '[] a)
- 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
- _TryExcept :: Prism (s v a) (s '[] a) (TryExcept v a) (TryExcept '[] a)
- class HasTryFinally s where
- _TryFinally :: Prism (s v a) (s '[] a) (TryFinally v a) (TryFinally '[] a)
- _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 :: Prism (Expr v a) (Expr '[] a) (Ident v a) (Ident '[] 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
Indentation
Newlines
Simple statements
Assignment
assignTargets :: Traversal (Expr v a) (Expr '[] a) (Ident v a) (Ident '[] a) Source #
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 Source #
_CompoundStatement :: Prism (s v a) (s '[] a) (CompoundStatement v a) (CompoundStatement '[] a) Source #
Instances
HasCompoundStatement CompoundStatement Source # | |
Defined in Language.Python.Optics _CompoundStatement :: Prism (CompoundStatement v a) (CompoundStatement [] a) (CompoundStatement v a) (CompoundStatement [] a) Source # | |
HasCompoundStatement Statement Source # | |
Defined in Language.Python.Optics _CompoundStatement :: Prism (Statement v a) (Statement [] a) (CompoundStatement v a) (CompoundStatement [] a) Source # |
Function definitions
class HasFundef s where Source #
Instances
HasFundef CompoundStatement Source # | |
Defined in Language.Python.Optics _Fundef :: Prism (CompoundStatement v a) (CompoundStatement [] a) (Fundef v a) (Fundef [] a) Source # | |
HasFundef Statement Source # | |
HasFundef Fundef Source # | |
Class defintions
class HasClassDef s where Source #
Instances
HasClassDef CompoundStatement Source # | |
Defined in Language.Python.Optics _ClassDef :: Prism (CompoundStatement v a) (CompoundStatement [] a) (ClassDef v a) (ClassDef [] a) Source # | |
HasClassDef Statement Source # | |
HasClassDef ClassDef Source # | |
while
statements
class HasWhile s where Source #
Instances
HasWhile CompoundStatement Source # | |
Defined in Language.Python.Optics _While :: Prism (CompoundStatement v a) (CompoundStatement [] a) (While v a) (While [] a) Source # | |
HasWhile Statement Source # | |
HasWhile While Source # | |
for
statements
Instances
HasFor CompoundStatement Source # | |
Defined in Language.Python.Optics _For :: Prism (CompoundStatement v a) (CompoundStatement [] a) (For v a) (For [] a) Source # | |
HasFor Statement Source # | |
HasFor For Source # | |
with
statements
class HasWith s where Source #
Instances
HasWith CompoundStatement Source # | |
Defined in Language.Python.Optics _With :: Prism (CompoundStatement v a) (CompoundStatement [] a) (With v a) (With [] a) Source # | |
HasWith Statement Source # | |
HasWith With Source # | |
if
statements
Instances
HasIf CompoundStatement Source # | |
Defined in Language.Python.Optics _If :: Prism (CompoundStatement v a) (CompoundStatement [] a) (If v a) (If [] a) Source # | |
HasIf Statement Source # | |
HasIf If Source # | |
try
statements
class HasTryExcept s where Source #
_TryExcept :: Prism (s v a) (s '[] a) (TryExcept v a) (TryExcept '[] a) Source #
Instances
HasTryExcept CompoundStatement Source # | |
Defined in Language.Python.Optics _TryExcept :: Prism (CompoundStatement v a) (CompoundStatement [] a) (TryExcept v a) (TryExcept [] a) Source # | |
HasTryExcept Statement Source # | |
Defined in Language.Python.Optics | |
HasTryExcept TryExcept Source # | |
Defined in Language.Python.Optics |
class HasTryFinally s where Source #
_TryFinally :: Prism (s v a) (s '[] a) (TryFinally v a) (TryFinally '[] a) Source #
Instances
HasTryFinally CompoundStatement Source # | |
Defined in Language.Python.Optics _TryFinally :: Prism (CompoundStatement v a) (CompoundStatement [] a) (TryFinally v a) (TryFinally [] a) Source # | |
HasTryFinally Statement Source # | |
Defined in Language.Python.Optics _TryFinally :: Prism (Statement v a) (Statement [] a) (TryFinally v a) (TryFinally [] a) Source # | |
HasTryFinally TryFinally Source # | |
Defined in Language.Python.Optics _TryFinally :: Prism (TryFinally v a) (TryFinally [] a) (TryFinally v a) (TryFinally [] a) Source # |
else
Parameters
_PositionalParam :: Prism (Param v a) (Param '[] a) (PositionalParam v a) (PositionalParam '[] a) Source #
_KeywordParam :: Prism (Param v a) (Param '[] a) (KeywordParam v a) (KeywordParam '[] a) Source #
_UnnamedStarParam :: Prism (Param v a) (Param '[] a) (UnnamedStarParam v a) (UnnamedStarParam '[] a) Source #
Expressions
Identifiers
None
Function calls
Tuples
_TupleUnpack :: Prism (TupleItem v a) (TupleItem '[] a) (TupleUnpack v a) (TupleUnpack '[] a) Source #
Lists
_ListUnpack :: Prism (ListItem v a) (ListItem '[] a) (ListUnpack v a) (ListUnpack '[] a) Source #