module Data.Invertible.Strong where
import Prelude hiding ((.), id, fst, snd, curry)
import qualified Prelude as P
import Data.Invertible.Bijection
import Data.Invertible.Profunctor
import Data.Invertible.Tuple
class IsoProfunctor p => IsoStrong p where
first' :: p a b -> p (a, c) (b, c)
first' = dimap swap swap P.. second'
second' :: p a b -> p (c, a) (c, b)
second' = dimap swap swap P.. first'
instance IsoStrong (Bijection (->)) where
first' (ab :<->: ba) = (\ ~(a, c) -> (ab a, c)) :<->: (\ ~(b, c) -> (ba b, c))
second' (ab :<->: ba) = (\ ~(c, a) -> (c, ab a)) :<->: (\ ~(c, b) -> (c, ba b))