liftとか
liftで遊んでみる。
> :t map map :: (a -> b) -> [a] -> [b] > :t fmap fmap :: (Functor f) => (a -> b) -> f a -> f b > :t liftM liftM :: (Monad m) => (a1 -> r) -> m a1 -> m r > :t liftM2 liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r > :t ap ap :: (Monad m) => m (a -> b) -> m a -> m b > :t liftM (+) liftM (+) :: (Num a1, Monad m) => m a1 -> m (a1 -> a1) > :t liftM2 (+) liftM2 (+) :: (Num a1, Monad m) => m a1 -> m a1 -> m a1 > :t liftM2 id liftM2 id :: (Monad m) => m (a2 -> r) -> m a2 -> m r > liftM2 (+) [1..4] [3,4] [4,5,5,6,6,7,7,8] > liftM (+) [1..4] `ap` [3,4] [4,5,5,6,6,7,7,8] > ap [succ,(*2)] [1..4] [2,3,4,5,2,4,6,8] > :t liftM (+) [1..4] liftM (+) [1..4] :: (Num a1, Enum a1) => [a1 -> a1] > map (\f -> f 10) (liftM (+) [1..4]) [11,12,13,14] > liftM (+) [1..4] >>= return . (\f -> f 10) [11,12,13,14]