@@ -417,6 +417,7 @@ where
418#include "inline.hs"
418#include "inline.hs"
420+import Control.Applicative (liftA2)
420import Control.Monad ((>=>))
421import Control.Monad ((>=>))
421import Data.Bifunctor (Bifunctor(..))
422import Data.Bifunctor (Bifunctor(..))
422import Data.Either (fromLeft, fromRight, isLeft, isRight)
423import Data.Either (fromLeft, fromRight, isLeft, isRight)
@@ -846,6 +847,21 @@ split_ (Fold stepL initialL _) (Fold stepR initialR extractR) =
846 Partial sR -> extractR sR
847 Partial sR -> extractR sR
847 Done rR -> return rR
848 Done rR -> return rR
850+-- | 'Applicative' form of 'splitWith'. Split the input serially over two
852+instance Monad m => Applicative (Fold m a) where
856+ {-# INLINE (<*>) #-}
857+ (<*>) = splitWith id
862+ {-# INLINE liftA2 #-}
863+ liftA2 f x = (<*>) (fmap f x)
849{-# ANN type TeeState Fuse #-}
865{-# ANN type TeeState Fuse #-}
850data TeeState sL sR bL bR
866data TeeState sL sR bL bR
851 = TeeBoth !sL !sR
867 = TeeBoth !sL !sR