Consider the following Applicative context f. I have a list of functions wrapped around this context F = f [a -> a] and a list of values wrapped around the same context i.e. V = f [a]. Now I want to apply the functions in F to the values in V. How can this be achieved?
I have tried the following :
1. (F <*>) <*> V
2. (V <*>) (F <*>)
But for some reason the types won't match.
The types won't match in 1 because both <*>
s are at the same "layer", and they won't match in 2 because you're trying to call the values as functions. (There are other problems too, but that should be enough to see why they shouldn't work.) You're looking for one of these two expressions:
(<*>) <$> f <*> v
liftA2 (<*>) f v
And remember in Haskell, variables start with lowercase letters and data constructors start with uppercase letters.