Last active
December 17, 2015 04:18
-
-
Save puffnfresh/5549221 to your computer and use it in GitHub Desktop.
This file contains 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 Data.Foldable | |
import Data.Monoid | |
pipeline :: [a -> a] -> a -> a | |
pipeline = appEndo . getDual . foldMap (Dual . Endo) | |
main = print $ pipeline [(+1), (*10)] 100 |
@mergeconflict that is actually a great way of showing that a monad is a monoid in the category of endofunctors. Thanks.
Yup!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
now do
pipelineK :: Monad m => [a -> m a] -> a -> m a
...
now do
pipelineAllTheThings :: (Foldable f, Monad m) => f (a -> m a) -> a -> m a