Created
March 7, 2016 02:13
-
-
Save kseo/03a66990be5a922c6c4b to your computer and use it in GitHub Desktop.
fold and Monoid
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
import Prelude hiding (foldr) | |
import Data.Monoid | |
foldComposing :: (a -> (b -> b)) -> [a] -> Endo b | |
foldComposing f = foldMap (Endo . f) | |
foldr :: (a -> (b -> b)) -> b -> [a] -> b | |
foldr f z xs = appEndo (foldComposing f xs) z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment