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

Modulefcf-containers-0.8.2Haskell2010

Fcf.Data.Tree

Fcf.Data.Tree

Tree provides an interface which is similar to the that given by the container-package. If a method is missing here that you need, please do open up an issue or better, make a PR.

This module provides it's own but (almost) identical definitions of Tree and Forest. The reason for not using the definitions given in the containers is that since nothing else is needed from containers, we are able to have less dependencies.

Many of the examples are from containers-package.

  • 15 types
Example2 expressions
import qualified GHC.TypeLits as TLimport           Fcf.Data.Nat
datadata Tree a
#

Same as in containers, except not used for any term-level computation in this module.

Constructors

Instances16KnownVal, Eval, …
typetype Forest a = [Tree a]
#

Same as in containers, except not used for any term-level computation in this module.

datadata UnfoldTree (c :: b -> Exp (a, [b])) (d :: b) (e :: Tree a)
#

Unfold for a Tree.

Example
Example2 expressions
data BuildNode :: Nat -> Exp (Nat,[Nat]):{  type instance Eval (BuildNode x) =      If (Eval ((2 TL.* x TL.+ 1) >= 8))          '(x, '[])          '(x, '[2 TL.* x, (2 TL.* x) TL.+ 1 ]):}
Example1 expression
:kind! Eval (UnfoldTree BuildNode 1)Eval (UnfoldTree BuildNode 1) :: Tree TL.Natural= 'Node    1    '[ 'Node 2 '[ 'Node 4 '[], 'Node 5 '[]],       'Node 3 '[ 'Node 6 '[], 'Node 7 '[]]]
Instances1Eval
datadata Flatten (b :: Tree a) (c :: [a])
#

Flatten a Tree.

Example
Example1 expression
:kind! Eval (Flatten ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]]))Eval (Flatten ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]])) :: [TL.Natural]= '[1, 2, 3, 4, 5, 6]
Instances1Eval
datadata GetRoot (b :: Tree a) (c :: a)
#

Get the root node from a Tree.

Instances1Eval
  • type Eval (GetRoot ('Node a2 _1)) = a2Defined in fcf-containers-0.8.2 · Fcf.Data.Tree
datadata Levels (b :: Tree a) (c :: [[a]])
#

Get the levels from a Tree.

Example
Example1 expression
:kind! Eval (Levels ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]]))Eval (Levels ('Node 1 '[ 'Node 2 '[ 'Node 3 '[ 'Node 4 '[]]], 'Node 5 '[ 'Node 6 '[]]])) :: [[TL.Natural]]= '[ '[1], '[2, 5], '[3, 6], '[4]]
Instances1Eval