I am trying to implement phantom Applicative functor from Monoid, described in section 4 in paper Applicative programming with effects:
newtype Accy o a = Acc {acc :: o}
instance Monoid o => Applicative (Accy o) where
pure _ = Acc mempty
Acc o1 <*> Acc o2 = Acc (o1 `mappend` o2)
However, I get following error:
* Could not deduce (Functor (Accy o))
arising from the superclasses of an instance declaration
from the context: Monoid o
bound by the instance declaration
at phantom-applicative-functor.hs:7:10-41
* In the instance declaration for `Applicative (Accy o)'
|
7 | instance Monoid o => Applicative (Accy o) where
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I have tried adding language extension such as:
{-# LANGUAGE MultiParamTypeClasses #-}
But, it didn't help. Is it possible to implement the phantom applicative function as described in the paper?