diff --git a/modules/core/arrow-annotations-processor/src/main/java/arrow/higherkinds/HigherKindsFileGenerator.kt b/modules/core/arrow-annotations-processor/src/main/java/arrow/higherkinds/HigherKindsFileGenerator.kt
index 6f64a0eb7b3..2409179e4c6 100644
--- a/modules/core/arrow-annotations-processor/src/main/java/arrow/higherkinds/HigherKindsFileGenerator.kt
+++ b/modules/core/arrow-annotations-processor/src/main/java/arrow/higherkinds/HigherKindsFileGenerator.kt
@@ -61,7 +61,7 @@ class HigherKindsFileGenerator(
val appliedTypeArgs = hk.typeArgs.dropLast(1)
val expandedAppliedTypeArgs = appliedTypeArgs.joinToString(", ")
val hkimpl = if (appliedTypeArgs.size == 1) "arrow.Kind" else "arrow.Kind${appliedTypeArgs.size}"
- return "typealias ${hk.name.replace("Of$".toRegex(), { "PartialOf" })}<$expandedAppliedTypeArgs> = $hkimpl<${hk.markerName}, $expandedAppliedTypeArgs>"
+ return "typealias ${hk.name.replace("Of$".toRegex()) { "PartialOf" }}<$expandedAppliedTypeArgs> = $hkimpl<${hk.markerName}, $expandedAppliedTypeArgs>"
}
private fun genKindedJTypeAliases(hk: HigherKind): String =
diff --git a/modules/core/arrow-core/src/main/kotlin/arrow/core/PartialFunction.kt b/modules/core/arrow-core/src/main/kotlin/arrow/core/PartialFunction.kt
index e0ee204e1df..f20838dabc1 100644
--- a/modules/core/arrow-core/src/main/kotlin/arrow/core/PartialFunction.kt
+++ b/modules/core/arrow-core/src/main/kotlin/arrow/core/PartialFunction.kt
@@ -56,7 +56,7 @@ fun PartialFunction.andThen(f: (B) -> C): PartialFunction
}
private class Lifted(val pf: PartialFunction) : (A) -> Option {
- override fun invoke(x: A): Option = pf.andThen { Some(it) }.invokeOrElse(x, { None })
+ override fun invoke(x: A): Option = pf.andThen { Some(it) }.invokeOrElse(x) { None }
}
fun ((A) -> B).toPartialFunction(definedAt: (A) -> Boolean): PartialFunction = PartialFunction(definedAt, this)
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/Cokleisli.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/Cokleisli.kt
index 7fbfa1455c1..847510f197a 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/Cokleisli.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/Cokleisli.kt
@@ -11,28 +11,28 @@ typealias CoreaderT = Cokleisli
@higherkind
data class Cokleisli(val MM: Comonad, val run: CokleisliFun) : CokleisliOf, CokleisliKindedJ, Comonad by MM {
- inline fun bimap(noinline g: (D) -> A, crossinline f: (B) -> C): Cokleisli = Cokleisli(MM, { f(run(it.map(g))) })
+ inline fun bimap(noinline g: (D) -> A, crossinline f: (B) -> C): Cokleisli = Cokleisli(MM) { f(run(it.map(g))) }
- fun lmap(g: (D) -> A): Cokleisli = Cokleisli(MM, { run(it.map(g)) })
+ fun lmap(g: (D) -> A): Cokleisli = Cokleisli(MM) { run(it.map(g)) }
- inline fun map(crossinline f: (B) -> C): Cokleisli = Cokleisli(MM, { f(run(it)) })
+ inline fun map(crossinline f: (B) -> C): Cokleisli = Cokleisli(MM) { f(run(it)) }
- inline fun contramapValue(crossinline f: (Kind) -> Kind): Cokleisli = Cokleisli(MM, { run(f(it)) })
+ inline fun contramapValue(crossinline f: (Kind) -> Kind): Cokleisli = Cokleisli(MM) { run(f(it)) }
- fun compose(a: Cokleisli): Cokleisli = Cokleisli(MM, { run(it.coflatMap(a.run)) })
+ fun compose(a: Cokleisli): Cokleisli = Cokleisli(MM) { run(it.coflatMap(a.run)) }
@JvmName("andThenK")
- fun andThen(a: Kind): Cokleisli = Cokleisli(MM, { run { a.extract() } })
+ fun andThen(a: Kind): Cokleisli = Cokleisli(MM) { run { a.extract() } }
fun andThen(a: Cokleisli): Cokleisli = a.compose(this)
- inline fun flatMap(crossinline f: (B) -> Cokleisli): Cokleisli = Cokleisli(MM, { f(run(it)).run(it) })
+ inline fun flatMap(crossinline f: (B) -> Cokleisli): Cokleisli = Cokleisli(MM) { f(run(it)).run(it) }
companion object {
inline operator fun invoke(MF: Comonad, noinline run: (Kind) -> B): Cokleisli = Cokleisli(MF, run)
- inline fun just(MF: Comonad, b: B): Cokleisli = Cokleisli(MF, { b })
+ inline fun just(MF: Comonad, b: B): Cokleisli = Cokleisli(MF) { b }
- inline fun ask(MF: Comonad): Cokleisli = Cokleisli(MF, { MF.run { it.extract() } })
+ inline fun ask(MF: Comonad): Cokleisli = Cokleisli(MF) { MF.run { it.extract() } }
}
}
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/Coproduct.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/Coproduct.kt
index 4d7d8115dd0..9217da13116 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/Coproduct.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/Coproduct.kt
@@ -13,8 +13,8 @@ data class Coproduct(val run: Either, Kind>) : Coprodu
fun coflatMap(CF: Comonad, CG: Comonad, f: (Coproduct) -> B): Coproduct =
Coproduct(run.bimap(
- { CF.run { it.coflatMap({ f(Coproduct(Left(it))) }) } },
- { CG.run { it.coflatMap({ f(Coproduct(Right(it))) }) } }
+ { CF.run { it.coflatMap { f(Coproduct(Left(it))) } } },
+ { CG.run { it.coflatMap { f(Coproduct(Right(it))) } } }
))
fun extract(CF: Comonad, CG: Comonad): A =
@@ -31,9 +31,9 @@ data class Coproduct(val run: Either, Kind>) : Coprodu
fun traverse(GA: Applicative, FT: Traverse, GT: Traverse, f: (A) -> Kind): Kind> = GA.run {
run.fold({
- FT.run { it.traverse(GA, f) }.map({ Coproduct(Left(it)) })
+ FT.run { it.traverse(GA, f) }.map { Coproduct(Left(it)) }
}, {
- GT.run { it.traverse(GA, f) }.map({ Coproduct(Right(it)) })
+ GT.run { it.traverse(GA, f) }.map { Coproduct(Right(it)) }
})
}
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/EitherT.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/EitherT.kt
index cba340dec20..ce2c6588792 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/EitherT.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/EitherT.kt
@@ -55,44 +55,44 @@ data class EitherT(val value: Kind>) : EitherTOf fold(FF: Functor, crossinline l: (A) -> C, crossinline r: (B) -> C): Kind = FF.run {
- value.map({ either -> either.fold(l, r) })
+ value.map { either -> either.fold(l, r) }
}
fun flatMap(MF: Monad, f: (B) -> EitherT): EitherT =
- flatMapF(MF, { it -> f(it).value })
+ flatMapF(MF) { it -> f(it).value }
fun flatMapF(MF: Monad, f: (B) -> Kind>): EitherT = MF.run {
- EitherT(value.flatMap({ either -> either.fold({ MF.just(Left(it)) }, { f(it) }) }))
+ EitherT(value.flatMap { either -> either.fold({ MF.just(Left(it)) }, { f(it) }) })
}
fun cata(FF: Functor, l: (A) -> C, r: (B) -> C): Kind = fold(FF, l, r)
fun liftF(FF: Functor, fa: Kind): EitherT = FF.run {
- EitherT(fa.map({ Right(it) }))
+ EitherT(fa.map { Right(it) })
}
- fun semiflatMap(MF: Monad, f: (B) -> Kind): EitherT = flatMap(MF, { liftF(MF, f(it)) })
+ fun semiflatMap(MF: Monad, f: (B) -> Kind): EitherT = flatMap(MF) { liftF(MF, f(it)) }
fun map(FF: Functor, f: (B) -> C): EitherT = FF.run {
- EitherT(value.map({ it.map(f) }))
+ EitherT(value.map { it.map(f) })
}
fun mapLeft(FF: Functor, f: (A) -> C): EitherT = FF.run {
- EitherT(value.map({ it.mapLeft(f) }))
+ EitherT(value.map { it.mapLeft(f) })
}
fun exists(FF: Functor, p: (B) -> Boolean): Kind = FF.run {
- value.map({ it.exists(p) })
+ value.map { it.exists(p) }
}
fun transform(FF: Functor, f: (Either) -> Either): EitherT = FF.run {
- EitherT(value.map({ f(it) }))
+ EitherT(value.map { f(it) })
}
- fun subflatMap(FF: Functor, f: (B) -> Either): EitherT = transform(FF, { it.flatMap(f = f) })
+ fun subflatMap(FF: Functor, f: (B) -> Either): EitherT = transform(FF) { it.flatMap(f = f) }
fun toOptionT(FF: Functor): OptionT = FF.run {
- OptionT(value.map({ it.toOption() }))
+ OptionT(value.map { it.toOption() })
}
fun combineK(MF: Monad, y: EitherTOf): EitherT = MF.run {
@@ -104,5 +104,5 @@ data class EitherT(val value: Kind>) : EitherTOf ap(MF: Monad, ff: EitherTOf C>): EitherT = ff.fix().flatMap(MF, { f -> map(MF, f) })
+ fun ap(MF: Monad, ff: EitherTOf C>): EitherT = ff.fix().flatMap(MF) { f -> map(MF, f) }
}
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/Ior.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/Ior.kt
index e9d7c654fa0..0ef313d7511 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/Ior.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/Ior.kt
@@ -145,7 +145,7 @@ sealed class Ior : IorOf {
fold({ lc }, { f(it, lc) }, { _, b -> f(b, lc) })
fun traverse(GA: Applicative, f: (B) -> Kind): Kind> = GA.run {
- fold({ just(Left(it)) }, { f(it).map({ Right(it) }) }, { _, b -> f(b).map({ Right(it) }) })
+ fold({ just(Left(it)) }, { f(it).map { Right(it) } }, { _, b -> f(b).map { Right(it) } })
}
/**
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/Kleisli.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/Kleisli.kt
index fa6de79c86a..d1ec1d22f29 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/Kleisli.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/Kleisli.kt
@@ -64,9 +64,9 @@ class Kleisli(val run: KleisliFun) : KleisliOf, Kleis
* @param MF [Monad] for the context [F].
*/
fun zip(MF: Monad, o: Kleisli): Kleisli> =
- flatMap(MF, { a ->
- o.map(MF, { b -> Tuple2(a, b) })
- })
+ flatMap(MF) { a ->
+ o.map(MF) { b -> Tuple2(a, b) }
+ }
/**
* Compose this arrow with another function to transform the input of the arrow.
@@ -99,7 +99,7 @@ class Kleisli(val run: KleisliFun) : KleisliOf, Kleis
* @param fb the new end of the arrow.
* @param MF [Monad] for the context [F].
*/
- fun andThen(MF: Monad, fb: Kind): Kleisli = andThen(MF, { fb })
+ fun andThen(MF: Monad, fb: Kind): Kleisli = andThen(MF) { fb }
/**
* Handle error within context of [F] given a [MonadError] is defined for [F].
@@ -108,7 +108,7 @@ class Kleisli(val run: KleisliFun) : KleisliOf, Kleis
* @param ME [MonadError] for the context [F].
*/
fun handleErrorWith(ME: MonadError, f: (E) -> KleisliOf): Kleisli = Kleisli {
- ME.run { run(it).handleErrorWith({ e: E -> f(e).fix().run(it) }) }
+ ME.run { run(it).handleErrorWith { e: E -> f(e).fix().run(it) } }
}
companion object {
@@ -128,7 +128,7 @@ class Kleisli(val run: KleisliFun) : KleisliOf, Kleis
* @param MF [Monad] for the context [F].
*/
fun tailRecM(MF: Monad, a: A, f: (A) -> KleisliOf>): Kleisli =
- Kleisli { b -> MF.tailRecM(a, { f(it).fix().run(b) }) }
+ Kleisli { b -> MF.tailRecM(a) { f(it).fix().run(b) } }
/**
* Create an arrow for a value of [A].
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/ListK.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/ListK.kt
index 3a28ae15fb9..3db9383c188 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/ListK.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/ListK.kt
@@ -37,7 +37,7 @@ data class ListK(val list: List) : ListKOf, List by list {
}.fix()
fun mapFilter(f: (A) -> Option): ListK =
- flatMap({ a -> f(a).fold({ empty() }, { just(it) }) })
+ flatMap { a -> f(a).fold({ empty() }, { just(it) }) }
companion object {
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/MapK.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/MapK.kt
index 1c31a8ea6d8..eb9aed963e8 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/MapK.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/MapK.kt
@@ -43,9 +43,9 @@ data class MapK(val map: Map) : MapKOf, Map by map {
this.map.foldLeft(b) { m, (k, v) -> f(m.k(), Tuple2(k, v)) }.k()
fun traverse(GA: Applicative, f: (A) -> Kind): Kind> = GA.run {
- (Foldable.iterateRight(map.iterator(), Eval.always { just(emptyMap().k()) }))({ kv, lbuf ->
+ (Foldable.iterateRight(map.iterator(), Eval.always { just(emptyMap().k()) })) { kv, lbuf ->
f(kv.value).map2Eval(lbuf) { (mapOf(kv.key to it.a).k() + it.b).k() }
- }).value()
+ }.value()
}
companion object
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/NonEmptyList.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/NonEmptyList.kt
index fb3b788c691..f116e5964ba 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/NonEmptyList.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/NonEmptyList.kt
@@ -47,9 +47,9 @@ class NonEmptyList private constructor(
fun traverse(AG: Applicative, f: (A) -> Kind): Kind> = with(AG) {
f(fix().head).map2Eval(Eval.always {
tail.k().traverse(AG, f)
- }, {
+ }) {
NonEmptyList(it.a, it.b.fix().list)
- }).value()
+ }.value()
}
fun coflatMap(f: (NonEmptyListOf) -> B): NonEmptyList {
diff --git a/modules/core/arrow-data/src/main/kotlin/arrow/data/OptionT.kt b/modules/core/arrow-data/src/main/kotlin/arrow/data/OptionT.kt
index 1ae88e86908..95ba91bf6a5 100644
--- a/modules/core/arrow-data/src/main/kotlin/arrow/data/OptionT.kt
+++ b/modules/core/arrow-data/src/main/kotlin/arrow/data/OptionT.kt
@@ -44,52 +44,52 @@ data class OptionT(val value: Kind>) : OptionTOf, Optio
}
inline fun fold(FF: Functor, crossinline default: () -> B, crossinline f: (A) -> B): Kind = FF.run {
- value.map({ option -> option.fold(default, f) })
+ value.map { option -> option.fold(default, f) }
}
fun cata(FF: Functor, default: () -> B, f: (A) -> B): Kind = fold(FF, default, f)
- fun ap(MF: Monad, ff: OptionTOf B>): OptionT = ff.fix().flatMap(MF, { f -> map(MF, f) })
+ fun ap(MF: Monad, ff: OptionTOf B>): OptionT = ff.fix().flatMap(MF) { f -> map(MF, f) }
- fun flatMap(MF: Monad, f: (A) -> OptionT): OptionT = flatMapF(MF, { it -> f(it).value })
+ fun flatMap(MF: Monad, f: (A) -> OptionT): OptionT = flatMapF(MF) { it -> f(it).value }
fun flatMapF(MF: Monad, f: (A) -> Kind>): OptionT = MF.run {
- OptionT(value.flatMap({ option -> option.fold({ just(None) }, f) }))
+ OptionT(value.flatMap { option -> option.fold({ just(None) }, f) })
}
fun liftF(FF: Functor, fa: Kind): OptionT = FF.run {
- OptionT(fa.map({ Some(it) }))
+ OptionT(fa.map { Some(it) })
}
- fun