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.Optics

Contents

Description

Optics for manipulating Python syntax trees

Synopsis

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

Function definitions

class HasFundef s where Source #

Methods

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

Instances
HasFundef CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

HasFundef Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

HasFundef Fundef Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

Class defintions

class HasClassDef s where Source #

Methods

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

Instances
HasClassDef CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

HasClassDef Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

HasClassDef ClassDef Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

while statements

class HasWhile s where Source #

Methods

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

Instances
HasWhile CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_While :: Prism (CompoundStatement v a) (CompoundStatement [] a) (While v a) (While [] 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 #

HasWhile While Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

for statements

class HasFor s where Source #

Methods

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

Instances
HasFor CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_For :: Prism (CompoundStatement v a) (CompoundStatement [] a) (For v a) (For [] 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 #

HasFor For Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

with statements

class HasWith s where Source #

Methods

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

Instances
HasWith CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_With :: Prism (CompoundStatement v a) (CompoundStatement [] a) (With v a) (With [] 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 #

HasWith With Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

if statements

class HasIf s where Source #

Methods

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

Instances
HasIf CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

Methods

_If :: Prism (CompoundStatement v a) (CompoundStatement [] a) (If v a) (If [] 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 #

HasIf If Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

_Elif :: Iso' (Elif v a) (Indents a, [Whitespace], Expr v a, Suite v a) Source #

try statements

class HasTryExcept s where Source #

Methods

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

Instances
HasTryExcept CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

HasTryExcept Statement Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

HasTryExcept TryExcept Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

class HasTryFinally s where Source #

Methods

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

else

_Else :: Iso' (Else v a) (Indents a, [Whitespace], Suite v a) Source #

Parameters

_StarParam :: Prism (Param v a) (Param '[] a) (StarParam v a) (StarParam '[] 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 previewing, it discards the 'Expr'\'s annotation, and when reviewing, it re-constructs an annotation from the supplied Ident

_Ident :: Prism (SimpleStatement v a) (SimpleStatement '[] a) (Expr v a) (Expr '[] a)

None

_None :: Prism (Expr v a) (Expr '[] a) (None v a) (None '[] a) Source #

Function calls

_Call :: Prism (Expr v a) (Expr '[] a) (Call v a) (Call '[] a) Source #

Tuples

_Tuple :: Prism (Expr v a) (Expr '[] a) (Tuple v a) (Tuple '[] a) Source #

tupleItems :: Traversal (Tuple v a) (Tuple '[] a) (TupleItem v a) (TupleItem '[] a) Source #

Lists

_List :: Prism (Expr v a) (Expr '[] a) (List v a) (List '[] a) Source #

listItems :: Traversal (List v a) (List '[] a) (ListItem v a) (ListItem '[] a) Source #