generics-mrsop-1.0.0.1: Generic Programming with Mutually Recursive Sums of Products.

Safe HaskellNone
LanguageHaskell2010

Generics.MRSOP.Examples.RoseTreeTH

Contents

Description

Usage example with template haskell support.

Synopsis

Defining the datatype

First, we will start off defining a variant of your standard Rose trees. The Leaf constructor adds some redundancy on purpose, so we can later use the combinators in the library to remove that redundancy.

data Rose a Source #

Rose trees with redundancy.

Constructors

a :>: [Rose a] 
Leaf a 

value1 :: Rose Int Source #

Sample values.

value2 :: Rose Int Source #

Sample values.

value3 :: Rose Int Source #

Sample values.

type CodesRoseInt = '['['[K KInt, I (S Z)], '[K KInt]], '['[], '[I Z, I (S Z)]]] Source #

pattern Pat0586258 :: PoA Singl (El FamRoseInt) '[K KInt, I (S Z)] -> NS (PoA Singl (El FamRoseInt)) '['[K KInt, I (S Z)], '[K KInt]] Source #

pattern Pat0Leaf :: PoA Singl (El FamRoseInt) '[K KInt] -> NS (PoA Singl (El FamRoseInt)) '['[K KInt, I (S Z)], '[K KInt]] Source #

pattern Pat19193 :: PoA Singl (El FamRoseInt) '[] -> NS (PoA Singl (El FamRoseInt)) '['[], '[I Z, I (S Z)]] Source #

pattern Pat158 :: PoA Singl (El FamRoseInt) '[I Z, I (S Z)] -> NS (PoA Singl (El FamRoseInt)) '['[], '[I Z, I (S Z)]] Source #

pattern IdxListRoseInt :: forall (a :: Nat). () => forall (n :: Nat). ((~#) Nat Nat a (S n), (~#) Nat Nat n Z) => SNat a Source #

pattern IdxRoseInt :: forall (a :: Nat). () => (~#) Nat Nat a Z => SNat a Source #

Eq Instance

testEq :: Bool Source #

Equality test; should return True!

Compos test

normalize :: Rose Int -> Rose Int Source #

This function removes the redundant Leaf constructor by the means of a compos. Check the source for details.

Crush test

sumTree :: Rose Int -> Int Source #

Sums up the values in a rose tree using a crush

testSum :: Bool Source #

The sum of a tree should be the same as the sum of a normalized tree; This should return True.

Orphan instances