Created
December 11, 2020 19:03
-
-
Save Solonarv/16e2c3d1301a99b6c26f59d6a261884b to your computer and use it in GitHub Desktop.
Monadic Loeb fixed-point combinator
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
-- standard "loeb" combinator | |
-- https://github.com/quchen/articles/blob/master/loeb-moeb.md | |
loeb :: Functor f => f (f a -> a) -> f a | |
loeb x = go where go = fmap ($ go) x | |
-- "monadic loeb"? | |
loebM :: (Traversable t, Monad m) => t (t a -> m a) -> m (t a) | |
loebM = sequenceA . loeb . fmap (\f xs -> f =<< sequenceA xs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment