Sassa NF's return . (*2)
is both short and demonstrates an interesting principle of your example. If we inline the whole thing we'll get
list >>= double
list >>= return . (*2)
The pattern \f l -> l >>= return . f
Is common enough to have its own name: liftM
liftM :: Monad m => (a -> b) -> m a -> m b
liftM f m = m >>= return . f
And in fact, liftM
is equivalent to fmap
, often known as just map
when referring to lists:
list >>= return . (*2)
liftM (*2) list
fmap (*2) list
map (*2) list