Last active
January 7, 2016 10:42
-
-
Save mankyKitty/30503fcaa11b0d1e8f45 to your computer and use it in GitHub Desktop.
An effect permitting unfold ???
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 Control.Lens.Cons (Cons (..), cons, (<|)) | |
import Data.Maybe (maybe) | |
import Data.Monoid (Monoid) | |
unfoldM :: (Cons s s a a, Monoid s, Monad m) => (b -> m (Maybe (a,b))) -> b -> m s | |
unfoldM f b = maybe (return mempty) (\(a,b') -> cons a <$> unfoldM f b') =<< f b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment