Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module explores different ways to implement the "pairing fold".
Documentation
>>>
:{
data Tree = Leaf | Tree :*: Tree instance Show Tree where show Leaf = "." show (xs :*: ys) = "(" ++ show xs ++ "*" ++ show ys ++ ")" :}
pairFold1 :: (a -> a -> a) -> [a] -> Maybe a Source #
The traditional definition of the pairing fold, as given in the original paper.
>>>
pairFold1 (:*:) (replicate 5 Leaf)
Just ((.*.)*((.*.)*.))
pairFold2 :: (a -> a -> a) -> [a] -> Maybe a Source #
A function that is identical to the one above, although implemented as a fold.
>>>
pairFold2 (:*:) (replicate 5 Leaf)
Just ((.*.)*((.*.)*.))
Instances
Foldable Acc3 Source # | |
Defined in MonusWeightedSearch.Examples.PairingFold fold :: Monoid m => Acc3 m -> m # foldMap :: Monoid m => (a -> m) -> Acc3 a -> m # foldMap' :: Monoid m => (a -> m) -> Acc3 a -> m # foldr :: (a -> b -> b) -> b -> Acc3 a -> b # foldr' :: (a -> b -> b) -> b -> Acc3 a -> b # foldl :: (b -> a -> b) -> b -> Acc3 a -> b # foldl' :: (b -> a -> b) -> b -> Acc3 a -> b # foldr1 :: (a -> a -> a) -> Acc3 a -> a # foldl1 :: (a -> a -> a) -> Acc3 a -> a # elem :: Eq a => a -> Acc3 a -> Bool # maximum :: Ord a => Acc3 a -> a # |