Add instance Monad ZipList

Dannyu NDos ndospark320 at gmail.com
Thu Jun 4 06:53:08 UTC 2020


instance Monad ZipList where
    ZipList [] >>= _ = ZipList []
    ZipList (x:xs) >>= f = ZipList $ do
        let ZipList y' = f x
        guard (not (null y'))
        let ZipList ys = ZipList xs >>= ZipList . join . maybeToList . fmap
snd . uncons . getZipList . f
        head y' : ys

instance MonadFail ZipList where
    fail _ = empty

instance MonadPlus ZipList
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200604/53e2c91b/attachment.html>


More information about the Libraries mailing list