Copyright | (c) gspia 2020- |
---|---|
License | BSD |
Maintainer | gspia |
Safe Haskell | Safe |
Language | Haskell2010 |
Synopsis
- data TreeF a b = NodeF a [b]
- data TreeToFix :: Tree a -> Exp (Fix (TreeF a))
- data SumNodesAlg :: Algebra (TreeF Nat) Nat
- data CountNodesAlg :: Algebra (TreeF a) Nat
- data Size :: Tree a -> Exp Nat
- data BuildNodeCoA :: CoAlgebra (TreeF Nat) Nat
- data BuildFibTreeCoA :: CoAlgebra (TreeF Nat) Nat
- data Fib :: Nat -> Exp Nat
- data BTreeF a b
- data PartHlp :: (a -> a -> Exp Bool) -> CoAlgebra (BTreeF a) [a]
- data SymbolCompareInc :: Symbol -> Symbol -> Exp Bool
- data SymbolCompareDec :: Symbol -> Symbol -> Exp Bool
- data Inord :: Algebra (BTreeF a) [a]
- data Qsort :: (a -> a -> Exp Bool) -> [a] -> Exp [a]
- data PartCmp :: (a -> a -> Exp Bool) -> CoAlgebra (BTreeF a) [a]
Documentation
NodeF a [b] |
Instances
type Eval (TreeToFix (Node a2 (b ': bs)) :: Fix (TreeF a1) -> Type) Source # | |
type Eval (TreeToFix (Node a2 ([] :: [Tree a1])) :: Fix (TreeF a1) -> Type) Source # | |
type Eval (BuildFibTreeCoA n :: TreeF Nat Nat -> Type) Source # | |
type Eval (BuildNodeCoA n :: TreeF Nat Nat -> Type) Source # | |
type Eval (Map f (NodeF a3 (b2 ': bs)) :: TreeF a2 b1 -> Type) Source # | |
type Eval (Map f (NodeF a3 ([] :: [a1])) :: TreeF a2 b -> Type) Source # | |
data TreeToFix :: Tree a -> Exp (Fix (TreeF a)) Source #
A function to transform a Tree into fixed structure that can be used by Cata and Ana.
See the implementation of Size
for an example.
data SumNodesAlg :: Algebra (TreeF Nat) Nat Source #
Sum the nodes of TreeF containing Nats.
See the implementation of Fib
for an example.
Instances
type Eval (SumNodesAlg (NodeF x (b ': bs)) :: Nat -> Type) Source # | |
Defined in Fcf.Alg.Tree | |
type Eval (SumNodesAlg (NodeF x ([] :: [Nat])) :: Nat -> Type) Source # | |
Defined in Fcf.Alg.Tree |
data CountNodesAlg :: Algebra (TreeF a) Nat Source #
Count the nodes of TreeF.
See the Size
for an example.
Instances
type Eval (CountNodesAlg (NodeF x (b ': bs)) :: Nat -> Type) Source # | |
Defined in Fcf.Alg.Tree | |
type Eval (CountNodesAlg (NodeF x ([] :: [Nat])) :: Nat -> Type) Source # | |
Defined in Fcf.Alg.Tree |
data Size :: Tree a -> Exp Nat Source #
Size of the Tree is the number of nodes in it.
Example
Size is defined as Cata CountNodesAlg =<< TreeToFix tr
and can be used with the following.
>>>
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 ]) :}
>>>
:kind! Eval (Size =<< UnfoldTree BuildNode 1)
Eval (Size =<< UnfoldTree BuildNode 1) :: Nat = 7
data BuildNodeCoA :: CoAlgebra (TreeF Nat) Nat Source #
CoAlgebra to build TreeF's.
This is an example from containers-package. See Size
and example in there.
:kind! Eval (Ana BuildNodeCoA 1) :kind! Eval (Hylo CountNodesAlg BuildNodeCoA 1)
data Fib :: Nat -> Exp Nat Source #
Fibonaccis with Hylo, not efficient
Example
>>>
:kind! Eval (Fib 10)
Eval (Fib 10) :: Nat = 55
BTreeF is a btree functor. At the moment, it is used to build sorting algorithms.
Instances
type Eval (PartHlp smaller (h ': t) :: BTreeF a [a] -> Type) Source # | |
type Eval (PartHlp _ ([] :: [a]) :: BTreeF a [a] -> Type) Source # | |
type Eval (PartCmp cmp coalg :: BTreeF a [a] -> Type) Source # | |
type Eval (Map f (BNodeF a4 b1 b2) :: BTreeF a3 a2 -> Type) Source # | |
type Eval (Map f (BEmptyF :: BTreeF a2 a1) :: BTreeF a2 b -> Type) Source # | |
data PartHlp :: (a -> a -> Exp Bool) -> CoAlgebra (BTreeF a) [a] Source #
data SymbolCompareInc :: Symbol -> Symbol -> Exp Bool Source #
Use this if you want to sort symbols into increasing order.
Instances
type Eval (SymbolCompareInc n1 n2 :: Bool -> Type) Source # | |
Defined in Fcf.Alg.Tree |
data SymbolCompareDec :: Symbol -> Symbol -> Exp Bool Source #
Use this if you want to sort symbols into decreasing order.
Instances
type Eval (SymbolCompareDec n1 n2 :: Bool -> Type) Source # | |
Defined in Fcf.Alg.Tree |
data Qsort :: (a -> a -> Exp Bool) -> [a] -> Exp [a] Source #
Qsort - give the comparison function a -> a -> Exp Bool
comparing your
list elements and then Qsort will order the list.
Example
>>>
:kind! Eval (Qsort (<) '[5,3,1,9,4,6,3])
Eval (Qsort (<) '[5,3,1,9,4,6,3]) :: [Nat] = '[1, 3, 3, 4, 5, 6, 9]
>>>
:kind! Eval (Qsort SymbolCompareInc '[ "bb", "e", "a", "e", "d" ])
Eval (Qsort SymbolCompareInc '[ "bb", "e", "a", "e", "d" ]) :: [TL.Symbol] = '["a", "bb", "d", "e", "e"]