haskell - Typeclass for (what seems to be) a contravariant functor implementing function inversion -
lets have following import control.category (category, (.), id) data invertible b = invertible (a -> b) (b -> a) instance category invertible id = invertible prelude.id prelude.id (invertible f f') . (invertible g g') = invertible (f prelude.. g) (g' prelude.. f') invert (invertible x y) = invertible y x note following true: invert (g . f) == invert f . invert g this structure seems similar contravariant functor (wikipedia) , follows same axiom: f(g . f) = f(f) . f(g) in case, f invert . i looked @ data.functor.contravariant.contramap , has function of type: (a -> b) -> f b -> f but didn't know how'd i'd implement in situation. example, can't work out sensible choice f , , in situation, there's no function a -> b , invert . however, invert nevertheless fits mathematical axiom of contravariant functor, i'm thinking can fit existing class, can't find 1 , how it. or pointers appreciated. ...