[Haskell-cafe] Have you seen this functor/contrafunctor combo?
sjoerd at w3future.com
Wed Jun 6 23:43:31 CEST 2012
If there would be a package where this could be in it would be contravariant, but it isn't.
> > newtype Q' p f a = Q' (p a -> f a)
> instance (Contravariant p, Functor m, MonadFix m) => Applicative (Q' p m) where
> pure a = Q' (pure (return a))
> Q' fs <*> Q' as = Q' $ \r -> do
> f <- fs (contramap ($ a) r)
> a <- as (contramap (f $) r)
> return $ f a
More information about the Haskell-Cafe