Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Synopsis
- data a :==: b = Iso {
- isomorphism_epimorphism :: a -> b
- isomorphism_section :: b -> a
- appIso :: Applicative f => f (a :==: b) -> f a :==: f b
- type Iso a b = a :==: b
- type Automorphism a = a :==: a
- leftIdempotent :: (a :==: b) -> Endo a
- rightIdempotent :: (a :==: b) -> Endo b
- automorphism :: Endo a -> Endo a -> Automorphism a
- visit_iso :: ComposableVisitor v => (v :==: a) -> v -> a
- adjoint_iso :: Adjunction f g => (f a -> b) :==: (a -> g b)
- packTextIso :: String :==: Text
- class (BiArrow arr, Groupoid arr) => Isomorphic arr where
- class IsomorphicFunctor f where
- data IsoA f a b
- transformIso :: IsoA f a b -> f a :==: f b
- appIsoF :: IsomorphicFunctor f => IsoA f a b -> f a -> f b
- toArrow :: BiArrow arr => (a :==: b) -> arr a b
- abstract :: Isomorphic arr => (a :==: b) :==: arr a b
- runIso :: (a :==: b) -> a -> b
- type FRepresentable f a = forall r. (a -> r) -> f r
- type FCorepresentable f a = forall r. (r -> a) -> f r
- representable :: FRepresentable f a -> f a
- corepresentable :: FCorepresentable f a -> f a
- inverse_representable :: Functor f => f a -> FRepresentable f a
- coinverse_representable :: CoFunctor f => f a -> FCorepresentable f a
- (=<) :: (a :==: b) -> a -> b
- liftIso :: Isomorphic arr => ((a :==: b) -> c :==: d) -> arr a b -> arr c d
- runIsoInverse :: (a :==: b) -> b -> a
- embedIso :: Groupoid cat => cat a b -> cat b b -> cat a a
- invertIso :: (a :==: b) -> b :==: a
- equalIso :: Eq a => (a, a) :==: Either a (a, a)
- inIso :: Rec f :==: f (Rec f)
- mapIso :: Functor f => (a :==: b) -> f a :==: f b
- inverseImageIso :: CoFunctor p => (a :==: b) -> p b :==: p a
- bimapIso :: (Functor f, CoFunctor f) => (a :==: b) -> (a :==: c) -> f c :==: f b
- orderedMapIso :: (MonadFail m, Ord i, Ord a) => Map i a -> Map a i -> m (i :==: a)
- curryIso :: ((a, b) -> c) :==: (a -> b -> c)
- intIso :: Automorphism a -> (Integer -> a) :==: a
- pairingIso :: (Integer, Integer) :==: Integer
- squareIso :: Automorphism Integer
- absIso :: (Num a, Eq a) => a :==: Either a a
- plusminusIso :: Integral a => Automorphism (a, a)
- timesDivideIso :: Floating a => Automorphism (a, a)
- polarIso :: RealFloat a => Complex a :==: (a, a)
- ratioIso :: Integral a => (a, a) :==: (Ratio a, a)
- injectIso :: (a :==: b) -> (a :==: Either a b, b :==: Either a b)
- leftRightIso :: (a :==: Either a a, a :==: Either a a)
- type Bot = forall a. a
- andIso :: (Bool, Bool) :==: (Bool, Ordering)
- orIso :: (Bool, Bool) :==: (Bool, Ordering)
- initialIso :: (BiArrow arr, Arrow arr') => arr () (arr' Bot a)
- terminalIso :: (Isomorphic arr, Arrow arr') => arr () (arr' a ())
- productIso :: (BiArrow arr, Isomorphic arr, ArrowApply arr') => arr (arr' c (a, b)) (arr' c a, arr' c b)
- coproductIso :: (BiArrow arr, Isomorphic arr, ArrowChoice arr', ArrowApply arr') => arr (arr' (Either a b) c) (arr' a c, arr' b c)
- exponentialIso :: ArrowApply arr' => arr' (a, b) c :==: arr' a (arr' b c)
- eitherIso :: Isomorphic arr => arr a c1 -> arr b c2 -> arr (Either c1 c2) c -> arr (Either a b) c
- notIso :: BiArrow arr => arr Bool Bool
- boolIso :: BiArrow arr => arr Bool (Either () ())
- assocIso :: BiArrow arr => arr ((a, b), c) (a, (b, c))
- tripleIso :: BiArrow arr => arr (a, b, c) ((a, b), c)
- quadIso :: BiArrow arr => arr (a, b, c, d) ((a, b), (c, d))
- pentaIso :: BiArrow arr => arr (a, b, c, d, e) ((a, b), c, (d, e))
- zipEither :: BiArrow arr => arr (Either x y, Either a b) (Either (x, a) (Either (x, b) (Either (y, a) (y, b))))
- distIso :: BiArrow arr => arr (Either (a, b) (a, c)) (a, Either b c)
- assocEitherIso :: BiArrow arr => arr (Either a (Either b c)) (Either (Either a b) c)
- terminalSecondIso :: BiArrow arr => arr (a, ()) a
- terminalThirdIso :: BiArrow arr => arr (a, b, ()) (a, b)
- terminalFourthIso :: BiArrow arr => arr (a, b, c, ()) (a, b, c)
- swapIso :: BiArrow arr => arr (a, b) (b, a)
- swapEitherIso :: BiArrow arr => arr (Either a b) (Either b a)
- swapEither :: Either a b -> Either b a
- (<**>) :: (a :==: b) -> (c :==: d) -> (a, c) :==: (b, d)
- encodeDecode :: Binary a => a :==: ByteString
- encoding :: Binary a => Automorphism ByteString -> Automorphism a
- decoding :: Binary a => Automorphism a -> Automorphism ByteString
- product3 :: (a :==: b) -> (c :==: d) -> (e :==: f) -> (a, c, e) :==: (b, d, f)
- first3 :: (a :==: a') -> (a, b, c) :==: (a', b, c)
- second3 :: (b :==: b') -> (a, b, c) :==: (a, b', c)
- third3 :: (c :==: c') -> (a, b, c) :==: (a, b, c')
- (<||>) :: Isomorphic arr => arr a b -> arr c d -> arr (Either a c) (Either b d)
- ifIso :: Isomorphic arr => arr a b -> arr a c -> arr (a, Bool) (Either b c)
- branch :: Isomorphic arr => arr a b -> arr a c -> arr b d -> arr c d -> arr (a, Bool) (d, Bool)
- returnIso :: BiArrow arr => a -> arr () a
- fixIso :: Isomorphic arr => arr a a -> arr () (a, a)
- foldrIso :: ((a, [a]) :==: b) -> (Bool :==: b) -> [a] :==: b
- appendIso :: BiArrow arr => arr ([a], [a]) ([a], Int)
- listIso :: BiArrow arr => arr [a] (Either (a, [a]) ())
- foldListIso :: (a :==: b) -> (() :==: d) -> (Either (b, c) d :==: c) -> [a] :==: c
- mapListIso :: (a :==: b) -> [a] :==: [b]
- maybeIso :: BiArrow arr => arr (Maybe a) (Either a ())
- data IsomorphismA arr a b = IsoA {
- epimorphismA :: arr a b
- sectionA :: arr b a
Documentation
See http://twanvl.nl/blog/haskell/isomorphism-lenses I also saw somewhere (can't remember where) a blog post for an idea for combinator library using isomorphisms. This is some sort of implementation of that idea.
Iso | |
|
Instances
BiArrow (:==:) Source # | |
Defined in Math.Tools.Isomorphism | |
Isomorphic (:==:) Source # | |
Category (:==:) Source # | |
Groupoid (:==:) Source # | |
Arrow arr => ArrowTransformation (:==:) (arr :: Type -> Type -> Type) Source # | |
Defined in Math.Tools.Isomorphism | |
FunctorArrow Endo (:==:) (:==:) Source # | |
FunctorArrow Vector2 (:==:) (:==:) Source # | |
FunctorArrow I (:==:) (:==:) Source # | |
Limiting Stream (a :==: a) Source # | |
data Closure Stream (a :==: a) Source # | |
Defined in Math.Number.Stream |
type Automorphism a = a :==: a Source #
leftIdempotent :: (a :==: b) -> Endo a Source #
https://en.wikipedia.org/Galois_Connection Note that since we don't check the equations for isomorphisms, this function need not produce identity.
rightIdempotent :: (a :==: b) -> Endo b Source #
https://en.wikipedia.org/Galois_Connection Note that since we don't check the equations for isomorphisms, this function need not produce an identity.
automorphism :: Endo a -> Endo a -> Automorphism a Source #
visit_iso :: ComposableVisitor v => (v :==: a) -> v -> a Source #
adjoint_iso :: Adjunction f g => (f a -> b) :==: (a -> g b) Source #
class (BiArrow arr, Groupoid arr) => Isomorphic arr where Source #
Instances
class IsomorphicFunctor f where Source #
transformIso :: IsoA f a b -> f a :==: f b Source #
Instances
IsomorphicFunctor Var Source # | |
FunctorArrow v (->) (->) => IsomorphicFunctor (NumExpr v) Source # | |
FunctorArrow v (->) (->) => IsomorphicFunctor (VectorSpaceExpr v) Source # | |
Defined in Math.Number.NumericExpression data IsoA (VectorSpaceExpr v) a b Source # transformIso :: IsoA (VectorSpaceExpr v) a b -> VectorSpaceExpr v a :==: VectorSpaceExpr v b Source # |
appIsoF :: IsomorphicFunctor f => IsoA f a b -> f a -> f b Source #
type FRepresentable f a = forall r. (a -> r) -> f r Source #
type FCorepresentable f a = forall r. (r -> a) -> f r Source #
representable :: FRepresentable f a -> f a Source #
corepresentable :: FCorepresentable f a -> f a Source #
inverse_representable :: Functor f => f a -> FRepresentable f a Source #
coinverse_representable :: CoFunctor f => f a -> FCorepresentable f a Source #
runIsoInverse :: (a :==: b) -> b -> a Source #
orderedMapIso :: (MonadFail m, Ord i, Ord a) => Map i a -> Map a i -> m (i :==: a) Source #
constraint: all elements of the map must be present in both maps.
pairingIso :: (Integer, Integer) :==: Integer Source #
Cantor pairing function. Algorithm for the inverse is from https://secure.wikimedia.org/wikipedia/en/wiki/Pairing_function
plusminusIso :: Integral a => Automorphism (a, a) Source #
timesDivideIso :: Floating a => Automorphism (a, a) Source #
terminalIso :: (Isomorphic arr, Arrow arr') => arr () (arr' a ()) Source #
productIso :: (BiArrow arr, Isomorphic arr, ArrowApply arr') => arr (arr' c (a, b)) (arr' c a, arr' c b) Source #
coproductIso :: (BiArrow arr, Isomorphic arr, ArrowChoice arr', ArrowApply arr') => arr (arr' (Either a b) c) (arr' a c, arr' b c) Source #
exponentialIso :: ArrowApply arr' => arr' (a, b) c :==: arr' a (arr' b c) Source #
eitherIso :: Isomorphic arr => arr a c1 -> arr b c2 -> arr (Either c1 c2) c -> arr (Either a b) c Source #
zipEither :: BiArrow arr => arr (Either x y, Either a b) (Either (x, a) (Either (x, b) (Either (y, a) (y, b)))) Source #
terminalSecondIso :: BiArrow arr => arr (a, ()) a Source #
terminalThirdIso :: BiArrow arr => arr (a, b, ()) (a, b) Source #
terminalFourthIso :: BiArrow arr => arr (a, b, c, ()) (a, b, c) Source #
swapEither :: Either a b -> Either b a Source #
encodeDecode :: Binary a => a :==: ByteString Source #
encoding :: Binary a => Automorphism ByteString -> Automorphism a Source #
decoding :: Binary a => Automorphism a -> Automorphism ByteString Source #
branch :: Isomorphic arr => arr a b -> arr a c -> arr b d -> arr c d -> arr (a, Bool) (d, Bool) Source #
fixIso :: Isomorphic arr => arr a a -> arr () (a, a) Source #
mapListIso :: (a :==: b) -> [a] :==: [b] Source #
This instance of map for list doesn't need fmap:
data IsomorphismA arr a b Source #
IsoA | |
|
Instances
Category arr => Category (IsomorphismA arr :: k -> k -> Type) Source # | |
Defined in Math.Tools.Isomorphism id :: forall (a :: k0). IsomorphismA arr a a # (.) :: forall (b :: k0) (c :: k0) (a :: k0). IsomorphismA arr b c -> IsomorphismA arr a b -> IsomorphismA arr a c # | |
Category arr => Groupoid (IsomorphismA arr :: k -> k -> Type) Source # | |
Defined in Math.Tools.Isomorphism invertA :: forall (a :: k0) (b :: k0). IsomorphismA arr a b -> IsomorphismA arr b a Source # | |
Arrow arr => BiArrow (IsomorphismA arr) Source # | |
Defined in Math.Tools.Isomorphism (<->) :: (a -> b) -> (b -> a) -> IsomorphismA arr a b Source # |