@@ -741,8 +741,8 @@ instance Semigroup (FromMaybe a) where
741
741
This is compatible with van Laarhoven optics as defined in the lens package.
742
742
Any Lens, Fold1 or Traversal1 will type-check as a `Handler1`.
743
743
-}
744
- type Handler1 a b =
745
- forall x . (b -> Const (Dual (FromMaybe x )) b ) -> a -> Const (Dual (FromMaybe x )) a
744
+ type Handler1 s a =
745
+ forall x . (a -> Const (Dual (FromMaybe x )) a ) -> s -> Const (Dual (FromMaybe x )) s
746
746
747
747
{-| @(handles t folder)@ transforms the input of a `Fold1` using a Lens,
748
748
Traversal1, or Fold1 optic:
@@ -765,13 +765,13 @@ type Handler1 a b =
765
765
>
766
766
> handles t (f <*> x) = handles t f <*> handles t x
767
767
-}
768
- handles :: forall a b r . Handler1 a b -> Fold1 b r -> Fold1 a r
768
+ handles :: forall s a r . Handler1 s a -> Fold1 a r -> Fold1 s r
769
769
handles k (Fold1_ begin step done) = Fold1_ begin' step' done
770
770
where
771
- begin' = stepAfromMaybe Nothing
772
- step' x = stepAfromMaybe (Just $! x)
773
- stepAfromMaybe = flip (appFromMaybe . getDual . getConst . k (Const . Dual . FromMaybe . flip stepBfromMaybe ))
774
- stepBfromMaybe = maybe begin step
771
+ begin' = stepSfromMaybe Nothing
772
+ step' x = stepSfromMaybe (Just $! x)
773
+ stepSfromMaybe = flip (appFromMaybe . getDual . getConst . k (Const . Dual . FromMaybe . flip stepAfromMaybe ))
774
+ stepAfromMaybe = maybe begin step
775
775
{-# INLINABLE handles #-}
776
776
777
777
{- | @(foldOver f folder xs)@ folds all values from a Lens, Traversal1 or Fold1 optic with the given folder
@@ -786,7 +786,7 @@ handles k (Fold1_ begin step done) = Fold1_ begin' step' done
786
786
> Foldl1.foldOver folded1 == Foldl1.fold1
787
787
788
788
-}
789
- foldOver :: Handler1 s a -> Fold1 a b -> s -> b
789
+ foldOver :: Handler1 s a -> Fold1 a r -> s -> r
790
790
foldOver l (Fold1_ begin step done) =
791
791
done . stepSfromMaybe Nothing
792
792
where
@@ -809,8 +809,8 @@ instance Monad m => Semigroup (FromMaybeM m a) where
809
809
This is compatible with van Laarhoven optics as defined in the lens package.
810
810
Any Lens, Fold1 or Traversal1 will type-check as a `HandlerM1`
811
811
-}
812
- type HandlerM1 m a b =
813
- forall x . (b -> Const (Dual (FromMaybeM m x )) b ) -> a -> Const (Dual (FromMaybeM m x )) a
812
+ type HandlerM1 m s a =
813
+ forall x . (a -> Const (Dual (FromMaybeM m x )) a ) -> s -> Const (Dual (FromMaybeM m x )) s
814
814
815
815
{-| @(handlesM t folder)@ transforms the input of a `FoldM1` using a Lens,
816
816
Traversal1 or Fold1 optic:
@@ -829,13 +829,13 @@ type HandlerM1 m a b =
829
829
>
830
830
> handlesM t (f <*> x) = handlesM t f <*> handlesM t x
831
831
-}
832
- handlesM :: Monad m => HandlerM1 m a b -> FoldM1 m b r -> FoldM1 m a r
832
+ handlesM :: Monad m => HandlerM1 m s a -> FoldM1 m a r -> FoldM1 m s r
833
833
handlesM k (FoldM1_ begin step done) = FoldM1_ begin' step' done
834
834
where
835
- begin' = stepMaybeA Nothing
836
- step' b = stepMaybeA (Just $! b)
837
- stepMaybeA = flip (appFromMaybeM . getDual . getConst . k (Const . Dual . FromMaybeM . flip stepMaybeB ))
838
- stepMaybeB = maybe begin step
835
+ begin' = stepMaybeS Nothing
836
+ step' b = stepMaybeS (Just $! b)
837
+ stepMaybeS = flip (appFromMaybeM . getDual . getConst . k (Const . Dual . FromMaybeM . flip stepMaybeA ))
838
+ stepMaybeA = maybe begin step
839
839
{-# INLINABLE handlesM #-}
840
840
841
841
{- | @(foldOverM f folder xs)@ folds all values from a Lens, Traversal1 or
@@ -846,8 +846,8 @@ handlesM k (FoldM1_ begin step done) = FoldM1_ begin' step' done
846
846
> Foldl1.foldOverM folded1 == Foldl1.foldM1
847
847
848
848
-}
849
- foldOverM :: Monad m => HandlerM1 m s a -> FoldM1 m a b -> s -> m b
850
- foldOverM l (FoldM1_ ( begin :: a -> m x ) ( step :: x -> a -> m x ) ( done :: x -> m b ) ) s = do
849
+ foldOverM :: Monad m => HandlerM1 m s a -> FoldM1 m a r -> s -> m r
850
+ foldOverM l (FoldM1_ begin step done) s = do
851
851
r <- stepMaybeS Nothing s
852
852
done r
853
853
where
0 commit comments