instance Monad IO -- predefined instance Monad Gen -- from QuickCheck instance Monad Parser -- from the Parsing module
instance Monad Maybe where return x = Just x Just x >>= f = f x Nothing >>= _ = Nothing
return :: a -> Maybe a (>>=) :: Maybe a -> (a->Maybe b) -> Maybe b
instance Monad [] where return x = [x] xs >>= f = [y | x<-xs, y<-f x]
return :: a -> [a] (>>=) :: [a] -> (a->[b]) -> [b]
[y | x<-xs, y<-f x]
⟺
do x<-xs; y<-f x; return y
instance Functor IO
instance Functor Gen -- from QuickCheck
instance Functor Parser
fmap :: (a->b) -> IO a -> IO b fmap :: (a->b) -> Gen a -> Gen b fmap :: (a->b) -> Parser a -> Parser b
instance Functor Maybe where fmap f Nothing = Nothing fmap f (Just x) = Just (f x)
fmap :: (a->b) -> Maybe a -> Maybe b
instance Functor [] where fmap = map
fmap :: (a->b) -> [a] -> [b]
instance Applicative IO
instance Applicative Gen -- from QuickCheck
instance Applicative Parser
(<*>) :: IO (a->b) -> IO a -> IO b (<*>) :: Gen (a->b) -> Gen a -> Gen b (<*>) :: Parser (a->b) -> Parser a -> Parser b
instance Applicative [] where pure x = [x] fs <*> xs = [f x | f<-fs, x<-xs]
pure :: a -> [a] (<*>) :: [a->b] -> [a] -> [b]
instance Applicative Maybe where pure x = Just x Just f <*> Just x = Just (f x) _ <*> _ = Nothing
pure :: a -> Maybe a (<*>) :: Maybe (a->b) -> Maybe a -> Maybe b
Applicative
Monad
class Applicative m => Monad m where -- ...
Monad
Applicative
Functor
fmap
liftM
pure
return
(<*>)
ap