On Wed, Feb 24, 2016 at 11:22 AM, Kosyrev Serge <_deepfire@feelingofgreen.ru> wrote:
Are you also saying that this cannot be resolved by some kind of a
type families-based type-level 'flip'?
It really can't, no. You can definetype family FlipF f a b whereFlipF f a b = f b abut FlipF, being a type family, is not first-class. You can't make any instances whatsoever for FlipF f a -- you'll probably get an error about a partially applied type family. What you *can* do is make a Flip newtype:newtype Flip f a b = Flip {unflip :: f b a}This behaves perfectly:instance Bifunctor f => Functor (Flip f a) wherefmap f = Flip . first f . unflipinstance Profunctor f => Contravariant (Flip f a) wherecontramap f = Flip . lmap f . unflipinstance Bifunctor f => Bifunctor (Flip f) wherebimap f g (Flip x) = Flip (bimap g f x)
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries