@@ -16,14 +16,13 @@ import Prelude
1616import Data.Either (Either (..), either )
1717import Data.Foldable (class Foldable , foldMap )
1818import Data.HeytingAlgebra (tt , ff )
19- import Data.Lens.Internal.Forget (Forget (..))
19+ import Data.Lens.Internal.Forget (Forget (..))
2020import Data.Lens.Types (Fold , Fold' ) as ExportTypes
2121import Data.Lens.Types (IndexedFold , Fold , Optic' , Indexed (..))
2222import Data.List (List (..), (:))
2323import Data.Maybe (Maybe (..), maybe )
2424import Data.Maybe.First (First (..))
2525import Data.Maybe.Last (Last (..))
26- import Data.Monoid (class Monoid , mempty )
2726import Data.Monoid.Additive (Additive (..))
2827import Data.Monoid.Conj (Conj (..))
2928import Data.Monoid.Disj (Disj (..))
@@ -47,18 +46,18 @@ infixl 8 previewOn as ^?
4746
4847-- | Folds all foci of a `Fold` to one. Note that this is the same as `view`.
4948foldOf :: forall s t a b . Fold a s t a b -> s -> a
50- foldOf p = foldMapOf p id
49+ foldOf p = foldMapOf p identity
5150
5251-- | Maps and then folds all foci of a `Fold`.
5352foldMapOf :: forall s t a b r . Fold r s t a b -> (a -> r ) -> s -> r
5453foldMapOf = under Forget
5554
5655-- | Right fold over a `Fold`.
57- foldrOf :: forall s t a b r . Fold (Endo r ) s t a b -> (a -> r -> r ) -> r -> s -> r
56+ foldrOf :: forall s t a b r . Fold (Endo ( -> ) r ) s t a b -> (a -> r -> r ) -> r -> s -> r
5857foldrOf p f r = flip unwrap r <<< foldMapOf p (Endo <<< f)
5958
6059-- | Left fold over a `Fold`.
61- foldlOf :: forall s t a b r . Fold (Dual (Endo r )) s t a b -> (r -> a -> r ) -> r -> s -> r
60+ foldlOf :: forall s t a b r . Fold (Dual (Endo ( -> ) r )) s t a b -> (r -> a -> r ) -> r -> s -> r
6261foldlOf p f r = flip unwrap r <<< unwrap <<< foldMapOf p (Dual <<< Endo <<< flip f)
6362
6463-- | Whether all foci of a `Fold` satisfy a predicate.
@@ -71,11 +70,11 @@ anyOf p f = unwrap <<< foldMapOf p (Disj <<< f)
7170
7271-- | The conjunction of all foci of a `Fold`.
7372andOf :: forall s t a b . HeytingAlgebra a => Fold (Conj a ) s t a b -> s -> a
74- andOf p = allOf p id
73+ andOf p = allOf p identity
7574
7675-- | The disjunction of all foci of a `Fold`.
7776orOf :: forall s t a b . HeytingAlgebra a => Fold (Disj a ) s t a b -> s -> a
78- orOf p = anyOf p id
77+ orOf p = anyOf p identity
7978
8079-- | Whether a `Fold` contains a given element.
8180elemOf :: forall s t a b . Eq a => Fold (Disj Boolean ) s t a b -> a -> s -> Boolean
@@ -106,25 +105,25 @@ lastOf :: forall s t a b. Fold (Last a) s t a b -> s -> Maybe a
106105lastOf p = unwrap <<< foldMapOf p (Last <<< Just )
107106
108107-- | The maximum of all foci of a `Fold`, if there is any.
109- maximumOf :: forall s t a b . Ord a => Fold (Endo (Maybe a )) s t a b -> s -> Maybe a
108+ maximumOf :: forall s t a b . Ord a => Fold (Endo (-> ) ( Maybe a )) s t a b -> s -> Maybe a
110109maximumOf p = foldrOf p (\a -> Just <<< maybe a (max a)) Nothing where
111110 max a b = if a > b then a else b
112111
113112-- | The minimum of all foci of a `Fold`, if there is any.
114- minimumOf :: forall s t a b . Ord a => Fold (Endo (Maybe a )) s t a b -> s -> Maybe a
113+ minimumOf :: forall s t a b . Ord a => Fold (Endo (-> ) ( Maybe a )) s t a b -> s -> Maybe a
115114minimumOf p = foldrOf p (\a -> Just <<< maybe a (min a)) Nothing where
116115 min a b = if a < b then a else b
117116
118117-- | Find the first focus of a `Fold` that satisfies a predicate, if there is any.
119- findOf :: forall s t a b . Fold (Endo (Maybe a )) s t a b -> (a -> Boolean ) -> s -> Maybe a
118+ findOf :: forall s t a b . Fold (Endo (-> ) ( Maybe a )) s t a b -> (a -> Boolean ) -> s -> Maybe a
120119findOf p f = foldrOf p (\a -> maybe (if f a then Just a else Nothing ) Just ) Nothing
121120
122121-- | Sequence the foci of a `Fold`, pulling out an `Applicative`, and ignore
123122-- | the result. If you need the result, see `sequenceOf` for `Traversal`s.
124123sequenceOf_
125124 :: forall f s t a b
126125 . Applicative f
127- => Fold (Endo (f Unit )) s t (f a ) b
126+ => Fold (Endo (-> ) ( f Unit )) s t (f a ) b
128127 -> s
129128 -> f Unit
130129sequenceOf_ p = flip unwrap (pure unit) <<< foldMapOf p \f -> Endo (f *> _)
@@ -133,18 +132,18 @@ sequenceOf_ p = flip unwrap (pure unit) <<< foldMapOf p \f -> Endo (f *> _)
133132traverseOf_
134133 :: forall f s t a b r
135134 . Applicative f
136- => Fold (Endo (f Unit )) s t a b
135+ => Fold (Endo (-> ) ( f Unit )) s t a b
137136 -> (a -> f r )
138137 -> s
139138 -> f Unit
140139traverseOf_ p f = foldrOf p (\a fu -> void (f a) *> fu) (pure unit)
141140
142141-- | Collects the foci of a `Fold` into a list.
143- toListOf :: forall s t a b . Fold (Endo (List a )) s t a b -> s -> List a
142+ toListOf :: forall s t a b . Fold (Endo (-> ) ( List a )) s t a b -> s -> List a
144143toListOf p = foldrOf p (:) Nil
145144
146145-- | Synonym for `toListOf`, reversed.
147- toListOfOn :: forall s t a b . s -> Fold (Endo (List a )) s t a b -> List a
146+ toListOfOn :: forall s t a b . s -> Fold (Endo (-> ) ( List a )) s t a b -> List a
148147toListOfOn s p = toListOf p s
149148
150149infixl 8 toListOfOn as ^..
@@ -163,7 +162,7 @@ filtered f =
163162 right >>>
164163 dimap
165164 (\x -> if f x then Right x else Left x)
166- (either id id )
165+ (either identity identity )
167166
168167-- | Replicates the elements of a fold.
169168replicated :: forall a b t r . Monoid r => Int -> Fold r a b a t
@@ -198,7 +197,7 @@ ifoldMapOf p f = unwrap $ p $ Indexed $ Forget (uncurry f)
198197-- | Right fold over an `IndexedFold`.
199198ifoldrOf
200199 :: forall i s t a b r
201- . IndexedFold (Endo r ) i s t a b
200+ . IndexedFold (Endo ( -> ) r ) i s t a b
202201 -> (i -> a -> r -> r )
203202 -> r
204203 -> s
@@ -208,7 +207,7 @@ ifoldrOf p f r = flip unwrap r <<< ifoldMapOf p (\i -> Endo <<< f i)
208207-- | Left fold over an `IndexedFold`.
209208ifoldlOf
210209 :: forall i s t a b r
211- . IndexedFold (Dual (Endo r )) i s t a b
210+ . IndexedFold (Dual (Endo ( -> ) r )) i s t a b
212211 -> (i -> r -> a -> r )
213212 -> r
214213 -> s
@@ -242,7 +241,7 @@ ianyOf p f = unwrap <<< ifoldMapOf p (\i -> Disj <<< f i)
242241-- | there is any.
243242ifindOf
244243 :: forall i s t a b
245- . IndexedFold (Endo (Maybe a )) i s t a b
244+ . IndexedFold (Endo (-> ) ( Maybe a )) i s t a b
246245 -> (i -> a -> Boolean )
247246 -> s
248247 -> Maybe a
@@ -255,15 +254,15 @@ ifindOf p f =
255254-- | Collects the foci of an `IndexedFold` into a list.
256255itoListOf
257256 :: forall i s t a b
258- . IndexedFold (Endo (List (Tuple i a ))) i s t a b
257+ . IndexedFold (Endo (-> ) ( List (Tuple i a ))) i s t a b
259258 -> s
260259 -> List (Tuple i a )
261260itoListOf p = ifoldrOf p (\i x xs -> Tuple i x : xs) Nil
262261
263262-- | Traverse the foci of an `IndexedFold`, discarding the results.
264263itraverseOf_
265264 :: forall i f s t a b r . (Applicative f )
266- => IndexedFold (Endo (f Unit )) i s t a b
265+ => IndexedFold (Endo (-> ) ( f Unit )) i s t a b
267266 -> (i -> a -> f r )
268267 -> s
269268 -> f Unit
@@ -272,7 +271,7 @@ itraverseOf_ p f = ifoldrOf p (\i a fu -> void (f i a) *> fu) (pure unit)
272271-- | Flipped version of `itraverseOf_`.
273272iforOf_
274273 :: forall i f s t a b r . (Applicative f )
275- => IndexedFold (Endo (f Unit )) i s t a b
274+ => IndexedFold (Endo (-> ) ( f Unit )) i s t a b
276275 -> s
277276 -> (i -> a -> f r )
278277 -> f Unit
0 commit comments