tree-traversals: Functions and newtype wrappers for traversing Trees

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

The tree-traversals package defines in-order, pre-order, post-order, level-order, and reversed level-order traversals for tree-like types:

inorder, preorder, postorder, levelorder, rlevelorder
  :: (TreeLike tree, Applicative f) => (a -> f b) -> tree a -> f (tree b)

The package also provides newtype wrappers for the various traversals so they may be used with traverse, i.e.

traverse f (InOrder tree) = inorder f tree
traverse f (PreOrder tree) = preorder f tree
traverse f (PostOrder tree) = postorder f tree
traverse f (LevelOrder tree) = levelorder f tree
traverse f (RLevelOrder tree) = rlevelorder f tree

To implement the various orders, the tree-traversals package provides the Control.Applicative.Phases.Phases applicative transformer for organizing effects into distinct phases.

Instances of Data.Traversable.TreeLike.TreeLike are provided for rose trees (Data.Tree.Tree), binary trees (Data.BinaryTree.BinaryTree), forests (Data.Traversable.TreeLike.Forest), and algebraic combinations of trees (Data.Functor.Compose.Compose outerTree innerTree, Data.Functor.Product fstTree sndTree, Data.Functor.Sum leftTree rightTree).


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.1.0, 0.1.1.0, 0.1.2.0, 0.1.3.0
Change log ChangeLog.md
Dependencies base (>=4.10 && <4.13), containers [details]
License CC0-1.0
Author Noah Luck Easterly
Maintainer noah.easterly@gmail.com
Category Data
Home page https://github.com/rampion/tree-traversals
Source repo head: git clone git://github.com/rampion/tree-traversals.git
this: git clone git://github.com/rampion/tree-traversals.git(tag v0.1.0.0)
Uploaded by NoahEasterly at 2019-12-11T22:58:38Z

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
development

Enable all warnings and upgrade warnings to errors

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for tree-traversals-0.1.1.0

[back to package description]

The tree-traversals package defines in-order, pre-order, post-order, level-order, and reversed level-order traversals for tree-like types:

inorder, preorder, postorder, levelorder, rlevelorder
  :: (TreeLike tree, Applicative f) => (a -> f b) -> tree a -> f (tree b) 

The package also provides newtype wrappers for the various traversals so they may be used with traverse, i.e.

traverse f (InOrder tree) = inorder f tree
traverse f (PreOrder tree) = preorder f tree
traverse f (PostOrder tree) = postorder f tree
traverse f (LevelOrder tree) = levelorder f tree
traverse f (RLevelOrder tree) = rlevelorder f tree

To implement the various orders, the tree-traversals package provides the Phases applicative transformer for organizing effects into distinct phases.

Instances of TreeLike are provided for rose trees (Tree from Data.Tree), binary trees (BinaryTree from this package's Data.BinaryTree), forests (Forest from this package's Data.Traversable.TreeLike), and algebraic combinations of trees (Compose outerTree innerTree, Product fstTree sndTree, Sum leftTree rightTree).