@@ -50,7 +50,7 @@ final class NestedFoldableOps[F[_], G[_], A](private val fga: F[G[A]]) extends A
50
50
*
51
51
* Example:
52
52
* {{{
53
- * scala> import cats.implicits ._
53
+ * scala> import cats.syntax.all ._
54
54
*
55
55
* scala> val l: List[Set[Int]] = List(Set(1, 2), Set(2, 3), Set(3, 4))
56
56
* scala> l.foldK
@@ -70,29 +70,15 @@ final class FoldableOps[F[_], A](private val fa: F[A]) extends AnyVal {
70
70
def foldA [G [_], B ](implicit F : Foldable [F ], ev : A <:< G [B ], G : Applicative [G ], B : Monoid [B ]): G [B ] =
71
71
F .foldA[G , B ](fa.asInstanceOf [F [G [B ]]])
72
72
73
- /**
74
- * test if `F[A]` contains an `A`, named contains_ to avoid conflict with existing contains which uses universal equality
75
- *
76
- * Example:
77
- * {{{
78
- * scala> import cats.implicits._
79
- *
80
- * scala> val l: List[Int] = List(1, 2, 3, 4)
81
- * scala> l.contains_(1)
82
- * res0: Boolean = true
83
- * scala> l.contains_(5)
84
- * res1: Boolean = false
85
- * }}}
86
- */
87
- def contains_ (v : A )(implicit ev : Eq [A ], F : Foldable [F ]): Boolean =
88
- F .exists(fa)(ev.eqv(_, v))
73
+ private [syntax] def contains_ (v : A , eq : Eq [A ], F : Foldable [F ]): Boolean =
74
+ F .contains_(fa, v)(eq)
89
75
90
76
/**
91
77
* Intercalate with a prefix and a suffix
92
78
*
93
79
* Example:
94
80
* {{{
95
- * scala> import cats.implicits ._
81
+ * scala> import cats.syntax.all ._
96
82
*
97
83
* scala> val l: List[String] = List("1", "2", "3")
98
84
* scala> l.foldSmash("List(", ",", ")")
@@ -109,7 +95,7 @@ final class FoldableOps[F[_], A](private val fa: F[A]) extends AnyVal {
109
95
*
110
96
* Example:
111
97
* {{{
112
- * scala> import cats.implicits ._
98
+ * scala> import cats.syntax.all ._
113
99
*
114
100
* scala> val l: List[Int] = List(1, 2, 3)
115
101
* scala> l.mkString_("L[", ";", "]")
@@ -139,7 +125,7 @@ final class FoldableOps[F[_], A](private val fa: F[A]) extends AnyVal {
139
125
*
140
126
* For example:
141
127
* {{{
142
- * scala> import cats.implicits ._
128
+ * scala> import cats.syntax.all ._
143
129
* scala> def parseInt(s: String): Either[String, Int] = Either.catchOnly[NumberFormatException](s.toInt).leftMap(_.getMessage)
144
130
* scala> val keys1 = List("1", "2", "4", "5")
145
131
* scala> val map1 = Map(4 -> "Four", 5 -> "Five")
@@ -170,7 +156,7 @@ final class FoldableOps[F[_], A](private val fa: F[A]) extends AnyVal {
170
156
*
171
157
* For example:
172
158
* {{{
173
- * scala> import cats.implicits ._
159
+ * scala> import cats.syntax.all ._
174
160
* scala> val list = List(1,2,3,4)
175
161
* scala> list.findM(n => (n >= 2).asRight[String])
176
162
* res0: Either[String,Option[Int]] = Right(Some(2))
@@ -185,31 +171,34 @@ final class FoldableOps[F[_], A](private val fa: F[A]) extends AnyVal {
185
171
* res3: Either[String,Option[Int]] = Left(error)
186
172
* }}}
187
173
*/
188
- def findM [G [_]](p : A => G [Boolean ])(implicit F : Foldable [F ], G : Monad [G ]): G [Option [A ]] = F .findM[G , A ](fa)(p)
174
+ def findM [G [_]](p : A => G [Boolean ])(implicit F : Foldable [F ], G : Monad [G ]): G [Option [A ]] =
175
+ F .findM[G , A ](fa)(p)
189
176
190
177
/**
191
178
* Tear down a subset of this structure using a `PartialFunction`.
192
179
* {{{
193
- * scala> import cats.implicits ._
180
+ * scala> import cats.syntax.all ._
194
181
* scala> val xs = List(1, 2, 3, 4)
195
182
* scala> xs.collectFold { case n if n % 2 == 0 => n }
196
183
* res0: Int = 6
197
184
* }}}
198
185
*/
199
- def collectFold [M ](f : PartialFunction [A , M ])(implicit F : Foldable [F ], M : Monoid [M ]): M = F .collectFold[A , M ](fa)(f)
186
+ def collectFold [M ](f : PartialFunction [A , M ])(implicit F : Foldable [F ], M : Monoid [M ]): M =
187
+ F .collectFold[A , M ](fa)(f)
200
188
201
189
/**
202
190
* Tear down a subset of this structure using a `A => Option[M]`.
203
191
* {{{
204
- * scala> import cats.implicits ._
192
+ * scala> import cats.syntax.all ._
205
193
* scala> val xs = List(1, 2, 3, 4)
206
194
* scala> def f(n: Int): Option[Int] = if (n % 2 == 0) Some(n) else None
207
195
* scala> xs.collectFoldSome(f)
208
196
* res0: Int = 6
209
197
* }}}
210
198
*/
211
199
@ deprecated(" Use collectFoldSome" , " 2.1.0-RC1" )
212
- def collectSomeFold [M ](f : A => Option [M ])(implicit F : Foldable [F ], M : Monoid [M ]): M = F .collectFoldSome[A , M ](fa)(f)
200
+ def collectSomeFold [M ](f : A => Option [M ])(implicit F : Foldable [F ], M : Monoid [M ]): M =
201
+ F .collectFoldSome[A , M ](fa)(f)
213
202
}
214
203
215
204
final class FoldableOps0 [F [_], A ](private val fa : F [A ]) extends AnyVal {
@@ -221,7 +210,7 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
221
210
*
222
211
* Example:
223
212
* {{{
224
- * scala> import cats.implicits ._
213
+ * scala> import cats.syntax.all ._
225
214
*
226
215
* scala> val l: List[Int] = List(1, 2, 3)
227
216
* scala> l.mkString_(",")
@@ -239,21 +228,22 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
239
228
* combining them using the `MonoidK[G]` instance.
240
229
*
241
230
* {{{
242
- * scala> import cats._, cats.implicits ._
231
+ * scala> import cats._, cats.syntax.all ._
243
232
* scala> val f: Int => Endo[String] = i => (s => s + i)
244
233
* scala> val x: Endo[String] = List(1, 2, 3).foldMapK(f)
245
234
* scala> val a = x("foo")
246
235
* a: String = "foo321"
247
236
* }}}
248
237
*/
249
- def foldMapK [G [_], B ](f : A => G [B ])(implicit F : Foldable [F ], G : MonoidK [G ]): G [B ] = F .foldMapK(fa)(f)
238
+ def foldMapK [G [_], B ](f : A => G [B ])(implicit F : Foldable [F ], G : MonoidK [G ]): G [B ] =
239
+ F .foldMapK(fa)(f)
250
240
251
241
/**
252
242
* Separate this Foldable into a Tuple by an effectful separating function `A => H[B, C]` for some `Bifoldable[H]`
253
243
* Equivalent to `Functor#map` over `Alternative#separate`
254
244
*
255
245
* {{{
256
- * scala> import cats.implicits ._, cats.data.Const
246
+ * scala> import cats.syntax.all ._, cats.data.Const
257
247
* scala> val list = List(1,2,3,4)
258
248
* scala> list.partitionBifold(a => (a, "value " + a.toString))
259
249
* res0: (List[Int], List[String]) = (List(1, 2, 3, 4),List(value 1, value 2, value 3, value 4))
@@ -272,7 +262,7 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
272
262
* Equivalent to `Traverse#traverse` over `Alternative#separate`
273
263
*
274
264
* {{{
275
- * scala> import cats.implicits ._, cats.data.Const
265
+ * scala> import cats.syntax.all ._, cats.data.Const
276
266
* scala> val list = List(1,2,3,4)
277
267
* `Const`'s second parameter is never instantiated, so we can use an impossible type:
278
268
* scala> list.partitionBifoldM(a => Option(Const[Int, Nothing with Any](a)))
@@ -289,7 +279,7 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
289
279
* Equivalent to `Traverse#traverse` over `Alternative#separate`
290
280
*
291
281
* {{{
292
- * scala> import cats.implicits ._, cats.Eval
282
+ * scala> import cats.syntax.all ._, cats.Eval
293
283
* scala> val list = List(1,2,3,4)
294
284
* scala> val partitioned1 = list.partitionEitherM(a => if (a % 2 == 0) Eval.now(Either.left[String, Int](a.toString)) else Eval.now(Either.right[String, Int](a)))
295
285
* Since `Eval.now` yields a lazy computation, we need to force it to inspect the result:
@@ -305,23 +295,40 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
305
295
)(implicit A : Alternative [F ], F : Foldable [F ], M : Monad [G ]): G [(F [B ], F [C ])] =
306
296
F .partitionEitherM[G , A , B , C ](fa)(f)(A , M )
307
297
308
- def sliding2 (implicit F : Foldable [F ]): List [(A , A )] = F .sliding2(fa)
309
- def sliding3 (implicit F : Foldable [F ]): List [(A , A , A )] = F .sliding3(fa)
310
- def sliding4 (implicit F : Foldable [F ]): List [(A , A , A , A )] = F .sliding4(fa)
311
- def sliding5 (implicit F : Foldable [F ]): List [(A , A , A , A , A )] = F .sliding5(fa)
312
- def sliding6 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A )] = F .sliding6(fa)
313
- def sliding7 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A )] = F .sliding7(fa)
314
- def sliding8 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A )] = F .sliding8(fa)
315
- def sliding9 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A )] = F .sliding9(fa)
316
- def sliding10 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A )] = F .sliding10(fa)
317
- def sliding11 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A )] = F .sliding11(fa)
318
- def sliding12 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A )] = F .sliding12(fa)
319
- def sliding13 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A )] = F .sliding13(fa)
320
- def sliding14 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A )] = F .sliding14(fa)
321
- def sliding15 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] = F .sliding15(fa)
322
- def sliding16 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] = F .sliding16(fa)
323
- def sliding17 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] = F .sliding17(fa)
324
- def sliding18 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] = F .sliding18(fa)
298
+ def sliding2 (implicit F : Foldable [F ]): List [(A , A )] =
299
+ F .sliding2(fa)
300
+ def sliding3 (implicit F : Foldable [F ]): List [(A , A , A )] =
301
+ F .sliding3(fa)
302
+ def sliding4 (implicit F : Foldable [F ]): List [(A , A , A , A )] =
303
+ F .sliding4(fa)
304
+ def sliding5 (implicit F : Foldable [F ]): List [(A , A , A , A , A )] =
305
+ F .sliding5(fa)
306
+ def sliding6 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A )] =
307
+ F .sliding6(fa)
308
+ def sliding7 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A )] =
309
+ F .sliding7(fa)
310
+ def sliding8 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A )] =
311
+ F .sliding8(fa)
312
+ def sliding9 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A )] =
313
+ F .sliding9(fa)
314
+ def sliding10 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A )] =
315
+ F .sliding10(fa)
316
+ def sliding11 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A )] =
317
+ F .sliding11(fa)
318
+ def sliding12 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A )] =
319
+ F .sliding12(fa)
320
+ def sliding13 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A )] =
321
+ F .sliding13(fa)
322
+ def sliding14 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A )] =
323
+ F .sliding14(fa)
324
+ def sliding15 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] =
325
+ F .sliding15(fa)
326
+ def sliding16 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] =
327
+ F .sliding16(fa)
328
+ def sliding17 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] =
329
+ F .sliding17(fa)
330
+ def sliding18 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] =
331
+ F .sliding18(fa)
325
332
def sliding19 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] =
326
333
F .sliding19(fa)
327
334
def sliding20 (implicit F : Foldable [F ]): List [(A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A , A )] =
0 commit comments