HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulehxt-9.3.1.22Haskell2010

Data.Tree.Class

Interface definition for trees

  • 1 class
  • 1 value
  • Packagehxt-9.3.1.22
  • Exports2
  • LanguageHaskell2010
  • LicenceMIT
  • SourceClass.hs
classclass Tree (t :: Type -> Type) where
#

The interface for trees

Methods

  • mkTree :: a -> [t a] -> t a

    tree construction: a new tree is constructed by a node attribute and a list of children

  • mkLeaf :: a -> t a

    leaf construction: leafs don't have any children

    definition: mkLeaf n = mkTree n []

  • isLeaf :: t a -> Bool

    leaf test: list of children empty?

  • isInner :: t a -> Bool

    innner node test: not . isLeaf

  • getNode :: t a -> a

    select node attribute

  • getChildren :: t a -> [t a]

    select children

  • changeNode :: (a -> a) -> t a -> t a

    edit node attribute

  • changeChildren :: ([t a] -> [t a]) -> t a -> t a

    edit children

  • setNode :: a -> t a -> t a

    substitute node: setNode n = changeNode (const n)

  • setChildren :: [t a] -> t a -> t a

    substitute children: setChildren cl = changeChildren (const cl)

  • foldTree :: (a -> [b] -> b) -> t a -> b

    fold for trees

  • nodesTree :: t a -> [a]

    all nodes of a tree

  • depthTree :: t a -> Int

    depth of a tree

  • cardTree :: t a -> Int

    number of nodes in a tree

  • formatTree :: (a -> String) -> t a -> String

    format tree for readable trace output

    a graphical representation of the tree in text format

Instances2Tree
  • Tree NTreeDefined in hxt-9.3.1.22 · Data.Tree.NTree.TypeDefs

    Implementation of Data.Tree.Class interface for rose trees

  • Tree NTZipperDefined in hxt-9.3.1.22 · Data.Tree.NTree.Zipper.TypeDefs