
On 09/02/13 06:53, Nicolas Trangez wrote:
# Redirected to haskell-cafe
On Sun, 2013-09-01 at 14:58 +0400, Artyom Kazak wrote:
Would this be an appropriate place to propose adding mapM_ (and then possibly mapM) to bytestring library?
Was it suggested before? If yes, why was it rejected?
This got me wondering: there are several type-classes useful for polymorphic container types, e.g. Functor, Foldable & Traversable which all apply to some type of kind (* -> *).
Are there related things for monomorphic containers, like ByteString, Text or some newtype'd Vector with fixed element type, e.g.
class MFunctor f a where mfmap :: (a -> a) -> f -> f
instance MFunctor ByteString Word8 where mfmap = ByteString.map
I'm not aware of this particular class, but I have considered it. In the end I've chosen to generalize the class to FactorialMonoid instead: class Monoid m => FactorialMonoid m where ... foldMap :: Monoid n => (m → n) → m → n ByteString and Text are instances of the class, and so are lists, maps, and other containers, and Sum and Product as well. http://hackage.haskell.org/packages/archive/monoid-subclasses/0.3.2/doc/html...
or (maybe even better)
class MFunctor f where type Elem mfmap :: (Elem -> Elem) -> f -> f
instance MFunctor ByteString where type Elem = Word8 mfmap = ByteString.map
and similar for other classes.
Nicolas
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe