Skip to content

Commit

Permalink
Delete fmapCollect. It's a lie, and will infinitely loop.
Browse files Browse the repository at this point in the history
The implementation instantiates g rather than f, and is the same as
fmapCollect = fmap. Deriving fmap requires cotraverse, not collect.
  • Loading branch information
aaronvargo committed Jul 23, 2017
1 parent 02597df commit 1020655
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/Data/Distributive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module Data.Distributive
( Distributive(..)
, cotraverse
, comapM
, fmapCollect
) where

import Control.Applicative
Expand Down Expand Up @@ -241,11 +240,6 @@ instance Distributive Complex where
imagP (_ :+ i) = i
#endif

-- | 'fmapCollect' is a viable default definition for 'fmap' given
-- a 'Distributive' instance defined in terms of 'collect'.
fmapCollect :: forall f a b . Distributive f => (a -> b) -> f a -> f b
fmapCollect = coerce (collect :: (a -> Identity b) -> f a -> Identity (f b))

#if __GLASGOW_HASKELL__ >= 702
instance Distributive U1 where
distribute _ = U1
Expand Down

0 comments on commit 1020655

Please sign in to comment.