I can multiply a list per 2:
(* 2) <$> [1, 2, 3] But I want multiply the elements which are Just:
(* 2) <$> [Just 1, Nothing, Just 3] Error:
* Non type-variable argument in the constraint: Num (Maybe a) (Use FlexibleContexts to permit this) * When checking the inferred type it :: forall a. (Num (Maybe a), Num a) => [Maybe a] Prelude Data.List
Another try:
fmap (* 2) [Just 1, Nothing, Just 3] Error:
* Non type-variable argument in the constraint: Num (Maybe a) (Use FlexibleContexts to permit this) * When checking the inferred type it :: forall a. (Num (Maybe a), Num a) => [Maybe a]
I have tried more things: map2, fmap2, map (*2) map, etc.