module Darcs.UI.Options.Iso where
import Darcs.Prelude
data Iso a b = Iso (a -> b) (b -> a)
class IsoFunctor f where
imap :: Iso a b -> f a -> f b
under :: Functor f => Iso a b -> Iso (f a) (f b)
under :: Iso a b -> Iso (f a) (f b)
under (Iso a -> b
fw b -> a
bw) = (f a -> f b) -> (f b -> f a) -> Iso (f a) (f b)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso ((a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
fw) ((b -> a) -> f b -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> a
bw)
cps :: Iso a b -> Iso (a -> c) (b -> c)
cps :: Iso a b -> Iso (a -> c) (b -> c)
cps (Iso a -> b
fw b -> a
bw) = ((a -> c) -> b -> c)
-> ((b -> c) -> a -> c) -> Iso (a -> c) (b -> c)
forall a b. (a -> b) -> (b -> a) -> Iso a b
Iso (\a -> c
k -> a -> c
k (a -> c) -> (b -> a) -> b -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> a
bw) (\b -> c
k -> b -> c
k (b -> c) -> (a -> b) -> a -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
fw)