LicenseGNU LGPLv3
Maintainerpaul.bittner@uni-ulm.de
Safe HaskellSafe

Edits

Description

Module for Edits to ASTs.

Synopsis

Documentation

data EditType Source #

Each edit is associated to a type depending on what it does.

Constructors

Identity

Identity edits do nothing to the AST (they are noops).

TraceOnly

TraceOnly are edits that do not alter the AST but have a non-empty delta. This delta is used to descibe side-effects that should be applied to all nodes in the delta (e.g., change their feature mapping).

Insert

Insert edits only add nodes to a tree.

Delete

Delete edits only remove nodes from a tree.

Move

Moves only relocate nodes within the same tree.

Update

Updates only change the contents of one or more nodes without altering the tree structure.

Instances

Instances details
Eq EditType Source # 
Instance details

Defined in Edits

Methods

(==) :: EditType -> EditType -> Bool

(/=) :: EditType -> EditType -> Bool

Show EditType Source # 
Instance details

Defined in Edits

Methods

showsPrec :: Int -> EditType -> ShowS

show :: EditType -> String

showList :: [EditType] -> ShowS

data Edit g a Source #

An edit to an AST.

Constructors

Edit 

Fields

  • edittype :: EditType

    The type of this edit classifying its behaviour.

  • name :: String

    The name of this edit. Used for debugging and printing.

  • run :: AST g a -> AST g a

    Applies the edit to an AST, yielding the edited AST.

  • delta :: AST g a -> Set (Node g a)

    Computs the set of all nodes that will be altered (inserted, deleted, moved, updated ...) when applying the edit to a given AST.

Instances

Instances details
Show (Edit g a) Source # 
Instance details

Defined in Edits

Methods

showsPrec :: Int -> Edit g a -> ShowS

show :: Edit g a -> String

showList :: [Edit g a] -> ShowS

type EditScript g a = [Edit g a] Source #

An EditScript is a sequence of edits that should be applied in order to a single AST.

foldEditScript :: EditScript g a -> AST g a -> AST g a Source #

Runs an entire edit script on a given AST. If curried, turns an edit script into one single function that can run that script on any AST.

edit_identity :: Edit g a Source #

The identity of edits. Does nothing and has an empty delta for all trees.

edit_trace_only :: Set (Node g a) -> Edit g a Source #

An identity edit that will keep the given set of nodes as delta for the feature trace recording. Upon recording, all given nodes will have their feature trace changed to the feature context. This function assumes that the given set of nodes is a subset of the nodes in the future edited tree.

edit_ins_tree :: Eq a => AST g a -> UUID -> Int -> Edit g a Source #

Inserts a subtree into another tree. The given tree (first argument) will become the i-th child of the node with the given UUID.

edit_del_node :: Eq a => UUID -> Edit g a Source #

Delete the node with the given UUID v and move its children up (such that they become children of the deleted node's parent).

edit_del_tree :: Eq a => UUID -> Edit g a Source #

Delete the entire subtree whose root has the given id.

edit_move_tree :: (Grammar g, Eq a, Show a) => UUID -> UUID -> Int -> Edit g a Source #

Moves the subtree s with the given root (first argument). s will become the i-th child of the node with the given id (second argument).

edit_update :: (Grammar g, Show a, Eq a) => UUID -> g -> a -> Edit g a Source #

Updates the node with the given UUID to have a new grammar type and a new value. The node will keep its UUID (i.e., not get a new uuid as it is still associated to the same previous node.