I was trying to understand applicative and how i can use it as a cartesian product between
K functions and
N parameters ,and i can't comprehend why i can't do the following:
[Just (+1),Just (+2)] <*> [Just 1 ,Just 2] renders
* Couldn't match expected type `Maybe Integer -> b' with actual type `Maybe (Integer -> Integer)' * Possible cause: `Just' is applied to too many arguments In the expression: Just (+ 1) In the first argument of `(<*>)', namely `[Just (+ 1), Just (+ 2)]' In the expression: [Just (+ 1), Just (+ 2)] <*> [Just 1, Just 2]
I do not understand since from the definition it is supposed to take the functions out of the context, take the values and apply all combinations.
I have also tried :
:t [pure (+1),pure (+2)] <*> [Just 1 ,Just 2] :: Num a => [a -> a] and i can't understand why the resulting type is not a list of values (and not
a->a) ,since all operators expect only one argument,and i am already supplying that.
Can someone shed some light?