[<<][rtl][>>][..]

Sun Jun 17 03:59:01 EDT 2018

## Applicative

Main reason not to use them is that Kleisli composition is enough.
However, applications do start making sense when state machines are
lifted to simulations, because the values become "pure" in some sense.
(a -> m b) -> Stream a -> Stream b
Also
(a, b) -> m c
a -> b -> m c
Stream a -> Stream b -> Stream c
Are all kind of the same thing.
So it should be possible to define an Applicative instance.
(a -> b -> c) -> m a -> m b -> m c
So this brings me to the question:
is (m a -> m b) the same as (a -> m b)?
For sure there is:
t :: (m a -> m b) -> a -> m b
t f = f . return
t' :: (a -> m b) -> m a -> m b
t' f m = m >= f
So the conversion is generic and seems to be unique, so these seem to be isomorphic.
Then for the multi argument function, it does seem that the order
becomes important:
t'' :: (a -> b -> m c) -> (m a -> m b -> m c)
t'' f ma mb = do
a <- ma
b <- mb
f a b
So there is some form of arbitraryness here. The problem goes away in
the uncurried version:
:: (a,b) -> m c -> (m (a,b) -> m c)
What does this all mean? It seems that currying/uncurring Kleisli
arrows is not unique.
This points at the "default order" for Applicative functors: left to right.
ap :: m (a -> b) -> m a -> m b

[Reply][About]

[<<][rtl][>>][..]