Commit 10d36f3c authored by Austin Seipp's avatar Austin Seipp
Browse files

Fix AMP warnings for MaybeT/MaybeErr


Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
parent dfc32cd5
......@@ -20,7 +20,8 @@ module Maybes (
MaybeT(..)
) where
import Control.Applicative
import Control.Monad
import Data.Maybe
infixr 4 `orElse`
......@@ -95,6 +96,10 @@ newtype MaybeT m a = MaybeT {runMaybeT :: m (Maybe a)}
instance Functor m => Functor (MaybeT m) where
fmap f x = MaybeT $ fmap (fmap f) $ runMaybeT x
instance (Monad m, Functor m) => Applicative (MaybeT m) where
pure = return
(<*>) = ap
instance Monad m => Monad (MaybeT m) where
return = MaybeT . return . Just
x >>= f = MaybeT $ runMaybeT x >>= maybe (return Nothing) (runMaybeT . f)
......@@ -112,6 +117,13 @@ instance Monad m => Monad (MaybeT m) where
\begin{code}
data MaybeErr err val = Succeeded val | Failed err
instance Functor (MaybeErr err) where
fmap = liftM
instance Applicative (MaybeErr err) where
pure = return
(<*>) = ap
instance Monad (MaybeErr err) where
return v = Succeeded v
Succeeded v >>= k = k v
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment