-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Split Epimorphisms and Monomorphisms -- -- Please see the README on GitHub at -- https://github.com/gvolpe/split-morphism#readme @package split-morphism @version 0.1.0.1 module Control.Lens.Format -- | A normalizing optic, isomorphic to Prism but with different laws, -- specifically getMaybe needs not to be injective; i.e., distinct -- inputs may have the same getMaybe result, which combined with a -- subsequent reverseGet yields a normalized form for a. -- Composition with stronger optics (Prism and Iso) yields -- another Format. data Format a b Format :: (a -> Maybe b) -> (b -> a) -> Format a b [getMaybe] :: Format a b -> a -> Maybe b [reverseGet] :: Format a b -> b -> a -- | getMaybe and reverseGet, yielding a normalized formatted -- value. Subsequent getMaybe/reverseGet cycles are idempotent. normalize :: Format a b -> a -> Maybe a -- | Compose with a Prism. composePrism :: Format a b -> Prism' b c -> Format a c -- | Compose with an Iso. composeIso :: Format a b -> Iso' b c -> Format a c -- | A Prism is trivially a Format. fromPrism :: Prism' a b -> Format a b -- | An Isomorphism is trivially a Format. fromIso :: Iso' a b -> Format a b instance Data.Functor.Invariant.Invariant (Control.Lens.Format.Format a) module Control.Lens.SplitEpi -- | A split epimorphism, which we can think of as a weaker Iso a b -- where b is a "smaller" type. So `get . reverseGet` remains an -- identity but `reverseGet . get` is merely idempotent (i.e., it -- normalizes values in a). -- -- The following statements hold: - reverseGet is a "section" of -- get, - get is a "retraction" of reverseGet, - -- b is a "retract" of a, - the pair `(get, -- reverseGet)` is a "splitting" of the idempotent `reverseGet . get`. data SplitEpi a b SplitEpi :: (a -> b) -> (b -> a) -> SplitEpi a b [get] :: SplitEpi a b -> a -> b [reverseGet] :: SplitEpi a b -> b -> a -- | `reverseGet . get`, yielding a normalized formatted value. Subsequent -- get/reverseGet cycles are idempotent. normalize :: SplitEpi a b -> a -> a -- | Compose with another SplitEpi. composeSplitEpi :: SplitEpi a b -> SplitEpi b c -> SplitEpi a c -- | Compose with an Iso. composeIso :: SplitEpi a b -> Iso' b c -> SplitEpi a c -- | An Isomorphism is trivially a SplitEpi. fromIso :: Iso' a b -> SplitEpi a b instance Data.Functor.Invariant.Invariant (Control.Lens.SplitEpi.SplitEpi a) module Control.Lens.SplitMono -- | A split monomorphism, which we can think of as a weaker Iso a b -- where a is a "smaller" type. So `reverseGet . get` remains an -- identity but `get . reverseGet` is merely idempotent (i.e., it -- normalizes values in b). -- -- The following statements hold: - reverseGet is a "retraction" -- of get, - get is a "section" of reverseGet, - -- a is a "retract" of b, - the pair `(reverseGet, -- get)` is a "splitting" of the idempotent `get . reverseGet`. data SplitMono a b SplitMono :: (a -> b) -> (b -> a) -> SplitMono a b [get] :: SplitMono a b -> a -> b [reverseGet] :: SplitMono a b -> b -> a -- | `reverseGet . get`, yielding a normalized formatted value. Subsequent -- get/reverseGet cycles are idempotent. normalize :: SplitMono a b -> b -> b -- | Compose with another SplitMono. composeSplitMono :: SplitMono a b -> SplitMono b c -> SplitMono a c -- | Compose with an Iso. composeIso :: SplitMono a b -> Iso' b c -> SplitMono a c -- | An Isomorphism is trivially a SplitMono. fromIso :: Iso' a b -> SplitMono a b instance Data.Functor.Invariant.Invariant (Control.Lens.SplitMono.SplitMono a) module Control.Lens.Wedge -- | Composition of a SplitMono and a SplitEpi, yielding an -- even weaker structure where neither `reverseGet . get` and `get . -- reverseGet` is an identity but both are idempotent. data Wedge a b Wedge :: (a -> b) -> (b -> a) -> Wedge a b [get] :: Wedge a b -> a -> b [reverseGet] :: Wedge a b -> b -> a -- | Normalize a via a round-trip through b. normalizeA :: Wedge a b -> a -> a -- | Normalize b via a round-trip through a. normalizeB :: Wedge a b -> b -> b -- | Swapping get and reverseGet yields a Wedge. reverse :: Wedge a b -> Wedge b a -- | Compose with another Wedge. composeWedge :: Wedge a b -> Wedge b c -> Wedge a c -- | Compose with an Iso. composeIso :: Wedge a b -> Iso' b c -> Wedge a c -- | An Isomorphism is trivially a Wedge. fromIso :: Iso' a b -> Wedge a b instance Data.Functor.Invariant.Invariant (Control.Lens.Wedge.Wedge a) module Control.Lens.SplitMorphism -- | Swapping get and reverseGet yields a SplitMono. reverseEpi :: SplitEpi a b -> SplitMono b a -- | Swapping get and reverseGet yields a SplitEpi. reverseMono :: SplitMono a b -> SplitEpi b a -- | Composition between SplitEpi and SplitMono. composeSplitEpiMono :: SplitEpi a b -> SplitMono b c -> Wedge a c -- | Composition between SplitEpi and Prism. composeSplitEpiPrism :: SplitEpi a b -> Prism' b c -> Format a c -- | Composition between SplitMono and SplitEpi. composeSplitMonoEpi :: SplitMono a b -> SplitEpi b c -> Wedge a c -- | Conversion from SplitEpi to Wedge. epiAsWedge :: SplitEpi a b -> Wedge a b -- | Conversion from SplitMono to Wedge. monoAsWedge :: SplitMono a b -> Wedge a b