representable-functors 1.8.0 → 2.0
raw patch · 3 files changed
+17/−2 lines, 3 files
Files
- Control/Monad/Representable/Reader.hs +6/−0
- Data/Functor/Representable.hs +10/−1
- representable-functors.cabal +1/−1
Control/Monad/Representable/Reader.hs view
@@ -133,6 +133,12 @@ extend = extendRep duplicate = duplicateRep +instance (Representable f, Representable m) => Zip (ReaderT f m) where+ zipWith = zipWithRep++instance (Representable f, Representable m) => ZipWithKey (ReaderT f m) where+ zipWithKey = zipWithKeyRep+ instance (Representable f, Representable m, Semigroup (Key f), Semigroup (Key m), Monoid (Key f), Monoid (Key m)) => Comonad (ReaderT f m) where extract = extractRep
Data/Functor/Representable.hs view
@@ -33,6 +33,9 @@ -- ** Bind/Monad , bindRep , bindWithKeyRep+ -- ** Zip/ZipWithKey+ , zipWithRep+ , zipWithKeyRep -- ** MonadReader , askRep , localRep@@ -63,7 +66,7 @@ -- > index . tabulate = id -- > tabulate . return f = return f -class (Indexable f, Distributive f, Keyed f, Apply f, Applicative f) => Representable f where+class (Indexable f, Distributive f, Keyed f, Apply f, Applicative f, ZipWithKey f) => Representable f where -- | > fmap f . tabulate = tabulate . fmap f tabulate :: (Key f -> a) -> f a @@ -96,6 +99,12 @@ apRep :: Representable f => f (a -> b) -> f a -> f b apRep f g = tabulate (index f <*> index g) ++zipWithRep :: Representable f => (a -> b -> c) -> f a -> f b -> f c+zipWithRep f g h = tabulate $ \k -> f (index g k) (index h k)++zipWithKeyRep :: Representable f => (Key f -> a -> b -> c) -> f a -> f b -> f c+zipWithKeyRep f g h = tabulate $ \k -> f k (index g k) (index h k) distributeRep :: (Representable f, Functor w) => w (f a) -> f (w a) distributeRep wf = tabulate (\k -> fmap (`index` k) wf)
representable-functors.cabal view
@@ -1,6 +1,6 @@ name: representable-functors category: Monads, Functors, Data Structures-version: 1.8.0+version: 2.0 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE