
David Menendez
Incidentally, is there a Backward applicative functor transfomer defined anywhere?
newtype Backward f a = Backward { runBackward :: f a } deriving Functor
instance Applicative f => Applicative (Backward f) where pure = Backward . pure (Backward f) <*> (Backward a) = Backward (f <**> a)
My intuitive typechecker doesn't accept that. And GHCi 6.8.2 seems to agree (I had to enable GeneralizedNewtypeDeriving for obvious reasons). /tmp/foo.hs:7:0: Occurs check: cannot construct the infinite type: a = (a -> b) -> b When trying to generalise the type inferred for `<*>' Signature type: forall (f :: * -> *). (Applicative f) => forall a1 b1. Backward f (a1 -> b1) -> Backward f a1 -> Backward f b1 Type to generalise: forall a1 b1. Backward f (a1 -> b1) -> Backward f a1 -> Backward f b1 In the instance declaration for `Applicative (Backward f)' Did I misunderstand something? Regards, Michael Karcher