kotlin-functional

所属分类:编程语言基础
开发工具:kotlin
文件大小:0KB
下载次数:0
上传日期:2023-09-19 15:28:57
上 传 者sh-1993
说明:  Kotlin编程语言的函数概念和类型,
(Functional concepts and types for Kotlin programming language,)

文件列表:
LICENSE (11357, 2023-09-22)
base/ (0, 2023-09-22)
base/build.gradle.kts (823, 2023-09-22)
base/src/ (0, 2023-09-22)
base/src/commonMain/ (0, 2023-09-22)
base/src/commonMain/kotlin/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/Context.kt (258, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/Alternative.kt (1618, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/Applicative.kt (1580, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/Arrow.kt (1145, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/ArrowApply.kt (255, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/ArrowChoice.kt (873, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/Category.kt (372, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/Comonad.kt (435, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/Lift.kt (1746, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/Monad.kt (1571, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/MonadPlus.kt (2767, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/MonadZip.kt (1650, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/arrow/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/arrow/FArrow.kt (4085, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/arrow/Kleisli.kt (4525, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/monad/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/monad/MonadTrans.kt (413, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/monad/OptionalT.kt (4447, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/reader/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/reader/Reader.kt (1621, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/state/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/control/state/State.kt (2283, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/data/ (0, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/data/BiFunctor.kt (377, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/data/Contravariant.kt (217, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/data/Foldable.kt (3684, 2023-09-22)
base/src/commonMain/kotlin/com/github/fsbarata/functional/data/Functions.kt (16661, 2023-09-22)
... ...

# kotlin-functional [![](https://jitpack.io/v/fsbarata/kotlin-functional.svg)](https://jitpack.io/#fsbarata/kotlin-functional) ## Purpose This library provides a set of concepts and implementations of patterns commonly used in functional programming. ## Background With the increasing of the multi-threaded/core capabilities on the devices, it is not feasible to continue using stateful, assumption-based and side-effect styles of programming. Kotlin provides a very limited range of functional structures and patterns. ## What to use it for This library is an attempt to complement the existing features of kotlin, as well as providing new types that are useful in functional programming. ## Common Data Types ### Optional Encapsulates a value that may or may not be present. It abstracts the nullability of a value. Most commonly used with the RxJava framework, where nulls are forbidden. Example 1: ``` Observable.just(1, 2, 3, 5, 6, 7) .map { if (it % 2 == 0) Optional.empty() else Optional.just(it) } .filterNotNone() // returns an Observable with items [1, 3, 5, 7] ``` Example 2: ``` Observable.just(1, 2, 3, 5, 6, 7) .map { if (it % 2 == 0) Optional.empty() else Optional.just(it) } .mapNotNone(liftOpt { it + 1 }) // returns an Observable with items [2, 4, 6, 8] ``` ### Either A data structure that can only carry one of two possibilities. Most commonly used to represent Correct (Right) or Error (Left) result of one computation. ### NonEmpty List/Set A list/set that must have at least one element. As a result, multiple operations are guaranteed to yield more predictable results, such as `first`, `last`, `max`, `reduce`, etc. Most commonly used to represent Lists that have been tested for emptiness. ### Validation Akin to Either, Validation can only carry a Success or a Failure result. While Either is used to shortcut errors, Validation is used to accumulate them. Most commonly used to accumulate/compose errors from multiple computations. ## Other uses You will find in this library other concepts such as Monad, Monoid and Foldable. ## Dependency ### Gradle ``` repositories { maven { url 'https://jitpack.io' } } dependencies { implementation "com.github.fsbarata.kotlin-functional:base:$kfVersion" } ```

近期下载者

相关文件


收藏者