
David Menendez
On Fri, Jul 25, 2008 at 10:12 AM, Michael Karcher
wrote: David Menendez
wrote: 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). [..] Did I misunderstand something?
That's a typo on my part. I should have written "Backward (a <**> f)".
so you mean: Backward f <*> Backward a = Backward (a <**> f) ? According to the haddock of Control.Applicative, this line is semantically equivalent to Backward f <*> Backward a = Backward (f <*> a) So I don't see the point of this "transformer". It seems to do nothing, just as newtype Backward f a = Backward { runBackward :: f a } deriving (Functor, Applicative) would also do. Regards, Michael Karcher