{-# LANGUAGE TypeOperators #-}
module Data.Invertible.PartialIsomorphism
( toIso
, fromIso
, (<$>)
) where
import Prelude hiding ((<$>))
import Data.Invertible.Bijection
import qualified Control.Isomorphism.Partial as P
import qualified Control.Isomorphism.Partial.Unsafe as P
toIso :: a <-> b -> P.Iso a b
toIso (f :<->: g) = P.Iso (Just . f) (Just . g)
fromIso :: P.Iso a b -> Maybe a <-> Maybe b
fromIso (P.Iso f g) = (f =<<) :<->: (g =<<)
(<$>) :: P.IsoFunctor f => a <-> b -> f a -> f b
(<$>) = (P.<$>) . toIso