1module Lens.Family.Phantom where 2 3import Control.Applicative.Backwards (Backwards(..)) 4import Control.Applicative (Const(..)) 5import Data.Functor.Constant (Constant(..)) 6import Data.Functor.Compose (Compose(..)) 7 8class Functor f => Phantom f where 9 coerce :: f a -> f b 10 11instance Phantom f => Phantom (Backwards f) where 12 coerce (Backwards x) = Backwards (coerce x) 13 14instance Phantom (Const a) where 15 coerce (Const x) = (Const x) 16 17instance Phantom (Constant a) where 18 coerce (Constant x) = (Constant x) 19 20instance (Phantom f, Functor g) => Phantom (Compose f g) where 21 coerce (Compose x) = Compose (coerce x) 22