Created
January 27, 2016 02:40
-
-
Save kseo/c709a26798071821cae5 to your computer and use it in GitHub Desktop.
Reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Reduce t where | |
| reducer :: (a -> b -> b) -> (t a -> b -> b) | |
| reducel :: (b -> a -> b) -> (b -> t a -> b) | |
| instance Reduce [] where | |
| reducer f x z = foldr f z x | |
| reducel f x z = foldl f x z | |
| toList :: (Reduce f) => f a -> [a] | |
| toList s = s `cons` [] where cons = reducer (:) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment