kan-extensions 4.1.0.1 → 4.1.1
raw patch · 7 files changed
+37/−10 lines, 7 filesnew-uploaderPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Monad.Codensity: instance Typeable Codensity
+ Data.Functor.Day: instance (Applicative f, Applicative g) => Applicative (Day f g)
Files
- CHANGELOG.markdown +9/−0
- kan-extensions.cabal +1/−1
- src/Control/Monad/Codensity.hs +10/−0
- src/Data/Functor/Coyoneda.hs +1/−1
- src/Data/Functor/Day.hs +6/−0
- src/Data/Functor/Kan/Ran.hs +6/−4
- src/Data/Functor/Kan/Rift.hs +4/−4
CHANGELOG.markdown view
@@ -1,3 +1,12 @@+4.1.1+---+* Added `Applicative` instance for `Day`+* Added `Typeable` instance for `Codensity`++4.1.0.1+----+* Added `tagged` dependency+ 4.1 --- * Moved co- and contra- variant `Day` convolution from `contravariant` to here. Day convolution is intimately connected to `Rift`.
kan-extensions.cabal view
@@ -1,6 +1,6 @@ name: kan-extensions category: Data Structures, Monads, Comonads, Functors-version: 4.1.0.1+version: 4.1.1 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE
src/Control/Monad/Codensity.hs view
@@ -6,6 +6,10 @@ #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} #endif+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708+{-# LANGUAGE DeriveDataTypeable #-}+#endif+ ----------------------------------------------------------------------------- -- | -- Module : Control.Monad.Codensity@@ -38,6 +42,9 @@ import Data.Functor.Kan.Ran import Data.Functor.Plus import Data.Functor.Rep+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708+import Data.Typeable+#endif -- | -- @'Codensity' f@ is the Monad generated by taking the right Kan extension@@ -53,6 +60,9 @@ newtype Codensity m a = Codensity { runCodensity :: forall b. (a -> m b) -> m b }+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708+ deriving Typeable+#endif instance Functor (Codensity k) where fmap f (Codensity m) = Codensity (\k -> m (k . f))
src/Data/Functor/Coyoneda.hs view
@@ -208,7 +208,7 @@ counit = counit . fmap lowerCoyoneda . lowerCoyoneda {-# INLINE counit #-} --- | Yoneda "expansion"+-- | Yoneda \"expansion\" -- -- @ -- 'liftCoyoneda' . 'lowerCoyoneda' ≡ 'id'
src/Data/Functor/Day.hs view
@@ -77,6 +77,12 @@ instance Functor (Day f g) where fmap f (Day fb gc bca) = Day fb gc $ \b c -> f (bca b c) +instance (Applicative f, Applicative g) => Applicative (Day f g) where+ pure x = Day (pure ()) (pure ()) (\_ _ -> x)+ (Day fa fb u) <*> (Day gc gd v) =+ Day ((,) <$> fa <*> gc) ((,) <$> fb <*> gd)+ (\(a,c) (b,d) -> u a b (v c d))+ instance (Representable f, Representable g) => Distributive (Day f g) where distribute f = Day (tabulate id) (tabulate id) $ \x y -> fmap (\(Day m n o) -> o (index m x) (index n y)) f
src/Data/Functor/Kan/Ran.hs view
@@ -67,17 +67,19 @@ -- @ -- ranIso1 :: Ran g f x -> Ran' g f x -- ranIso1 (Ran e) = Ran' e id+-- @ --+-- @ -- ranIso2 :: Ran' g f x -> Ran g f x--- ranIso2 (Ran' h z) = Ran $ \k -> h (k <$> z)+-- ranIso2 (Ran' h z) = Ran $ \\k -> h (k \<$\> z) -- @ -- -- @ -- ranIso2 (ranIso1 (Ran e)) ≡ -- by definition -- ranIso2 (Ran' e id) ≡ -- by definition--- Ran $ \k -> e (k <$> id) -- by definition--- Ran $ \k -> e (k . id) -- f . id = f--- Ran $ \k -> e k -- eta reduction+-- Ran $ \\k -> e (k \<$\> id) -- by definition+-- Ran $ \\k -> e (k . id) -- f . id = f+-- Ran $ \\k -> e k -- eta reduction -- Ran e -- @ --
src/Data/Functor/Kan/Rift.hs view
@@ -54,7 +54,7 @@ -- -- @ -- riftIso1 :: Functor g => UniversalRift g f a -> Rift g f a--- riftIso1 (UniversalRift h z) = Rift $ \g -> h $ fmap (\k -> k <$> z) g+-- riftIso1 (UniversalRift h z) = Rift $ \\g -> h $ fmap (\\k -> k \<$\> z) g -- @ -- -- @@@ -65,9 +65,9 @@ -- @ -- riftIso1 (riftIso2 (Rift h)) = -- riftIso1 (UniversalRift h id) = -- by definition--- Rift $ \g -> h $ fmap (\k -> k <$> id) g -- by definition--- Rift $ \g -> h $ fmap id g -- <$> = (.) and (.id)--- Rift $ \g -> h g -- by functor law+-- Rift $ \\g -> h $ fmap (\\k -> k \<$\> id) g -- by definition+-- Rift $ \\g -> h $ fmap id g -- \<$\> = (.) and (.id)+-- Rift $ \\g -> h g -- by functor law -- Rift h -- eta reduction -- @ --