こういう認識で合ってます?
{-# LANGUAGE DefaultSignatures #-}
import Prelude hiding (Functor(..), Monad(..))
class Functor m where
fmap :: (a -> b) -> m a -> m b
default fmap :: Applicative m => (a -> b) -> m a -> m b
fmap f v = pure f <$> v
class Functor m => Applicative m where
pure :: a -> m a
default pure :: Monad m => a -> m a
pure = return
(<$>) :: m (a -> b) -> m a -> m b
default (<$>) :: Monad m => m (a -> b) -> m a -> m b
a <$> b = a >>= \f -> b >>= \v -> return (f v)
class Applicative m => Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b
instance Monad [] where
return a = [a]
m >>= f = concatMap f m
instance Applicative []
instance Functor []
main :: IO ()
main = do
print $ [(+1), (*2)] <$> [1, 2, 3]