adjunctions 0.8.1 → 0.9.0
raw patch · 3 files changed
+13/−23 lines, 3 filesdep ~keysdep ~representable-functors
Dependency ranges changed: keys, representable-functors
Files
- Data/Functor/Adjunction.hs +1/−0
- Data/Functor/Contravariant/Adjunction.hs +9/−20
- adjunctions.cabal +3/−3
Data/Functor/Adjunction.hs view
@@ -101,6 +101,7 @@ -- limitR :: Adjunction f u => (forall a. u a) -> u (forall a. a) -- limitR = leftAdjunct (rightAdjunct (\(x :: forall a. a) -> x)) + instance Adjunction ((,)e) ((->)e) where leftAdjunct f a e = f (e, a) rightAdjunct f ~(e, a) = f a e
Data/Functor/Contravariant/Adjunction.hs view
@@ -1,12 +1,13 @@ {-# LANGUAGE Rank2Types, MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-} module Data.Functor.Contravariant.Adjunction ( Adjunction(..)- , Representation(..)- , repAdjunction, repFlippedAdjunction+ , corepAdjunction+ , coindexAdjunction ) where import Control.Monad.Instances () import Data.Functor.Contravariant+import Data.Functor.Corepresentable -- | An adjunction from Hask^op to Hask -- @@ -18,11 +19,12 @@ -- Any adjunction from Hask to Hask^op would indirectly -- permit unsafePerformIO, and therefore does not exist. -class (Contravariant f, Contravariant g) => Adjunction f g | f -> g, g -> f where+class (Contravariant f, Corepresentable g) => Adjunction f g | f -> g, g -> f where unit :: a -> g (f a) -- monad in Hask counit :: a -> f (g a) -- comonad in Hask^op leftAdjunct :: (b -> f a) -> a -> g b rightAdjunct :: (a -> g b) -> b -> f a+ unit = leftAdjunct id counit = rightAdjunct id leftAdjunct f = contramap f . unit @@ -38,22 +40,9 @@ unit a = Predicate (\k -> getPredicate k a) counit = unit --- | A representation of a contravariant functor-data Representation f x = Representation- { rep :: forall a. (a -> x) -> f a- , unrep :: forall a. f a -> (a -> x)- }- -- | Represent a contravariant functor that has a left adjoint-repAdjunction :: Adjunction f g => Representation g (f ())-repAdjunction = Representation - { rep = flip leftAdjunct () - , unrep = rightAdjunct . const- }--repFlippedAdjunction :: Adjunction f g => Representation f (g ()) -repFlippedAdjunction = Representation - { rep = flip rightAdjunct () - , unrep = leftAdjunct . const- }+corepAdjunction :: Adjunction f g => (a -> f ()) -> g a+corepAdjunction = flip leftAdjunct () +coindexAdjunction :: Adjunction f g => g a -> a -> f ()+coindexAdjunction = rightAdjunct . const
adjunctions.cabal view
@@ -1,6 +1,6 @@ name: adjunctions category: Data Structures, Adjunctions-version: 0.8.1+version: 0.9.0 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -26,9 +26,9 @@ containers >= 0.4 && < 0.5, contravariant >= 0.1.2 && < 0.2, distributive >= 0.1.1 && < 0.2,- keys >= 0.1.0.1 && < 0.2,+ keys >= 0.2 && < 0.3, mtl >= 2.0.1.0 && < 2.1,- representable-functors >= 0.2 && < 0.3,+ representable-functors >= 0.3 && < 0.4, semigroups >= 0.3.4 && < 0.4, semigroupoids >= 1.1.1 && < 1.2.0, transformers >= 0.2.0 && < 0.3,