Skip to content

Instantly share code, notes, and snippets.

@UnkindPartition
Created May 22, 2015 10:03
Show Gist options
  • Save UnkindPartition/32b1d925baa3bc0e6b89 to your computer and use it in GitHub Desktop.
Save UnkindPartition/32b1d925baa3bc0e6b89 to your computer and use it in GitHub Desktop.
import Control.Monad.Logic
import Control.Monad.Trans.Maybe
zipLogic :: (MonadLogic m) => m a -> m b -> m (a, b)
zipLogic gx gy =
maybe mzero return <=< runMaybeT $ do
(x, rx) <- MaybeT (msplit gx)
(y, ry) <- MaybeT (msplit gy)
lift $ return (x, y) `mplus` zipLogic rx ry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment