module Generics.Pointless.Examples.Observe where
import Generics.Pointless.Combinators
import Generics.Pointless.Functors
import Generics.Pointless.RecursionPatterns
import Generics.Pointless.Observe.RecursionPatterns
import Generics.Pointless.Observe.Functors
import Generics.Pointless.Examples.Examples
import Debug.Observe
import Data.Typeable
lengthHyloO :: Observable a => [a] -> Int
lengthHyloO = hyloO (_L::Int) f g
where f = inn
g = (id -|- snd) . out
lengthAnaO :: Observable a => [a] -> Int
lengthAnaO = anaO (_L::Int) f
where f = (id -|- snd) . out
lengthCataO :: (Typeable a, Observable a) => [a] -> Int
lengthCataO = cataO (_L :: [a]) g
where g = inn . (id -|- snd)
factHyloO :: Int -> Int
factHyloO = hyloO (_L::[Int]) f g
where g = (id -|- succ /\ id) . out
f = one \/ prod
factParaO :: Int -> Int
factParaO = paraO (_L::Int) f
where f = one \/ prod . (id >< succ)
factZygoO :: Int -> Int
factZygoO = zygoO (_L::Int) inn f
where f = one \/ (prod . (id >< succ))
fibHyloO :: Int -> Int
fibHyloO = hyloO (_L::LTree One) f g
where g = (bang -|- pred /\ pred . pred) . ((<=1)?)
f = one \/ add
fibHistoO :: Int -> Int
fibHistoO = histoO (_L::Int) f
where f = (zero \/ (one . snd \/ add . (id >< outl)) . distr . out)
fibDynaO :: Int -> Int
fibDynaO = dynaO (_L::Int) f g
where f = (zero \/ (one . snd \/ add . (id >< outl)) . distr . out)
g = out
qsortHyloO :: (Typeable a, Observable a, Ord a) => [a] -> [a]
qsortHyloO = hyloO (_L::Tree a) f g
where g = (id -|- fst /\ partition) . out
f = nil \/ cat . (id >< cons) . assocr . (swap >< id) . assocl
tailParaO :: (Typeable a, Observable a) => [a] -> [a]
tailParaO = paraO (_L::[a]) (nil \/ snd . snd)
addAccumO :: (Int,Int) -> Int
addAccumO = accumO (_L::Int) t f
where t = (fst -|- id >< succ) . distl
f = (snd \/ fst) . distl