Created
August 23, 2018 06:44
-
-
Save paulp/c0740d7a4fa79dfc145d2984981c7d61 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
instance Monad f => Applicative (OptionalT f) where | |
pure = OptionalT . pure . Full | |
mf <*> ma = OptionalT $ do | |
optf <- runOptionalT mf | |
case optf of | |
Empty -> return Empty | |
Full f -> do | |
opta <- runOptionalT ma | |
return $ f <$> opta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment