hpython-0.1: Syntax tree and DSL for Python

Copyright(C) CSIRO 2017-2018
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

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

Methods

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

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

Methods

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

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

Methods

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

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 #

Instances
HasTryFinally CompoundStatement Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

HasTryFinally TryFinally Source # 
Instance details

Defined in Language.Python.Optics

Methods

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

_Finally :: Iso' (Finally v a) (Indents a, [Whitespace], Suite v a) Source #

_Except :: Iso' (Except v a) (Indents a, [Whitespace], Maybe (ExceptAs v a), Suite v a) Source #

else

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

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 #

_StarParam :: Prism (Param v a) (Param '[] a) (StarParam v a) (StarParam '[] a) Source #

Expressions

Identifiers

_Ident :: Prism (Expr v a) (Expr '[] a) (Ident v a) (Ident '[] a) Source #

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 #

_TupleUnpack :: Prism (TupleItem v a) (TupleItem '[] a) (TupleUnpack v a) (TupleUnpack '[] 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 #

_ListUnpack :: Prism (ListItem v a) (ListItem '[] a) (ListUnpack v a) (ListUnpack '[] a) Source #

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