FunctorM
Ashley Yakeley
ashley at semantic.org
Fri Jun 4 03:55:56 EDT 2004
In article <20040528001157.GA1924 at momenergy.repetae.net>,
John Meacham <john at repetae.net> wrote:
> class FunctorM f where
> fmapM :: Monad m => (a -> m b) -> f a -> m (f b)
I have an equivalent (I think) class in HBase in its big library of
Functor classes:
class (Functor f) =>
ExtractableFunctor f where
{
fextract :: forall g a. (FunctorApplyReturn g) =>
f (g a) -> g (f a);
};
for :: (ExtractableFunctor f,FunctorApplyReturn m) =>
(a -> m b) -> (f a -> m (f b));
for foo fa = fextract (fmap foo fa);
The important thing here is that a FunctorApplyReturn is more general
than Monad, it has only return and "fapply :: f (a -> b) -> f a -> f b".
Given this, it's also possible to write this function (by using a state
monad):
ftolist :: (ExtractableFunctor f) => f a -> [a]
The main Functor classes in HBase are arranged like this:
Functor <= FunctorApply <= FunctorApplyReturn <= Monad
Doubtless if I knew a little more category theory, I'd have better names
for them. It would be nice if the standard libraries adopted a
superclass arrangement like this...
--
Ashley Yakeley, Seattle WA
More information about the Libraries
mailing list