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

**Error**

```
* 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?

`[]`

) does not contain functions. It contains`Maybe`

s. So trying to apply the functions in the context is a type error. This is why the error says that it expected a function but actually got a`Maybe`

instead. Try`[(+1), (+2)] <*> [1,2]`

instead. – Rein Henrichs Apr 20 at 21:02`Maybe`

. – Willem Van Onsem Apr 20 at 21:04`[]`

and`Maybe`

? If so, then this won't work by default because GHC doesn't understand you're working with a composition. You need to make a new type for the composition, either with Compose or "by hand" with something like`newtype MaybeList a = [Maybe a]`

(and then supply your own`Applicative`

instance for`MaybeList`

). – Robin Zigmond Apr 20 at 21:15