packages feed

representable-functors 2.0.2 → 2.1

raw patch · 2 files changed

+6/−2 lines, 2 files

Files

Data/Functor/Representable.hs view
@@ -48,6 +48,7 @@  import Control.Applicative import Control.Comonad.Trans.Traced+import Control.Comonad.Cofree import Control.Monad.Trans.Identity import Control.Monad.Reader import Data.Distributive@@ -57,6 +58,7 @@ import Data.Functor.Compose import Data.Functor.Product import Data.Lens.Common+import qualified Data.Sequence as Seq import Data.Semigroup hiding (Product) import Prelude hiding (lookup) @@ -77,7 +79,7 @@ -- * Default definitions  fmapRep :: Representable f => (a -> b) -> f a -> f b-fmapRep f = tabulate . fmap f . index +fmapRep f = tabulate . fmap f . index  mapWithKeyRep :: Representable f => (Key f -> a -> b) -> f a -> f b mapWithKeyRep f = tabulate . (<*>) f . index@@ -145,3 +147,5 @@ instance (Representable f, Representable g) => Representable (Product f g) where   tabulate f = Pair (tabulate (f . Left)) (tabulate (f . Right)) +instance Representable f => Representable (Cofree f) where+  tabulate f = f Seq.empty :< tabulate (\k -> tabulate (f . (k Seq.<|)))
representable-functors.cabal view
@@ -1,6 +1,6 @@ name:          representable-functors category:      Monads, Functors, Data Structures-version:       2.0.2+version:       2.1 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE