[Haskell-cafe] Applicative of Applicative

M Farkas-Dyck strake888 at gmail.com
Tue Mar 24 05:59:45 UTC 2015


The composition of any 2 Applicatives is itself an applicative functor. So we have

liftA2 (<*>) :: (Applicative p, Applicative q) => p (q (a -> b)) -> p (q a) -> p (q b)

On 23/03/2015 at 22:02:41 +0100, martin wrote:
> But a Temporal Temporal Int can always be flattened into a Temporal Int.

This is simply join, so it's also a Monad. I assume (pure = return) would make its argument time-invariant.

> So I may just as well ask to apply a function to the bottom level, namely the Ints.
> 
> How to I choose how deep down I want to reach?

Consider what semantics you want. Not knowing the semantics of Temporal and join :: Temporal (Temporal a) -> Temporal a, I can't say for sure, but changing TV channels seems to me a good example of Temporal (Temporal Image), for each channel is a Temporal Image and which is shown itself varies temporally.

Analogously, if I have _ :: [[a]], I can fmap (fmap (_ :: a -> b)) :: [[a]] -> [[b]], fmap (_ :: [a] -> [b]) :: [a] -> [b], or fmap (_ :: a -> b) ∘ join :: [[a]] -> [b] it; which I do is a function of the semantics I want.

Hope this helps ☺


More information about the Haskell-Cafe mailing list