Skip to content

Commit e1674d4

Browse files
torgeirshchessai
authored andcommitted
Add Bifoldable and Bitraverse instances for Of (#92)
* Add Bifoldable and Bitraverse instances for Of
1 parent 4265e12 commit e1674d4

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
- 0.2.4.0
2+
3+
Bifoldable and Bitraversable instances for Of.
4+
15
- 0.2.3.0
26
Add `wrapEffect`.
37

src/Data/Functor/Of.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import Data.Functor.Classes
1313
import Data.Foldable (Foldable)
1414
import Data.Traversable (Traversable)
1515
#endif
16+
#if MIN_VERSION_base(4,10,0)
17+
import Data.Bifoldable (Bifoldable, bifoldMap)
18+
import Data.Bitraversable (Bitraversable, bitraverse)
19+
#endif
1620
import GHC.Generics (Generic, Generic1)
1721

1822
-- | A left-strict pair; the base functor for streams of individual elements.
@@ -49,6 +53,18 @@ instance Bifunctor Of where
4953
{-#INLINE second #-}
5054
#endif
5155

56+
#if MIN_VERSION_base(4,10,0)
57+
-- | @since 0.2.4.0
58+
instance Bifoldable Of where
59+
bifoldMap f g (a :> b) = f a `mappend` g b
60+
{-#INLINE bifoldMap #-}
61+
62+
-- | @since 0.2.4.0
63+
instance Bitraversable Of where
64+
bitraverse f g (a :> b) = (:>) <$> f a <*> g b
65+
{-#INLINE bitraverse #-}
66+
#endif
67+
5268
instance Monoid a => Applicative (Of a) where
5369
pure x = mempty :> x
5470
{-#INLINE pure #-}

0 commit comments

Comments
 (0)