11{-# LANGUAGE CPP #-}
2+ {-# LANGUAGE DeriveFunctor #-}
23{-# LANGUAGE FlexibleInstances #-}
34{-# LANGUAGE FunctionalDependencies #-}
45{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -19,6 +20,7 @@ import qualified Prelude as Prelude
1920
2021import Control.Applicative (ZipList (.. ), pure , (<$>) )
2122import Data.Bifunctor (Bifunctor (.. ))
23+ import Data.Biapplicative (Biapplicative (.. ), traverseBia )
2224import Data.Functor.Compose (Compose (.. ))
2325import Data.Functor.Identity (Identity (.. ))
2426import Data.Functor.Product (Product (.. ))
@@ -577,6 +579,17 @@ instance (Ord k) => Align (Map k) where
577579instance Ord k => Unalign (Map k ) where
578580 unalign xs = (Map. mapMaybe justHere xs, Map. mapMaybe justThere xs)
579581
582+ -- A copy of (,) with a stricter bimap.
583+ newtype SBPair a b = SBPair { unSBPair :: (a , b ) }
584+
585+ instance Bifunctor SBPair where
586+ bimap f g (SBPair (a, b)) = SBPair (f a, g b)
587+
588+ instance Biapplicative SBPair where
589+ bipure a b = SBPair (a, b)
590+ biliftA2 f g (SBPair (a, b)) (SBPair (c, d)) =
591+ SBPair (f a c, g b d)
592+
580593instance Ord k => Unzip (Map k ) where unzip = unzipDefault
581594
582595instance Ord k => Zip (Map k ) where
0 commit comments