The operator is *>defined by default as
xs *> ys = id <$ xs <*> ys
which, in turn, translates by default to
const id <$> xs <*> ys
That is, it replaces each element xswith idto get xs', and then calculates xs' <*> ys. []is an instance Monadwhere (=<<) = concatMap. One of the laws Applicativedescribes the relationship between instances Applicativeand Monad:
pure = return
fs <*> as = fs `ap` as = fs >>= \f -> as >>= \a -> f a
For lists, this
fs <*> as = [f a | f <- fs, a <- as]
, *> Monad.
, Applicative , newtype Control.Applicative:
newtype ZipList a = ZipList [a]
instance Applicative ZipList where
pure = repeat
(<*>) = zipWith ($)