Given the following, taken from Typeclassopedia :
class MyApplicative f where pure :: a -> fa ap :: f (a -> b) -> fa -> fb instance Monoid e => MyApplicative ((,) e) where pure x = (mempty, x) (u, f) `ap` (v, x) = (u `mappend` v, fx)
I am trying to do something like:
ghci> (+) <$> Control.Applicative.pure 100 <*> Control.Applicative.pure 50 150
but with the new Applicative :
ghci> Main.pure (+ 100) `ap` (Main.pure 50) <interactive>:132:1: No instance for (MyApplicative f0) arising from a use of `it' The type variable `f0' is ambiguous Note: there is a potential instance available: instance Monoid e => MyApplicative ((,) e) -- Defined at MonoidWork.hs:8:10 In the first argument of `print', namely `it' In a stmt of an interactive GHCi command: print it
Looking for types:
ghci> :t Main.pure (+ 100) Main.pure (+ 100) :: (MyApplicative f, Num a) => f (a -> a)
and
ghci> :t (Main.pure 50) (Main.pure 50) :: (MyApplicative f, Num a) => fa
I do not understand how to fix a compile-time error.
source share