generics-mrsop-2.0.0: 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 
Instances
Family Singl FamRoseInt CodesRoseInt Source # 
Instance details

Defined in Generics.MRSOP.Examples.RoseTreeTH

HasDatatypeInfo Singl FamRoseInt CodesRoseInt Source # 
Instance details

Defined in Generics.MRSOP.Examples.RoseTreeTH

Eq (Rose Int) Source #

Equality is defined using geq

Instance details

Defined in Generics.MRSOP.Examples.RoseTreeTH

Methods

(==) :: Rose Int -> Rose Int -> Bool #

(/=) :: Rose Int -> Rose Int -> Bool #

Show a => Show (Rose a) Source # 
Instance details

Defined in Generics.MRSOP.Examples.RoseTreeTH

Methods

showsPrec :: Int -> Rose a -> ShowS #

show :: Rose a -> String #

showList :: [Rose a] -> ShowS #

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 ListRoseInt_Ifx1 :: phi Z -> phi (S Z) -> View kon phi (Lkup (S Z) CodesRoseInt) Source #

pattern ListRoseInt_Ifx0 :: View kon phi (Lkup (S Z) CodesRoseInt) Source #

pattern RoseIntLeaf_ :: kon KInt -> View kon phi (Lkup Z CodesRoseInt) Source #

pattern RoseInt_Ifx0 :: kon KInt -> phi (S Z) -> View kon phi (Lkup Z CodesRoseInt) Source #

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

pattern IdxRoseInt :: forall (a :: 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