Skip to content

Commit a902c0c

Browse files
committed
Rename type variables of optics according to s t a b scheme
1 parent b54c7e9 commit a902c0c

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/Control/Foldl.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,8 @@ dropM n (FoldM step begin done) = FoldM step' begin' done'
13501350
13511351
Any lens, traversal, or prism will type-check as a `Handler`
13521352
-}
1353-
type Handler a b =
1354-
forall x . (b -> Const (Dual (Endo x)) b) -> a -> Const (Dual (Endo x)) a
1353+
type Handler s a =
1354+
forall x . (a -> Const (Dual (Endo x)) a) -> s -> Const (Dual (Endo x)) s
13551355

13561356
{-| @(handles t folder)@ transforms the input of a `Fold` using a lens,
13571357
traversal, or prism:
@@ -1381,7 +1381,7 @@ type Handler a b =
13811381
>
13821382
> handles t (f <*> x) = handles t f <*> handles t x
13831383
-}
1384-
handles :: Handler a b -> Fold b r -> Fold a r
1384+
handles :: Handler s a -> Fold a r -> Fold s r
13851385
handles k (Fold step begin done) = Fold step' begin done
13861386
where
13871387
step' = flip (appEndo . getDual . getConst . k (Const . Dual . Endo . flip step))
@@ -1402,7 +1402,7 @@ handles k (Fold step begin done) = Fold step' begin done
14021402
> Foldl.foldOver folded == Foldl.fold
14031403
14041404
-}
1405-
foldOver :: Handler s a -> Fold a b -> s -> b
1405+
foldOver :: Handler s a -> Fold a r -> s -> r
14061406
foldOver l (Fold step begin done) =
14071407
done . flip appEndo begin . getDual . getConst . l (Const . Dual . Endo . flip step)
14081408
{-# INLINABLE foldOver #-}
@@ -1432,8 +1432,8 @@ instance Monad m => Monoid (EndoM m a) where
14321432
14331433
Any lens, traversal, or prism will type-check as a `HandlerM`
14341434
-}
1435-
type HandlerM m a b =
1436-
forall x . (b -> Const (Dual (EndoM m x)) b) -> a -> Const (Dual (EndoM m x)) a
1435+
type HandlerM m s a =
1436+
forall x . (a -> Const (Dual (EndoM m x)) a) -> s -> Const (Dual (EndoM m x)) s
14371437

14381438
{-| @(handlesM t folder)@ transforms the input of a `FoldM` using a lens,
14391439
traversal, or prism:
@@ -1453,7 +1453,7 @@ type HandlerM m a b =
14531453
>
14541454
> handlesM t (f <*> x) = handlesM t f <*> handlesM t x
14551455
-}
1456-
handlesM :: HandlerM m a b -> FoldM m b r -> FoldM m a r
1456+
handlesM :: HandlerM m s a -> FoldM m a r -> FoldM m s r
14571457
handlesM k (FoldM step begin done) = FoldM step' begin done
14581458
where
14591459
step' = flip (appEndoM . getDual . getConst . k (Const . Dual . EndoM . flip step))
@@ -1466,7 +1466,7 @@ handlesM k (FoldM step begin done) = FoldM step' begin done
14661466
> Foldl.foldOverM folded == Foldl.foldM
14671467
14681468
-}
1469-
foldOverM :: Monad m => HandlerM m s a -> FoldM m a b -> s -> m b
1469+
foldOverM :: Monad m => HandlerM m s a -> FoldM m a r -> s -> m r
14701470
foldOverM l (FoldM step begin done) s = do
14711471
b <- begin
14721472
r <- (flip appEndoM b . getDual . getConst . l (Const . Dual . EndoM . flip step)) s

src/Control/Foldl/NonEmpty.hs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,8 @@ instance Semigroup (FromMaybe a) where
741741
This is compatible with van Laarhoven optics as defined in the lens package.
742742
Any Lens, Fold1 or Traversal1 will type-check as a `Handler1`.
743743
-}
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
746746

747747
{-| @(handles t folder)@ transforms the input of a `Fold1` using a Lens,
748748
Traversal1, or Fold1 optic:
@@ -765,13 +765,13 @@ type Handler1 a b =
765765
>
766766
> handles t (f <*> x) = handles t f <*> handles t x
767767
-}
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
769769
handles k (Fold1_ begin step done) = Fold1_ begin' step' done
770770
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
775775
{-# INLINABLE handles #-}
776776

777777
{- | @(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
786786
> Foldl1.foldOver folded1 == Foldl1.fold1
787787
788788
-}
789-
foldOver :: Handler1 s a -> Fold1 a b -> s -> b
789+
foldOver :: Handler1 s a -> Fold1 a r -> s -> r
790790
foldOver l (Fold1_ begin step done) =
791791
done . stepSfromMaybe Nothing
792792
where
@@ -809,8 +809,8 @@ instance Monad m => Semigroup (FromMaybeM m a) where
809809
This is compatible with van Laarhoven optics as defined in the lens package.
810810
Any Lens, Fold1 or Traversal1 will type-check as a `HandlerM1`
811811
-}
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
814814

815815
{-| @(handlesM t folder)@ transforms the input of a `FoldM1` using a Lens,
816816
Traversal1 or Fold1 optic:
@@ -829,13 +829,13 @@ type HandlerM1 m a b =
829829
>
830830
> handlesM t (f <*> x) = handlesM t f <*> handlesM t x
831831
-}
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
833833
handlesM k (FoldM1_ begin step done) = FoldM1_ begin' step' done
834834
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
839839
{-# INLINABLE handlesM #-}
840840

841841
{- | @(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
846846
> Foldl1.foldOverM folded1 == Foldl1.foldM1
847847
848848
-}
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
851851
r <- stepMaybeS Nothing s
852852
done r
853853
where

0 commit comments

Comments
 (0)