Releases: kevin-lee/extras
v0.44.0
0.44.0 - 2023-11-05
New Features
- [
extras-string
] Addextras.strings.syntax.all
to have allstrings
syntax (#441)import extras.strings.syntax.all._
- [
extras-string
] Add case conversion -string.toPascalCase
(#443)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toPascalCase // Abc
"AbcDefGhi".toPascalCase // AbcDefGhi
"abcDefGhi".toPascalCase // AbcDefGhi
"abc".toPascalCase // Abc
"ABC".toPascalCase // Abc
"abc_def_ghi".toPascalCase // AbcDefGhi
"abc-def-ghi".toPascalCase // AbcDefGhi
"abc def ghi".toPascalCase // AbcDefGhi
- [
extras-string
] Add case conversion -string.toOnePascalCase
(#455)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toOnePascalCase // Abc
"AbcDef".toOnePascalCase // Abcdef
"abcDef".toOnePascalCase // Abcdef
"abc".toOnePascalCase // Abc
"ABC".toOnePascalCase // Abc
- [
extras-string
] Add case conversion -string.toCamelCase
(#444)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toCamelCase // abc
"AbcDefGhi".toCamelCase // abcDefGhi
"abcDefGhi".toCamelCase // abcDefGhi
"abc".toCamelCase // abc
"ABC".toCamelCase // abc
"abc_def_ghi".toCamelCase // abcDefGhi
"abc-def-ghi".toCamelCase // abcDefGhi
"abc def ghi".toCamelCase // abcDefGhi
- [
extras-string
] Add case conversion -string.toSnakeCase
(#445)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toSnakeCase // Abc
"AbcDefGhi".toSnakeCase // Abc_Def_Ghi
"abcDefGhi".toSnakeCase // abc_Def_Ghi
"abc".toSnakeCase // abc
"ABC".toSnakeCase // ABC
"Abc_Def_Ghi".toSnakeCase // Abc_Def_Ghi
"abc_def_ghi".toSnakeCase // abc_def_ghi
"ABC_DEF_GHI".toSnakeCase // ABC_DEF_GHI
"abc-def-ghi".toSnakeCase // abc_def_ghi
"Abc-Def-Ghi".toSnakeCase // Abc_Def_Ghi
"ABC-DEF-GHI".toSnakeCase // ABC_DEF_GHI
"abc def ghi".toSnakeCase // abc_def_ghi
"Abc Def Ghi".toSnakeCase // Abc_Def_Ghi
"ABC DEF GHI".toSnakeCase // ABC_DEF_GHI
- [
extras-string
] Add case conversion -string.toSnakeUpperCase
(#465)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toSnakeUpperCase // ABC
"AbcDefGhi".toSnakeUpperCase // ABC_DEF_GHI
"abcDefGhi".toSnakeUpperCase // ABC_DEF_GHI
"abc".toSnakeUpperCase // ABC
"ABC".toSnakeUpperCase // ABC
"Abc_Def_Ghi".toSnakeUpperCase // ABC_DEF_GHI
"abc_def_ghi".toSnakeUpperCase // ABC_DEF_GHI
"ABC_DEF_GHI".toSnakeUpperCase // ABC_DEF_GHI
"abc-def-ghi".toSnakeUpperCase // ABC_DEF_GHI
"Abc-Def-Ghi".toSnakeUpperCase // ABC_DEF_GHI
"ABC-DEF-GHI".toSnakeUpperCase // ABC_DEF_GHI
"abc def ghi".toSnakeUpperCase // ABC_DEF_GHI
"Abc Def Ghi".toSnakeUpperCase // ABC_DEF_GHI
"ABC DEF GHI".toSnakeUpperCase // ABC_DEF_GHI
- [
extras-string
] Add case conversion -string.toSnakeLowerCase
(#466)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toSnakeLowerCase // abc
"AbcDefGhi".toSnakeLowerCase // abc_def_ghi
"abcDefGhi".toSnakeLowerCase // abc_def_ghi
"abc".toSnakeLowerCase // abc
"ABC".toSnakeLowerCase // abc
"Abc_Def_Ghi".toSnakeLowerCase // abc_def_ghi
"abc_def_ghi".toSnakeLowerCase // abc_def_ghi
"ABC_DEF_GHI".toSnakeLowerCase // abc_def_ghi
"abc-def-ghi".toSnakeLowerCase // abc_def_ghi
"Abc-Def-Ghi".toSnakeLowerCase // abc_def_ghi
"ABC-DEF-GHI".toSnakeLowerCase // abc_def_ghi
"abc def ghi".toSnakeLowerCase // abc_def_ghi
"Abc Def Ghi".toSnakeLowerCase // abc_def_ghi
"ABC DEF GHI".toSnakeLowerCase // abc_def_ghi
- [
extras-string
] Add case conversion -string.toKebabCase
(#446)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toKebabCase // Abc
"AbcDefGhi".toKebabCase // Abc-Def-Ghi
"abcDefGhi".toKebabCase // abc-Def-Ghi
"abc".toKebabCase // abc
"ABC".toKebabCase // ABC
"Abc_Def_Ghi".toKebabCase // Abc-Def-Ghi
"abc_def_ghi".toKebabCase // abc-def-ghi
"ABC_DEF_GHI".toKebabCase // ABC-DEF-GHI
"abc-def-ghi".toKebabCase // abc-def-ghi
"Abc-Def-Ghi".toKebabCase // Abc-Def-Ghi
"ABC-DEF-GHI".toKebabCase // ABC-DEF-GHI
"abc def ghi".toKebabCase // abc-def-ghi
"Abc Def Ghi".toKebabCase // Abc-Def-Ghi
"ABC DEF GHI".toKebabCase // ABC-DEF-GHI
- [
extras-string
] Add case conversion -string.toKebabUpperCase
(#467)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toKebabUpperCase // ABC
"AbcDefGhi".toKebabUpperCase // ABC-DEF-GHI
"abcDefGhi".toKebabUpperCase // ABC-DEF-GHI
"abc".toKebabUpperCase // ABC
"ABC".toKebabUpperCase // ABC
"Abc_Def_Ghi".toKebabUpperCase // ABC-DEF-GHI
"abc_def_ghi".toKebabUpperCase // ABC-DEF-GHI
"ABC_DEF_GHI".toKebabUpperCase // ABC-DEF-GHI
"abc-def-ghi".toKebabUpperCase // ABC-DEF-GHI
"Abc-Def-Ghi".toKebabUpperCase // ABC-DEF-GHI
"ABC-DEF-GHI".toKebabUpperCase // ABC-DEF-GHI
"abc def ghi".toKebabUpperCase // ABC-DEF-GHI
"Abc Def Ghi".toKebabUpperCase // ABC-DEF-GHI
"ABC DEF GHI".toKebabUpperCase // ABC-DEF-GHI
- [
extras-string
] Add case conversion -string.toKebabLowerCase
(#468)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
"Abc".toKebabLowerCase // abc
"AbcDefGhi".toKebabLowerCase // abc-def-ghi
"abcDefGhi".toKebabLowerCase // abc-def-ghi
"abc".toKebabLowerCase // abc
"ABC".toKebabLowerCase // abc
"Abc_Def_Ghi".toKebabLowerCase // abc-def-ghi
"abc_def_ghi".toKebabLowerCase // abc-def-ghi
"ABC_DEF_GHI".toKebabLowerCase // abc-def-ghi
"abc-def-ghi".toKebabLowerCase // abc-def-ghi
"Abc-Def-Ghi".toKebabLowerCase // abc-def-ghi
"ABC-DEF-GHI".toKebabLowerCase // abc-def-ghi
"abc def ghi".toKebabLowerCase // abc-def-ghi
"Abc Def Ghi".toKebabLowerCase // abc-def-ghi
"ABC DEF GHI".toKebabLowerCase // abc-def-ghi
- [
extras-string
] Add case conversion -Seq[String].mkPascalCaseString
(#447)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
List("Abc", "Def").mkPascalCaseString // AbcDef
List("AbcDef", "Ghi", "jkl", "MnoPqr").mkPascalCaseString // AbcDefGhiJklMnoPqr
List("abcDef", "Ghi", "jkl", "MnoPqr").mkPascalCaseString // AbcDefGhiJklMnoPqr
List("abc").mkPascalCaseString // Abc
List("ABC").mkPascalCaseString // Abc
List("Abc_Def_Ghi", "jkl_mno_Pqr").mkPascalCaseString // AbcDefGhiJklMnoPqr
List("abc_def_ghi", "jkl_mno_pqr", "st_u").mkPascalCaseString // AbcDefGhiJklMnoPqrStU
List("ABC_DEF_GHI", "JKL_MNO_PQR", "ST_U").mkPascalCaseString // AbcDefGhiJklMnoPqrStU
List("Abc-Def-Ghi", "jkl-mno-Pqr").mkPascalCaseString // AbcDefGhiJklMnoPqr
List("abc-def-ghi", "jkl-mno-pqr", "st-u").mkPascalCaseString // AbcDefGhiJklMnoPqrStU
List("ABC-DEF-GHI", "JKL-MNO-PQR", "ST-U").mkPascalCaseString // AbcDefGhiJklMnoPqrStU
List("Abc Def Ghi", "jkl mno Pqr").mkPascalCaseString // AbcDefGhiJklMnoPqr
List("abc def ghi", "jkl mno pqr", "st u").mkPascalCaseString // AbcDefGhiJklMnoPqrStU
List("ABC DEF GHI", "JKL MNO PQR", "ST U").mkPascalCaseString // AbcDefGhiJklMnoPqrStU
- [
extras-string
] Add case conversion -Seq[String].mkCamelCaseString
(#448)import extras.strings.syntax.cases._ // or import extras.strings.syntax.all._
List("Abc", "Def").mkCamelCaseString // abcDef
List("AbcDef", "Ghi", "jkl", "MnoPqr").mkCamelCaseS...
v0.43.0
v0.42.0
v0.41.0
0.41.0 - 2023-08-27
New Features
-
Add
extras-string
module (#406) -
[
extras-string
] Addsyntax
forInt
and addtoOrdinal
(#408)1.toOrdinal // String = 1st 2.toOrdinal // String = 2nd 3.toOrdinal // String = 3rd 4.toOrdinal // String = 4th ...
(1 to 30).map(_.toOrdinal).foreach(println(_))
1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th 14th 15th 16th 17th 18th 19th 20th 21st 22nd 23rd 24th 25th 26th 27th 28th 29th 30th
-
[
extras-string
] Addsyntax
forLong
and addtoOrdinal
(#409)1L.toOrdinal // String = 1st 2L.toOrdinal // String = 2nd 3L.toOrdinal // String = 3rd 4L.toOrdinal // String = 4th ...
(1L to 30L).map(_.toOrdinal).foreach(println(_))
1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th 14th 15th 16th 17th 18th 19th 20th 21st 22nd 23rd 24th 25th 26th 27th 28th 29th 30th
-
[
extras-string
] AddcommaWith
syntax forSeq[String]
(#419)An extension method for a
Seq[String]
, providing a way to join the elements with a comma and a given conjunction.It joins
String
values with commas and uses the given conjunction before the last element.List.empty[String].commaWith("BLAH") // String = "" List("").commaWith("BLAH") // String = "" List("aaa").commaWith("BLAH") // String = "aaa" List("aaa", "bbb").commaWith("BLAH") // String = "aaa BLAH bbb" List("aaa", "bbb", "ccc").commaWith("BLAH") // String = "aaa, bbb BLAH ccc" List("aaa", "bbb", "ccc", "ddd").commaWith("BLAH") // String = "aaa, bbb, ccc BLAH ddd"
-
[
extras-string
] AddserialCommaWith
syntax forSeq[String]
(#420)An extension method for a
Seq[String]
, providing a way to join the elements with a serial comma and a given conjunction.It joins
String
values with commas and uses the given conjunction before the last element.This method employs the serial comma (also known as the Oxford comma),
which means it always inserts a comma before the conjunction unless there are only two elements.List.empty[String].serialCommaWith("BLAH") // String = "" List("").serialCommaWith("BLAH") // String = "" List("aaa").serialCommaWith("BLAH") // String = "aaa" List("aaa", "bbb").serialCommaWith("BLAH") // String = "aaa BLAH bbb" List("aaa", "bbb", "ccc").serialCommaWith("BLAH") // String = "aaa, bbb, BLAH ccc" List("aaa", "bbb", "ccc", "ddd").serialCommaWith("BLAH") // String = "aaa, bbb, ccc, BLAH ddd"
-
[
extras-string
] AddcommaAnd
syntax forSeq[String]
(#412)Format
Seq[String]
into a human-readable list using comma and the conjunctionand
.
It separates elements by commas and uses the termand
before the last element.List.empty[String].commaAnd // String = "" List("").commaAnd // String = "" List("aaa").commaAnd // String = "aaa" List("aaa", "bbb").commaAnd // String = "aaa and bbb" List("aaa", "bbb", "ccc").commaAnd // String = "aaa, bbb and ccc" List("aaa", "bbb", "ccc", "ddd").commaAnd // String = "aaa, bbb, ccc and ddd"
-
[
extras-string
] AddserialCommaAnd
syntax forSeq[String]
(#414)Format
Seq[String]
into a human-readable list using comma and the conjunctionand
.It separates elements by commas and uses the term
and
before the last element following the "Oxford comma" style.e.g.)
"aaa, bbb, and ccc"
List.empty[String].serialCommaAnd // String = "" List("").serialCommaAnd // String = "" List("aaa").serialCommaAnd // String = "aaa" List("aaa", "bbb").serialCommaAnd // String = "aaa and bbb" List("aaa", "bbb", "ccc").serialCommaAnd // String = "aaa, bbb, and ccc" List("aaa", "bbb", "ccc", "ddd").serialCommaAnd // String = "aaa, bbb, ccc, and ddd"
-
[
extras-string
] AddcommaOr
syntax forSeq[String]
(#416)Format
Seq[String]
into a human-readable list using comma and the conjunctionor
.It separates elements by commas and uses the term
or
before the last element.List.empty[String].commaOr // String = "" List("").commaOr // String = "" List("aaa").commaOr // String = "aaa" List("aaa", "bbb").commaOr // String = "aaa or bbb" List("aaa", "bbb", "ccc").commaOr // String = "aaa, bbb or ccc" List("aaa", "bbb", "ccc", "ddd").commaOr // String = "aaa, bbb, ccc or ddd"
-
[
extras-string
] AddserialCommaOr
syntax forSeq[String]
(#417)Format
Seq[String]
into a human-readable list using comma and the conjunctionor
.It separates elements by commas and uses the term
or
before the last element following the "Oxford comma" style.e.g.)
"aaa, bbb, or ccc"
List.empty[String].serialCommaOr // String = "" List("").serialCommaOr // String = "" List("aaa").serialCommaOr // String = "aaa" List("aaa", "bbb").serialCommaOr // String = "aaa or bbb" List("aaa", "bbb", "ccc").serialCommaOr // String = "aaa, bbb, or ccc" List("aaa", "bbb", "ccc", "ddd").serialCommaOr // String = "aaa, bbb, ccc, or ddd"
v0.40.0
v0.39.0
v0.38.0
v0.37.0
0.37.0 - 2023-03-13
Changes
- [
extras-cats
] FixinnerFold
andinnerFoldF
forF[Either[A, B]]
to have the same method signature asEither
's (#368)-
innerFold
def innerFold[D](ifLeft: => D)(f: B => D)(implicit F: Functor[F]): F[D]
to
def innerFold[D](forLeft: A => D)(forRight: B => D)(implicit F: Functor[F]): F[D]
-
innerFoldF
def innerFoldF[D](ifLeft: => F[D])(f: B => F[D])(implicit F: FlatMap[F]): F[D]
to
def innerFoldF[D](forLeft: A => F[D])(forRight: B => F[D])(implicit F: FlatMap[F]): F[D]
-
v0.36.0
0.36.0 - 2023-03-12
New Feature
extras-cats
- Add
innerMap
extension method toF[Option[A]]
(#348)val foa: F[Option[A]] = ... foa.innerMap(A => B) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(1) // IO[Option[Int]] = IO(Some(1)) foa.innerMap(_ + 999) // IO[Option[Int]] = IO(Some(1000))
- Add
innerFlatMap
extension method toF[Option[A]]
(#349)val foa: F[Option[A]] = ... foa.innerFlatMap(A => Option[B]) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(1) // IO[Option[Int]] = IO(Some(1)) foa.innerFlatMap((_ + 999).some) // IO[Option[Int]] = IO(Some(1000))
- Add
innerFlatMapF
extension method toF[Option[A]]
(#352)val foa: F[Option[A]] = ... foa.innerFlatMapF(A => F[Option[B]]) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(1) // IO[Option[Int]] = IO(Some(1)) foa.innerFlatMapF(a => IO.pure((a + 999).some)) // IO[Option[Int]] = IO(Some(1000))
innerGetOrElse
,innerGetOrElseF
,innerFold
andinnerFoldF
to extension methods toF[Option[A]]
(#354)-
innerGetOrElse
val foa: F[Option[A]] = ... foa.innerGetOrElse[B >: A](=> B) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(999) // IO[Option[Int]] = IO(Some(999)) foa.innerGetOrElse(0) // IO[Option[Int]] = IO(Some(1000)) val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int]) // IO[Option[Int]] = None foa2.innerGetOrElse(0) // IO[Option[Int]] = IO(Some(0))
-
innerGetOrElseF
val foa: F[Option[A]] = ... foa.innerGetOrElseF[B >: A](=> F[B]) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(999) // IO[Option[Int]] = IO(Some(999)) foa.innerGetOrElseF(IO.pure(0)) // IO[Option[Int]] = IO(Some(1000)) val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int]) // IO[Option[Int]] = None foa2.innerGetOrElseF(IO.pure(0)) // IO[Option[Int]] = IO(Some(0))
-
innerFold
val foa: F[Option[A]] = ... foa.innerFold[B](=> B)(A => B) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(1) // IO[Option[Int]] = IO(Some(1)) foa.innerFold(0)(_ + 999) // IO[Option[Int]] = IO(Some(1000)) val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int]) // IO[Option[Int]] = None foa2.innerFold(0)(_ + 999) // IO[Option[Int]] = IO(Some(0))
-
innerFoldF
val foa: F[Option[A]] = ... foa.innerFoldF[B >: A](=> F[B]) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(1) // IO[Option[Int]] = IO(Some(1)) foa.innerFoldF(IO.pure(0))(a => IO.pure(a + 999)) // IO[Option[Int]] = IO(Some(1000)) val foa2: IO[Option[Int]] = IO.pure(Option.empty[Int]) // IO[Option[Int]] = None foa2.innerFoldF(IO.pure(0))(a => IO.pure(a + 999)) // IO[Option[Int]] = IO(Some(0))
-
- Add
innerMap
,innerFlatMap
,innerFlatMapF
,innerGetOrElse
,innerGetOrElseF
,innerFold
andinnerFoldF
extension methods toF[Either[A, B]]
(#356)-
innerMap
val feab: F[Either[A, B]] = ... feab.innerMap(B => D) // F[Either[A, D]]
val feab: F[Either[String, Int]] = IO.pure(Right(1)) // IO[Either[String, Int]] = IO(Right(1)) feab.innerMap(_ + 999) // IO[Either[String, Int]] = IO(Right(1000))
-
innerFlatMap
val feab: F[Either[A, B]] = ... feab.innerFlatMap(B => Either[A, D]) // F[Either[A, D]]
val feab: F[Either[String, Int]] = IO.pure(Right(1)) // IO[Either[String, Int]] = IO(Right(1)) feab.innerFlatMap(b => (b + 999).asRight[String]) // IO[Either[String, Int]] = IO(Right(1000))
-
innerFlatMapF
val feab: F[Either[A, B]] = ... feab.innerFlatMapF(B => F[Either[A, D]]) // F[Either[A, D]]
val feab: F[Either[String, Int]] = IO.pure(Right(1)) // IO[Either[String, Int]] = IO(Right(1)) feab.innerFlatMapF(b => IO.pure((b + 999).asRight[String])) // IO[Either[String, Int]] = IO(Right(1000))
-
innerGetOrElse
val feab: F[Either[A, B]] = ... feab.innerGetOrElse[D >: B](=> D) // F[D]
val feab: F[Either[String, Int]] = IO.pure(Right(999)) // IO[Either[String, Int]] = IO(Right(999)) feab.innerGetOrElse(0) // IO[Int] = IO(999) val feab2: F[Either[String, Int]] = IO.pure("Error".asLeft[Int]) // IO[Either[String, Int]] = IO(Left("Error")) feab2.innerGetOrElse(0) // IO[Int] = IO(0)
-
innerGetOrElseF
val feab: F[Either[A, B]] = ... feab.innerGetOrElseF[D >: B](=> F[D]) // F[D]
val feab: F[Either[String, Int]] = IO.pure(Right(999)) // IO[Either[String, Int]] = IO(Right(999)) feab.innerGetOrElseF(IO.pure(0)) // IO[Either[String, Int]] = IO(Right(999)) val feab2: F[Either[String, Int]] = IO.pure("Error".asLeft[Int]) // IO[Either[String, Int]] = IO(Left("Error")) feab2.innerGetOrElseF(IO.pure(0)) // IO[Int] = IO(0)
-
innerFold
val feab: F[Either[A, B]] = ... feab.innerFold[D](=> D)(B => D) // F[D]
val feab: F[Either[String, Int]] = IO.pure(Right(1)) // IO[Either[String, Int]] = IO(Right(1)) feab.innerFold(0)(_ + 999) // IO[Int] = IO(1000) val feab: F[Either[String, Int]] = IO.pure("Error".asLeft) // IO[Either[String, Int]] = IO(Left("Error")) feab.innerFold(0)(_ + 999) // IO[Int] = IO(0)
-
innerFoldF
val feab: F[Either[A, B]] = ... feab.innerFoldF[D](=> F[D])(B => F[D]) // F[D]
val feab: F[Either[String, Int]] = IO.pure(Right(1)) // IO[Either[String, Int]] = IO(Right(1)) feab.innerFoldF(IO.pure(0))(b => IO.pure(b + 999)) // IO[Int] = IO(1000) val feab: F[Either[String, Int]] = IO.pure("Error".asLeft) // IO[Either[String, Int]] = IO(Left("Error")) feab.innerFoldF(IO.pure(0))(b => IO.pure(b + 999)) // IO[Int] = IO(0)
-
-
Add
innerLeftMap
,innerLeftFlatMap
andinnerLeftFlatMapF
extension methods toF[Either[A, B]]
(#358)-
innerLeftMap
val feab: F[Either[A, B]] = ... feab.innerLeftMap(A => C) // F[Either[C, B]]
val feab: F[Either[String, Int]] = IO.pure(Left("Error")) // IO[Either[String, Int]] = IO(Left("Error")) feab.innerLeftMap("Failed: " + _) // IO[Either[String, Int]] = IO(Left("Failed: Error"))
-
innerLeftFlatMap
val feab: F[Either[A, B]] = ... feab.innerFlatMap(A => Either[C, B]) // F[Either[C, B]]
val feab: F[Either[String, Int]] = IO.pure(Left("Error")) // IO[Either[String, Int]] = IO(Left("Error")) feab.innerFlatMap(a => ("Failed: " + a).asLeft[Int]) // IO[Either[String, Int]] = IO(Left("Failed: Error"))
-
innerLeftFlatMapF
val feab: F[Either[A, B]] = ... feab.innerFlatMapF(A => F[Either[C, B]]) // F[Either[C, B]]
val feab: F[Either[String, Int]] = IO.pure(Left("Error")) // IO[Either[String, Int]] = IO(Left("Error")) feab.innerFlatMapF(a => IO.pure(("Failed: " + a).asLeft[Int])) // IO[Either[String, Int]] = IO(Left("Failed: Error"))
-
-
Add
innerFilter
,innerExists
,innerContains
,innerForall
,innerCollect
,innerOrElse
andinnerOrElseF
extension methods toF[Option[A]]
(#360)-
innerFilter
val foa: F[Option[A]] = ... foa.innerFilter(A => Boolean) // F[Option[A]]
val foa: IO[Option[Int]] = IO.pure(Some(1)) // IO[Option[Int]] = IO(Some(1)) foa.innerFilter(_ > 0) // IO[Option[Int]] = IO(Some(1)) foa.innerFilter(_ > 1) // IO[Option[Int]] = IO(None)
-
innerExists
val foa: F[Option[A]] = ... foa.innerExists(A => Boolean) // F[Boolean]
val foa: IO[Option[Int]] = IO.pure(Some(1)) // IO[Option[Int]] = IO(Some(1)) foa.innerExists(_ > 0) // IO[Boolean] = IO(true) foa.innerExists(_ > 1) // IO[Boolean] = IO(false)
-
innerContains
val foa: F[Option[A]] = ... foa.innerContains(A) // F[Boolean]
val foa: IO[Option[Int]] = IO.pure(Some(1)) // IO[Option[Int]] = IO(Some(1)) foa.innerContains(1) // IO[Boolean] = IO(true) foa.innerContains(0) // IO[Boolean] = IO(false)
-
innerForall
val foa: F[Option[A]] = ... foa.innerForall(A) // F[Boolean]
val foa: IO[Option[Int]] = IO.pure(Some(1)) // IO[Option[Int]] = IO(Some(1)) foa.innerForall(_ > 0) // IO[Boolean] = IO(true) foa.innerForall(_ > 1) // IO[Boolean] = IO(false) val foa2: IO[Option[Int]] = IO.pure(None) // IO[Option[Int]] = IO(None) foa2.innerForall(_ > 1) // IO[Boolean] = IO(true)
-
innerCollect
val foa: F[Option[A]] = ... foa.innerCollect(PartialFunction[A, B]) // F[Option[B]]
val foa: IO[Option[Int]] = IO.pure(Some(1)) // IO[Option[Int]] = IO(Some(1)) foa.innerCollect { case 1 => 0 case 2 => 999 } // IO[Option[Int]] = IO(0) val foa2: IO[Option[Int]] = IO.pure(Some(2)) // IO[Option[Int]] = IO(2) foa.innerCollect { case 1 => 0 case 2 => 999 } // IO[Option[Int]] = IO(999) val foa3: IO[Option[Int]] = IO.pure(Some(3)) // IO[Option[Int]] = IO(3) foa.innerCollect { case 1 => 0 case 2 => 9...
-