Skip to content

Commit 6ffde94

Browse files
committed
Rename type variables of optics according to s t a b scheme
1 parent f553e2a commit 6ffde94

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
@@ -737,8 +737,8 @@ instance Semigroup (FromMaybe a) where
737737
This is compatible with van Laarhoven optics as defined in the lens package.
738738
Any Lens, Fold1 or Traversal1 will type-check as a `Handler1`.
739739
-}
740-
type Handler1 a b =
741-
forall x. (b -> Const (Dual (FromMaybe x)) b) -> a -> Const (Dual (FromMaybe x)) a
740+
type Handler1 s a =
741+
forall x. (a -> Const (Dual (FromMaybe x)) a) -> s -> Const (Dual (FromMaybe x)) s
742742

743743
{-| @(handles t folder)@ transforms the input of a `Fold1` using a Lens,
744744
Traversal1, or Fold1 optic:
@@ -761,13 +761,13 @@ type Handler1 a b =
761761
>
762762
> handles t (f <*> x) = handles t f <*> handles t x
763763
-}
764-
handles :: forall a b r. Handler1 a b -> Fold1 b r -> Fold1 a r
764+
handles :: forall s a r. Handler1 s a -> Fold1 a r -> Fold1 s r
765765
handles k (Fold1_ begin step done) = Fold1_ begin' step' done
766766
where
767-
begin' = stepAfromMaybe Nothing
768-
step' x = stepAfromMaybe (Just $! x)
769-
stepAfromMaybe = flip (appFromMaybe . getDual . getConst . k (Const . Dual . FromMaybe . flip stepBfromMaybe))
770-
stepBfromMaybe = maybe begin step
767+
begin' = stepSfromMaybe Nothing
768+
step' x = stepSfromMaybe (Just $! x)
769+
stepSfromMaybe = flip (appFromMaybe . getDual . getConst . k (Const . Dual . FromMaybe . flip stepAfromMaybe))
770+
stepAfromMaybe = maybe begin step
771771
{-# INLINABLE handles #-}
772772

773773
{- | @(foldOver f folder xs)@ folds all values from a Lens, Traversal1 or Fold1 optic with the given folder
@@ -782,7 +782,7 @@ handles k (Fold1_ begin step done) = Fold1_ begin' step' done
782782
> Foldl1.foldOver folded1 == Foldl1.fold1
783783
784784
-}
785-
foldOver :: Handler1 s a -> Fold1 a b -> s -> b
785+
foldOver :: Handler1 s a -> Fold1 a r -> s -> r
786786
foldOver l (Fold1_ begin step done) =
787787
done . stepSfromMaybe Nothing
788788
where
@@ -805,8 +805,8 @@ instance Monad m => Semigroup (FromMaybeM m a) where
805805
This is compatible with van Laarhoven optics as defined in the lens package.
806806
Any Lens, Fold1 or Traversal1 will type-check as a `HandlerM1`
807807
-}
808-
type HandlerM1 m a b =
809-
forall x . (b -> Const (Dual (FromMaybeM m x)) b) -> a -> Const (Dual (FromMaybeM m x)) a
808+
type HandlerM1 m s a =
809+
forall x . (a -> Const (Dual (FromMaybeM m x)) a) -> s -> Const (Dual (FromMaybeM m x)) s
810810

811811
{-| @(handlesM t folder)@ transforms the input of a `FoldM1` using a Lens,
812812
Traversal1 or Fold1 optic:
@@ -825,13 +825,13 @@ type HandlerM1 m a b =
825825
>
826826
> handlesM t (f <*> x) = handlesM t f <*> handlesM t x
827827
-}
828-
handlesM :: Monad m => HandlerM1 m a b -> FoldM1 m b r -> FoldM1 m a r
828+
handlesM :: Monad m => HandlerM1 m s a -> FoldM1 m a r -> FoldM1 m s r
829829
handlesM k (FoldM1_ begin step done) = FoldM1_ begin' step' done
830830
where
831-
begin' = stepMaybeA Nothing
832-
step' b = stepMaybeA (Just $! b)
833-
stepMaybeA = flip (appFromMaybeM . getDual . getConst . k (Const . Dual . FromMaybeM . flip stepMaybeB))
834-
stepMaybeB = maybe begin step
831+
begin' = stepMaybeS Nothing
832+
step' b = stepMaybeS (Just $! b)
833+
stepMaybeS = flip (appFromMaybeM . getDual . getConst . k (Const . Dual . FromMaybeM . flip stepMaybeA))
834+
stepMaybeA = maybe begin step
835835
{-# INLINABLE handlesM #-}
836836

837837
{- | @(foldOverM f folder xs)@ folds all values from a Lens, Traversal1 or
@@ -842,8 +842,8 @@ handlesM k (FoldM1_ begin step done) = FoldM1_ begin' step' done
842842
> Foldl1.foldOverM folded1 == Foldl1.foldM1
843843
844844
-}
845-
foldOverM :: Monad m => HandlerM1 m s a -> FoldM1 m a b -> s -> m b
846-
foldOverM l (FoldM1_ (begin :: a -> m x) (step :: x -> a -> m x) (done :: x -> m b)) s = do
845+
foldOverM :: Monad m => HandlerM1 m s a -> FoldM1 m a r -> s -> m r
846+
foldOverM l (FoldM1_ begin step done) s = do
847847
r <- stepMaybeS Nothing s
848848
done r
849849
where

0 commit comments

Comments
 (0)