The FunctorM library

Thomas Jäger thjaeger at gmail.com
Sun Mar 20 18:29:38 EST 2005

Hello,

Aside from naming issues, there seem to be some problems with the way
FunctorM is currently implemented.

First of all, `FunctorM` should be a superclass of `Functor' because
there is an obvios implementation of fmap in terms of fmapM
> import Data.FunctorM
>
> fmap' :: FunctorM f => (a -> b) -> f a -> f b
> fmap' f = runIdentity . fmapM (return . f)
It is already annyoing enough that `Funtor' isn't a subclass of

Now, FunctorM should be based on the simplest operations possible,
which in this case is the distributive law and not a monadic version
of fmap (which might be provided for efficiency reasons).

> class Functor f => FunctorM' f where
>   dist' :: Monad m => f (m a) -> m (f a)
>   fmapM' :: Monad m => (a -> m b) -> f a -> m (f b)
>
>   dist' = fmapM' id
>   fmapM' f = dist' . fmap f
>
> -- for example
> instance FunctorM' [] where
>   dist' = sequence
>   fmapM' = mapM

Thomas
{"ft_lang_label":"__label__en","ft_lang_prob":0.8257702,"math_prob":0.924109,"size":1107,"snap":"2022-05-2022-21","text_gpt3_token_len":325,"char_repetition_ratio":0.12964642,"word_repetition_ratio":0.009478673,"special_character_ratio":0.2990063,"punctuation_ratio":0.1127451,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9851402,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-01-19T04:38:49Z\",\"WARC-Record-ID\":\"<urn:uuid:5fc5690d-6ad5-495c-a354-c112287529b3>\",\"Content-Length\":\"3642\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9914d8b6-6822-4870-9e6f-976264de5c78>\",\"WARC-Concurrent-To\":\"<urn:uuid:422149a3-b2c6-4d51-9bfc-c5aa3081e47b>\",\"WARC-IP-Address\":\"23.253.242.70\",\"WARC-Target-URI\":\"https://mail.haskell.org/pipermail/libraries/2005-March/003454.html\",\"WARC-Payload-Digest\":\"sha1:FAJQPVQUWP25LKBM4J2RLLHXDDHVFXL3\",\"WARC-Block-Digest\":\"sha1:NN3HGBWELM4VS6L7L3YK3ULWDQ3ACVA3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-05/CC-MAIN-2022-05_segments_1642320301263.50_warc_CC-MAIN-20220119033421-20220119063421-00521.warc.gz\"}"}