-- |
-- Use bijections on 'Invariant' functors from "Data.Functor.Invariant".
{-# LANGUAGE TypeOperators #-}
module Data.Invertible.Invariant
  ( invmap
  ) where

import Data.Invertible.Bijection
import qualified Data.Functor.Invariant as I

-- |Apply a bijection over an 'I.Invariant' using 'I.invmap'.
invmap :: I.Invariant f => a <-> b -> f a -> f b
invmap :: forall (f :: * -> *) a b. Invariant f => (a <-> b) -> f a -> f b
invmap (a -> b
f :<->: b -> a
g) = (a -> b) -> (b -> a) -> f a -> f b
forall a b. (a -> b) -> (b -> a) -> f a -> f b
forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
I.invmap a -> b
f b -> a
g