Skip to content

Commit

Permalink
Merge pull request #323 from lehins/const-fmap
Browse files Browse the repository at this point in the history
Fix fusion of `<$` operator
  • Loading branch information
Bodigrim authored Jun 27, 2020
2 parents c07b176 + 0676969 commit 6b8fcdf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Data/Vector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ instance Functor Vector where
{-# INLINE fmap #-}
fmap = map

{-# INLINE (<$) #-}
(<$) = map . const

instance Monad Vector where
{-# INLINE return #-}
return = Applicative.pure
Expand Down
2 changes: 2 additions & 0 deletions Data/Vector/Fusion/Bundle/Monadic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ drop n Bundle{sElems = s, sSize = sz} =
instance Monad m => Functor (Bundle m v) where
{-# INLINE fmap #-}
fmap = map
{-# INLINE (<$) #-}
(<$) = map . const

-- | Map a function over a 'Bundle'
map :: Monad m => (a -> b) -> Bundle m v a -> Bundle m v b
Expand Down
2 changes: 2 additions & 0 deletions Data/Vector/Fusion/Stream/Monadic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ instance Functor (Step s) where
fmap f (Yield x s) = Yield (f x) s
fmap _ (Skip s) = Skip s
fmap _ Done = Done
{-# INLINE (<$) #-}
(<$) = fmap . const

-- | Monadic streams
data Stream m a = forall s. Stream (s -> m (Step s a)) s
Expand Down

0 comments on commit 6b8fcdf

Please sign in to comment.