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
- _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 :: (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) 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 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
for
statements
with
statements
if
statements
try
statements
class HasTryExcept s where 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
_Ident :: (Choice p, Applicative f) => p (Ident v a) (f (Ident '[] a)) -> p (Expr v a) (f (Expr '[] a)) Source #
A faux-Prism for matching on the Ident
constructor of an SimpleStatement
.
It's not a Prism because:
When preview
ing, it discards the 'Expr'\'s annotation, and when
review
ing, it re-constructs an annotation from the supplied Ident
_Ident
::Prism
(SimpleStatement
v a) (SimpleStatement
'[] a) (Expr
v a) (Expr
'[] a)
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 #