├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── add-company-logo-to-users.md │ └── feature_request.md ├── scripts │ └── create-release-notes.sh └── workflows │ ├── auto-update-pr.yaml │ ├── githubpages.yaml │ ├── publish.yml │ └── pull_request.yml ├── .gitignore ├── .idea ├── icon.png └── vcs.xml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASE.md ├── arrow-libs ├── core │ ├── arrow-annotations │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-annotations.api │ │ │ ├── arrow-annotations.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-annotations.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ │ └── commonMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ ├── optics │ │ │ └── optics.kt │ │ │ └── synthetic.kt │ ├── arrow-atomic │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-atomic.api │ │ │ ├── arrow-atomic.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-atomic.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ │ ├── androidAndJvmMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── atomic │ │ │ │ ├── Atomic.kt │ │ │ │ ├── AtomicInt.kt │ │ │ │ └── AtomicLong.kt │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── atomic │ │ │ │ ├── Atomic.kt │ │ │ │ ├── AtomicBoolean.kt │ │ │ │ ├── AtomicInt.kt │ │ │ │ └── AtomicLong.kt │ │ │ ├── commonTest │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── atomic │ │ │ │ ├── AtomicBooleanTest.kt │ │ │ │ ├── AtomicIntTest.kt │ │ │ │ ├── AtomicLongTest.kt │ │ │ │ ├── AtomicTest.kt │ │ │ │ └── Platform.kt │ │ │ ├── jsMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── atomic │ │ │ │ ├── Atomic.kt │ │ │ │ ├── AtomicInt.kt │ │ │ │ └── AtomicLong.kt │ │ │ ├── jvmTest │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── example-atomic-01.kt │ │ │ ├── nativeMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── atomic │ │ │ │ ├── Atomic.kt │ │ │ │ ├── AtomicInt.kt │ │ │ │ └── AtomicLong.kt │ │ │ └── wasmJsMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── atomic │ │ │ ├── Atomic.kt │ │ │ ├── AtomicInt.kt │ │ │ └── AtomicLong.kt │ ├── arrow-autoclose │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-autoclose.api │ │ │ ├── arrow-autoclose.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-autoclose.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.code.include │ │ ├── knit.properties │ │ └── src │ │ │ ├── androidAndJvmMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── throwIfFatal.kt │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── AutoCloseScope.kt │ │ │ ├── commonTest │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── AutoCloseTest.kt │ │ │ ├── jvmTest │ │ │ └── kotlin │ │ │ │ ├── arrow │ │ │ │ └── AutoCloseJvmTest.kt │ │ │ │ └── examples │ │ │ │ ├── example-autocloseable-01.kt │ │ │ │ └── example-autocloseable-02.kt │ │ │ └── nonJvmMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── throwIfFatal.kt │ ├── arrow-cache4k │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-cache4k.api │ │ │ ├── arrow-cache4k.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-cache4k.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ └── src │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ └── Cache4k.kt │ │ │ └── commonTest │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── core │ │ │ └── Cache4kTest.kt │ ├── arrow-core-high-arity │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-core-high-arity.api │ │ │ ├── arrow-core-high-arity.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-core-high-arity.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ ├── knit.test.template │ │ └── src │ │ │ └── commonMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── core │ │ │ ├── Iterable.kt │ │ │ ├── NonEmptyList.kt │ │ │ ├── Sequence.kt │ │ │ ├── map.kt │ │ │ └── raise │ │ │ └── RaiseAccumulate.kt │ ├── arrow-core │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-core.api │ │ │ ├── arrow-core.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-core.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ ├── knit.test.template │ │ └── src │ │ │ ├── androidAndJvmMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ ├── ArrowCoreInternalException.kt │ │ │ │ ├── MemoizedDeepRecursiveFunction.kt │ │ │ │ ├── NonFatal.kt │ │ │ │ ├── SortedMapK.kt │ │ │ │ └── raise │ │ │ │ └── CancellationExceptionNoTrace.kt │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ ├── ArrowCoreInternalException.kt │ │ │ │ ├── Comparison.kt │ │ │ │ ├── Either.kt │ │ │ │ ├── Ior.kt │ │ │ │ ├── Iterable.kt │ │ │ │ ├── MemoizedDeepRecursiveFunction.kt │ │ │ │ ├── NonEmptyCollection.kt │ │ │ │ ├── NonEmptyList.kt │ │ │ │ ├── NonEmptySet.kt │ │ │ │ ├── NonFatal.kt │ │ │ │ ├── Option.kt │ │ │ │ ├── Pair.kt │ │ │ │ ├── Result.kt │ │ │ │ ├── Sequence.kt │ │ │ │ ├── Triple.kt │ │ │ │ ├── Tuple4.kt │ │ │ │ ├── Tuple5.kt │ │ │ │ ├── Tuple6.kt │ │ │ │ ├── Tuple7.kt │ │ │ │ ├── Tuple8.kt │ │ │ │ ├── Tuple9.kt │ │ │ │ ├── TupleN.kt │ │ │ │ ├── map.kt │ │ │ │ ├── nonFatalOrThrow.kt │ │ │ │ ├── predef.kt │ │ │ │ ├── raise │ │ │ │ ├── Builders.kt │ │ │ │ ├── Effect.kt │ │ │ │ ├── ErrorHandlers.kt │ │ │ │ ├── Fold.kt │ │ │ │ ├── Mappers.kt │ │ │ │ ├── Raise.kt │ │ │ │ ├── RaiseAccumulate.kt │ │ │ │ └── Trace.kt │ │ │ │ ├── string.kt │ │ │ │ └── utils.kt │ │ │ ├── commonTest │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ ├── BooleanTest.kt │ │ │ │ ├── CollectionsSyntaxTests.kt │ │ │ │ ├── ComparisonKtTest.kt │ │ │ │ ├── EitherTest.kt │ │ │ │ ├── IorTest.kt │ │ │ │ ├── IterableTest.kt │ │ │ │ ├── KotestInlineUtils.kt │ │ │ │ ├── ListKTest.kt │ │ │ │ ├── MapKTest.kt │ │ │ │ ├── NonEmptyListTest.kt │ │ │ │ ├── NonEmptySetTest.kt │ │ │ │ ├── NonFatalTest.kt │ │ │ │ ├── OptionTest.kt │ │ │ │ ├── SequenceKTest.kt │ │ │ │ ├── TupleTest.kt │ │ │ │ ├── extensions │ │ │ │ └── NumberInstancesTest.kt │ │ │ │ ├── raise │ │ │ │ ├── EagerEffectSpec.kt │ │ │ │ ├── EffectSpec.kt │ │ │ │ ├── IorSpec.kt │ │ │ │ ├── MappersSpec.kt │ │ │ │ ├── NullableSpec.kt │ │ │ │ ├── OptionSpec.kt │ │ │ │ ├── RaiseAccumulateSpec.kt │ │ │ │ ├── ResultSpec.kt │ │ │ │ ├── StructuredConcurrencySpec.kt │ │ │ │ ├── TraceSpec.kt │ │ │ │ └── predef.kt │ │ │ │ └── test │ │ │ │ ├── Generators.kt │ │ │ │ ├── GeneratorsTest.kt │ │ │ │ ├── Laws.kt │ │ │ │ └── laws │ │ │ │ ├── MonoidLaws.kt │ │ │ │ ├── SemigroupLaws.kt │ │ │ │ └── SemiringLaws.kt │ │ │ ├── jvmTest │ │ │ ├── java │ │ │ │ └── arrow │ │ │ │ │ └── core │ │ │ │ │ ├── DeadlockTest.kt │ │ │ │ │ ├── IorUsage.java │ │ │ │ │ ├── NonFatalJvmTest.kt │ │ │ │ │ └── OptionUsage.java │ │ │ └── kotlin │ │ │ │ ├── arrow │ │ │ │ └── core │ │ │ │ │ └── raise │ │ │ │ │ ├── EffectUsage.kt │ │ │ │ │ └── TraceJvmSpec.kt │ │ │ │ └── examples │ │ │ │ ├── example-effect-error-01.kt │ │ │ │ ├── example-effect-error-02.kt │ │ │ │ ├── example-effect-error-03.kt │ │ │ │ ├── example-effect-error-04.kt │ │ │ │ ├── example-effect-error-05.kt │ │ │ │ ├── example-either-01.kt │ │ │ │ ├── example-either-02.kt │ │ │ │ ├── example-either-03.kt │ │ │ │ ├── example-either-04.kt │ │ │ │ ├── example-either-05.kt │ │ │ │ ├── example-either-06.kt │ │ │ │ ├── example-either-07.kt │ │ │ │ ├── example-either-08.kt │ │ │ │ ├── example-either-09.kt │ │ │ │ ├── example-either-10.kt │ │ │ │ ├── example-either-11.kt │ │ │ │ ├── example-either-12.kt │ │ │ │ ├── example-either-13.kt │ │ │ │ ├── example-either-14.kt │ │ │ │ ├── example-either-15.kt │ │ │ │ ├── example-either-16.kt │ │ │ │ ├── example-either-17.kt │ │ │ │ ├── example-either-18.kt │ │ │ │ ├── example-either-19.kt │ │ │ │ ├── example-either-20.kt │ │ │ │ ├── example-either-21.kt │ │ │ │ ├── example-either-22.kt │ │ │ │ ├── example-either-23.kt │ │ │ │ ├── example-either-24.kt │ │ │ │ ├── example-either-25.kt │ │ │ │ ├── example-either-26.kt │ │ │ │ ├── example-either-27.kt │ │ │ │ ├── example-either-28.kt │ │ │ │ ├── example-either-29.kt │ │ │ │ ├── example-either-30.kt │ │ │ │ ├── example-either-31.kt │ │ │ │ ├── example-either-32.kt │ │ │ │ ├── example-either-33.kt │ │ │ │ ├── example-either-34.kt │ │ │ │ ├── example-either-35.kt │ │ │ │ ├── example-either-36.kt │ │ │ │ ├── example-ior-01.kt │ │ │ │ ├── example-ior-02.kt │ │ │ │ ├── example-ior-03.kt │ │ │ │ ├── example-ior-04.kt │ │ │ │ ├── example-ior-05.kt │ │ │ │ ├── example-ior-06.kt │ │ │ │ ├── example-ior-07.kt │ │ │ │ ├── example-ior-08.kt │ │ │ │ ├── example-ior-09.kt │ │ │ │ ├── example-ior-10.kt │ │ │ │ ├── example-ior-11.kt │ │ │ │ ├── example-iterable-01.kt │ │ │ │ ├── example-iterable-02.kt │ │ │ │ ├── example-iterable-03.kt │ │ │ │ ├── example-iterable-04.kt │ │ │ │ ├── example-iterable-05.kt │ │ │ │ ├── example-iterable-06.kt │ │ │ │ ├── example-iterable-07.kt │ │ │ │ ├── example-iterable-08.kt │ │ │ │ ├── example-iterable-09.kt │ │ │ │ ├── example-iterable-10.kt │ │ │ │ ├── example-iterable-11.kt │ │ │ │ ├── example-iterable-12.kt │ │ │ │ ├── example-iterable-13.kt │ │ │ │ ├── example-iterable-14.kt │ │ │ │ ├── example-iterable-15.kt │ │ │ │ ├── example-iterable-16.kt │ │ │ │ ├── example-iterable-17.kt │ │ │ │ ├── example-map-01.kt │ │ │ │ ├── example-map-02.kt │ │ │ │ ├── example-map-03.kt │ │ │ │ ├── example-map-04.kt │ │ │ │ ├── example-map-05.kt │ │ │ │ ├── example-map-06.kt │ │ │ │ ├── example-map-07.kt │ │ │ │ ├── example-map-08.kt │ │ │ │ ├── example-nonemptylist-01.kt │ │ │ │ ├── example-nonemptylist-02.kt │ │ │ │ ├── example-nonemptylist-03.kt │ │ │ │ ├── example-nonemptylist-04.kt │ │ │ │ ├── example-nonemptylist-05.kt │ │ │ │ ├── example-nonemptylist-06.kt │ │ │ │ ├── example-nonfatal-01.kt │ │ │ │ ├── example-nonfatalorthrow-01.kt │ │ │ │ ├── example-option-01.kt │ │ │ │ ├── example-option-02.kt │ │ │ │ ├── example-option-03.kt │ │ │ │ ├── example-option-04.kt │ │ │ │ ├── example-option-05.kt │ │ │ │ ├── example-option-06.kt │ │ │ │ ├── example-option-07.kt │ │ │ │ ├── example-option-08.kt │ │ │ │ ├── example-option-09.kt │ │ │ │ ├── example-option-10.kt │ │ │ │ ├── example-option-11.kt │ │ │ │ ├── example-option-12.kt │ │ │ │ ├── example-option-13.kt │ │ │ │ ├── example-option-14.kt │ │ │ │ ├── example-option-15.kt │ │ │ │ ├── example-option-16.kt │ │ │ │ ├── example-option-17.kt │ │ │ │ ├── example-option-18.kt │ │ │ │ ├── example-option-19.kt │ │ │ │ ├── example-option-20.kt │ │ │ │ ├── example-option-21.kt │ │ │ │ ├── example-raise-01.kt │ │ │ │ ├── example-raise-02.kt │ │ │ │ ├── example-raise-03.kt │ │ │ │ ├── example-raise-04.kt │ │ │ │ ├── example-raise-05.kt │ │ │ │ ├── example-raise-06.kt │ │ │ │ ├── example-raise-07.kt │ │ │ │ ├── example-raise-08.kt │ │ │ │ ├── example-raise-09.kt │ │ │ │ ├── example-raise-10.kt │ │ │ │ ├── example-raise-11.kt │ │ │ │ ├── example-raise-12.kt │ │ │ │ ├── example-raise-13.kt │ │ │ │ ├── example-raise-dsl-01.kt │ │ │ │ ├── example-raise-dsl-02.kt │ │ │ │ ├── example-raise-dsl-03.kt │ │ │ │ ├── example-raise-dsl-04.kt │ │ │ │ ├── example-raise-dsl-05.kt │ │ │ │ ├── example-raise-dsl-06.kt │ │ │ │ ├── example-raise-dsl-07.kt │ │ │ │ ├── example-raise-dsl-08.kt │ │ │ │ ├── example-raise-dsl-09.kt │ │ │ │ ├── example-raise-dsl-10.kt │ │ │ │ ├── example-raise-dsl-11.kt │ │ │ │ ├── example-raise-dsl-12.kt │ │ │ │ ├── example-sequence-01.kt │ │ │ │ ├── example-sequence-02.kt │ │ │ │ ├── example-sequence-03.kt │ │ │ │ ├── example-sequence-04.kt │ │ │ │ ├── example-sequence-05.kt │ │ │ │ ├── example-sequence-06.kt │ │ │ │ ├── example-sequence-07.kt │ │ │ │ ├── example-sequence-08.kt │ │ │ │ ├── example-sequence-09.kt │ │ │ │ ├── example-sequence-10.kt │ │ │ │ ├── example-sequence-11.kt │ │ │ │ ├── example-sequence-12.kt │ │ │ │ ├── example-sequence-13.kt │ │ │ │ ├── example-sequence-14.kt │ │ │ │ ├── example-sequence-15.kt │ │ │ │ ├── example-sequence-16.kt │ │ │ │ └── test │ │ │ │ ├── EitherKnitTest.kt │ │ │ │ ├── IterableKnitTest.kt │ │ │ │ ├── OptionKnitTest.kt │ │ │ │ ├── RaiseKnitTest.kt │ │ │ │ └── SequenceKnitTest.kt │ │ │ └── nonJvmMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── core │ │ │ ├── ArrowCoreInternalException.kt │ │ │ ├── NonFatal.kt │ │ │ └── raise │ │ │ └── CancellationExceptionNoTrace.kt │ ├── arrow-eval │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-eval.api │ │ │ ├── arrow-eval.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-eval.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── eval │ │ │ │ ├── Eval.kt │ │ │ │ └── SuspendEval.kt │ │ │ ├── commonTest │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── eval │ │ │ │ ├── EvalTest.kt │ │ │ │ └── SuspendEvalTest.kt │ │ │ └── jvmTest │ │ │ └── kotlin │ │ │ └── examples │ │ │ ├── example-eval-01.kt │ │ │ ├── example-eval-02.kt │ │ │ ├── example-eval-03.kt │ │ │ └── example-eval-04.kt │ ├── arrow-functions │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-functions.api │ │ │ ├── arrow-functions.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-functions.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ ├── knit.test.template │ │ └── src │ │ │ ├── androidAndJvmMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ └── composition-jvm.kt │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ ├── composition.kt │ │ │ │ ├── currying.kt │ │ │ │ ├── memoization.kt │ │ │ │ └── partials.kt │ │ │ ├── commonTest │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ ├── AndThenTests.kt │ │ │ │ ├── CurryingTest.kt │ │ │ │ ├── FunctionSyntaxTest.kt │ │ │ │ └── MemoizationTest.kt │ │ │ ├── jvmTest │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── example-memoization-01.kt │ │ │ └── nonJvmMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── core │ │ │ └── composition-js.kt │ └── arrow-platform │ │ ├── api │ │ ├── android │ │ │ └── arrow-platform.api │ │ ├── arrow-platform.klib.api │ │ └── jvm │ │ │ └── arrow-platform.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ ├── androidMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── platform │ │ │ ├── Platform.kt │ │ │ └── test │ │ │ └── Flaky.kt │ │ ├── commonMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── platform │ │ │ ├── Platform.kt │ │ │ └── test │ │ │ └── Flaky.kt │ │ ├── jsMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── platform │ │ │ ├── Platform.kt │ │ │ └── test │ │ │ └── Flaky.kt │ │ ├── jvmMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── platform │ │ │ ├── PlatformJvm.kt │ │ │ └── test │ │ │ └── Flaky.kt │ │ ├── nativeMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── platform │ │ │ ├── Platform.kt │ │ │ └── test │ │ │ └── Flaky.kt │ │ └── wasmJsMain │ │ └── kotlin │ │ └── arrow │ │ └── platform │ │ ├── Platform.kt │ │ └── test │ │ └── Flaky.kt ├── fx │ ├── arrow-collectors │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-collectors.api │ │ │ ├── arrow-collectors.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-collectors.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ └── src │ │ │ ├── androidAndJvmMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── collectors │ │ │ │ ├── Collectors.kt │ │ │ │ └── JvmCollector.kt │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── collectors │ │ │ │ ├── Collect.kt │ │ │ │ ├── Collector.kt │ │ │ │ ├── Collectors.kt │ │ │ │ └── Zip.kt │ │ │ └── commonTest │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── collectors │ │ │ ├── CollectorsTest.kt │ │ │ └── Util.kt │ ├── arrow-fx-coroutines │ │ ├── README.MD │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-fx-coroutines.api │ │ │ ├── arrow-fx-coroutines.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-fx-coroutines.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ │ ├── androidAndJvmMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── fx │ │ │ │ └── coroutines │ │ │ │ └── ResourceExtensions.kt │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── fx │ │ │ │ └── coroutines │ │ │ │ ├── Bracket.kt │ │ │ │ ├── CountDownLatch.kt │ │ │ │ ├── CyclicBarrier.kt │ │ │ │ ├── ParMap.kt │ │ │ │ ├── ParZip.kt │ │ │ │ ├── ParZipOrAccumulate.kt │ │ │ │ ├── Race2.kt │ │ │ │ ├── Race3.kt │ │ │ │ ├── Resource.kt │ │ │ │ ├── await │ │ │ │ └── AwaitAllScope.kt │ │ │ │ └── flow.kt │ │ │ ├── commonTest │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── fx │ │ │ │ └── coroutines │ │ │ │ ├── BracketCaseTest.kt │ │ │ │ ├── CountDownLatchSpec.kt │ │ │ │ ├── CyclicBarrierSpec.kt │ │ │ │ ├── FlowTest.kt │ │ │ │ ├── Generators.kt │ │ │ │ ├── GuaranteeCaseTest.kt │ │ │ │ ├── KotestInlineUtils.kt │ │ │ │ ├── ParMapTest.kt │ │ │ │ ├── ParZip2Test.kt │ │ │ │ ├── ParZip3Test.kt │ │ │ │ ├── ParZip4Test.kt │ │ │ │ ├── ParZip5Test.kt │ │ │ │ ├── ParZip6Test.kt │ │ │ │ ├── ParZip7Test.kt │ │ │ │ ├── ParZip8Test.kt │ │ │ │ ├── ParZip9Test.kt │ │ │ │ ├── Platform.kt │ │ │ │ ├── RaceNTest.kt │ │ │ │ ├── ResourceAutoCloseTest.kt │ │ │ │ └── ResourceTest.kt │ │ │ ├── jsMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── fx │ │ │ │ └── coroutines │ │ │ │ └── ResourceExtensions.kt │ │ │ ├── jvmTest │ │ │ └── kotlin │ │ │ │ ├── arrow │ │ │ │ └── fx │ │ │ │ │ └── coroutines │ │ │ │ │ ├── BracketCaseJvmTest.kt │ │ │ │ │ ├── FlowJvmTest.kt │ │ │ │ │ ├── NamedThreadFactory.kt │ │ │ │ │ ├── ParMapJvmTest.kt │ │ │ │ │ ├── ParZip2JvmTest.kt │ │ │ │ │ ├── ParZip3JvmTest.kt │ │ │ │ │ ├── ParZip4JvmTest.kt │ │ │ │ │ ├── ParZip5JvmTest.kt │ │ │ │ │ ├── ParZip6JvmTest.kt │ │ │ │ │ ├── ParZip7JvmTest.kt │ │ │ │ │ ├── ParZip8JvmTest.kt │ │ │ │ │ ├── ParZip9JvmTest.kt │ │ │ │ │ ├── RaceNJvmTest.kt │ │ │ │ │ └── ResourceTestJvm.kt │ │ │ │ └── examples │ │ │ │ ├── example-bracket-01.kt │ │ │ │ ├── example-bracket-02.kt │ │ │ │ ├── example-flow-01.kt │ │ │ │ ├── example-flow-02.kt │ │ │ │ ├── example-flow-03.kt │ │ │ │ ├── example-flow-04.kt │ │ │ │ ├── example-parzip-01.kt │ │ │ │ ├── example-parzip-02.kt │ │ │ │ ├── example-parzip-03.kt │ │ │ │ ├── example-parzip-04.kt │ │ │ │ ├── example-parzip-05.kt │ │ │ │ ├── example-parzip-06.kt │ │ │ │ ├── example-parzip-07.kt │ │ │ │ ├── example-parzip-08.kt │ │ │ │ ├── example-parzip-09.kt │ │ │ │ ├── example-parzip-10.kt │ │ │ │ ├── example-parzip-11.kt │ │ │ │ ├── example-parzip-12.kt │ │ │ │ ├── example-parzip-13.kt │ │ │ │ ├── example-parzip-14.kt │ │ │ │ ├── example-parzip-15.kt │ │ │ │ ├── example-parzip-16.kt │ │ │ │ ├── example-race2-01.kt │ │ │ │ ├── example-race2-02.kt │ │ │ │ ├── example-resource-01.kt │ │ │ │ ├── example-resource-02.kt │ │ │ │ ├── example-resource-03.kt │ │ │ │ ├── example-resource-04.kt │ │ │ │ ├── example-resource-05.kt │ │ │ │ ├── example-resource-06.kt │ │ │ │ ├── example-resource-07.kt │ │ │ │ ├── example-resource-08.kt │ │ │ │ ├── example-resource-09.kt │ │ │ │ ├── example-resource-10.kt │ │ │ │ ├── example-resourceextensions-01.kt │ │ │ │ ├── example-resourceextensions-02.kt │ │ │ │ ├── example-resourceextensions-03.kt │ │ │ │ └── example-resourceextensions-04.kt │ │ │ ├── nativeMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── fx │ │ │ │ └── coroutines │ │ │ │ └── ResourceExtensions.kt │ │ │ └── wasmJsMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── fx │ │ │ └── coroutines │ │ │ └── ResourceExtensions.kt │ └── arrow-fx-stm │ │ ├── README.md │ │ ├── api │ │ ├── android │ │ │ └── arrow-fx-stm.api │ │ ├── arrow-fx-stm.klib.api │ │ └── jvm │ │ │ └── arrow-fx-stm.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ ├── androidAndJvmMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── fx │ │ │ └── stm │ │ │ └── internal │ │ │ └── RetryException.kt │ │ ├── commonMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── fx │ │ │ └── stm │ │ │ ├── STM.kt │ │ │ ├── TArray.kt │ │ │ ├── TMVar.kt │ │ │ ├── TMap.kt │ │ │ ├── TQueue.kt │ │ │ ├── TSemaphore.kt │ │ │ ├── TSet.kt │ │ │ ├── TVar.kt │ │ │ └── internal │ │ │ ├── Hamt.kt │ │ │ └── Impl.kt │ │ ├── commonTest │ │ └── kotlin │ │ │ └── arrow │ │ │ └── fx │ │ │ └── stm │ │ │ ├── STMTest.kt │ │ │ ├── TArrayTest.kt │ │ │ ├── TMVarTest.kt │ │ │ ├── TMapTest.kt │ │ │ ├── TQueueTest.kt │ │ │ └── TSemaphoreTest.kt │ │ ├── jvmTest │ │ └── kotlin │ │ │ └── examples │ │ │ ├── example-stm-01.kt │ │ │ ├── example-stm-02.kt │ │ │ ├── example-stm-03.kt │ │ │ ├── example-stm-04.kt │ │ │ ├── example-stm-05.kt │ │ │ ├── example-stm-06.kt │ │ │ ├── example-stm-07.kt │ │ │ ├── example-stm-08.kt │ │ │ ├── example-stm-09.kt │ │ │ ├── example-stm-10.kt │ │ │ ├── example-stm-11.kt │ │ │ ├── example-stm-12.kt │ │ │ ├── example-stm-13.kt │ │ │ ├── example-stm-14.kt │ │ │ ├── example-stm-15.kt │ │ │ ├── example-stm-16.kt │ │ │ ├── example-stm-17.kt │ │ │ ├── example-stm-18.kt │ │ │ ├── example-stm-19.kt │ │ │ ├── example-stm-20.kt │ │ │ ├── example-stm-21.kt │ │ │ ├── example-stm-22.kt │ │ │ ├── example-stm-23.kt │ │ │ ├── example-stm-24.kt │ │ │ ├── example-stm-25.kt │ │ │ ├── example-stm-26.kt │ │ │ ├── example-stm-27.kt │ │ │ ├── example-stm-28.kt │ │ │ ├── example-stm-29.kt │ │ │ ├── example-stm-30.kt │ │ │ ├── example-stm-31.kt │ │ │ ├── example-stm-32.kt │ │ │ ├── example-stm-33.kt │ │ │ ├── example-stm-34.kt │ │ │ ├── example-stm-35.kt │ │ │ ├── example-stm-36.kt │ │ │ ├── example-stm-37.kt │ │ │ ├── example-stm-38.kt │ │ │ ├── example-stm-39.kt │ │ │ ├── example-stm-40.kt │ │ │ ├── example-stm-41.kt │ │ │ ├── example-stm-42.kt │ │ │ ├── example-stm-43.kt │ │ │ ├── example-stm-44.kt │ │ │ ├── example-stm-45.kt │ │ │ ├── example-stm-46.kt │ │ │ ├── example-stm-47.kt │ │ │ ├── example-stm-48.kt │ │ │ ├── example-stm-49.kt │ │ │ ├── example-stm-50.kt │ │ │ ├── example-stm-51.kt │ │ │ ├── example-stm-52.kt │ │ │ ├── example-stm-53.kt │ │ │ ├── example-stm-54.kt │ │ │ ├── example-stm-55.kt │ │ │ ├── example-stm-56.kt │ │ │ ├── example-stm-57.kt │ │ │ ├── example-stm-58.kt │ │ │ ├── example-stm-59.kt │ │ │ ├── example-stm-60.kt │ │ │ ├── example-tarray-01.kt │ │ │ ├── example-tarray-02.kt │ │ │ ├── example-tarray-03.kt │ │ │ ├── example-tarray-04.kt │ │ │ ├── example-tarray-05.kt │ │ │ ├── example-tmap-01.kt │ │ │ ├── example-tmap-02.kt │ │ │ ├── example-tmap-03.kt │ │ │ ├── example-tmap-04.kt │ │ │ ├── example-tmap-05.kt │ │ │ ├── example-tmap-06.kt │ │ │ ├── example-tmvar-01.kt │ │ │ ├── example-tmvar-02.kt │ │ │ ├── example-tmvar-03.kt │ │ │ ├── example-tmvar-04.kt │ │ │ ├── example-tmvar-05.kt │ │ │ ├── example-tmvar-06.kt │ │ │ ├── example-tmvar-07.kt │ │ │ ├── example-tmvar-08.kt │ │ │ ├── example-tqueue-01.kt │ │ │ ├── example-tqueue-02.kt │ │ │ ├── example-tqueue-03.kt │ │ │ ├── example-tqueue-04.kt │ │ │ ├── example-tqueue-05.kt │ │ │ ├── example-tqueue-06.kt │ │ │ ├── example-tqueue-07.kt │ │ │ ├── example-tqueue-08.kt │ │ │ ├── example-tqueue-09.kt │ │ │ ├── example-tqueue-10.kt │ │ │ ├── example-tsemaphore-01.kt │ │ │ ├── example-tsemaphore-02.kt │ │ │ ├── example-tsemaphore-03.kt │ │ │ ├── example-tsemaphore-04.kt │ │ │ ├── example-tset-01.kt │ │ │ ├── example-tset-02.kt │ │ │ ├── example-tset-03.kt │ │ │ ├── example-tvar-01.kt │ │ │ ├── example-tvar-02.kt │ │ │ ├── example-tvar-03.kt │ │ │ ├── example-tvar-04.kt │ │ │ └── example-tvar-05.kt │ │ └── nonJvmMain │ │ └── kotlin │ │ └── arrow │ │ └── fx │ │ └── stm │ │ └── internal │ │ └── RetryException.kt ├── integrations │ ├── arrow-core-jackson │ │ ├── api │ │ │ └── arrow-core-jackson.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ │ ├── main │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── integrations │ │ │ │ └── jackson │ │ │ │ └── module │ │ │ │ ├── ArrowModule.kt │ │ │ │ ├── EitherModule.kt │ │ │ │ ├── IorModule.kt │ │ │ │ ├── NonEmptyCollections.kt │ │ │ │ ├── OptionModule.kt │ │ │ │ └── internal │ │ │ │ ├── ElementDeserializer.kt │ │ │ │ ├── ProductTypeDeserializer.kt │ │ │ │ ├── ProductTypeSerializer.kt │ │ │ │ ├── UnionTypeDeserializer.kt │ │ │ │ └── UnionTypeSerializer.kt │ │ │ └── test │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── integrations │ │ │ └── jackson │ │ │ └── module │ │ │ ├── DataHelpers.kt │ │ │ ├── EitherModuleTest.kt │ │ │ ├── ExampleTest.kt │ │ │ ├── IorModuleTest.kt │ │ │ ├── KotestInlineUtils.kt │ │ │ ├── NonEmptyListModuleTest.kt │ │ │ ├── NonEmptySetModuleTest.kt │ │ │ ├── OptionModuleTest.kt │ │ │ └── TestHelper.kt │ ├── arrow-core-retrofit │ │ ├── api │ │ │ └── arrow-core-retrofit.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ │ ├── main │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── retrofit │ │ │ │ └── adapter │ │ │ │ └── either │ │ │ │ ├── ArrowEitherCallAdapter.kt │ │ │ │ ├── ArrowResponseECallAdapter.kt │ │ │ │ ├── EitherCallAdapterFactory.kt │ │ │ │ ├── ResponseE.kt │ │ │ │ ├── eitherAdapter.kt │ │ │ │ └── networkhandling │ │ │ │ ├── CallError.kt │ │ │ │ └── NetworkEitherCallAdapter.kt │ │ │ └── test │ │ │ └── kotlin │ │ │ ├── arrow │ │ │ └── retrofit │ │ │ │ └── adapter │ │ │ │ ├── either │ │ │ │ ├── ArrowEitherCallAdapterTest.kt │ │ │ │ ├── ArrowResponseEAdapterTest.kt │ │ │ │ └── networkhandling │ │ │ │ │ ├── CallErrorTestClient.kt │ │ │ │ │ └── NetworkEitherCallAdapterTest.kt │ │ │ │ ├── mock │ │ │ │ ├── ErrorMock.kt │ │ │ │ └── ResponseMock.kt │ │ │ │ └── retrofit │ │ │ │ └── SuspendApiTestClient.kt │ │ │ └── examples │ │ │ ├── example-arrow-retrofit-01.kt │ │ │ └── example-arrow-retrofit-02.kt │ ├── arrow-core-serialization │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-core-serialization.api │ │ │ ├── arrow-core-serialization.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-core-serialization.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ └── src │ │ │ ├── commonMain │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── core │ │ │ │ └── serialization │ │ │ │ ├── EitherSerializer.kt │ │ │ │ ├── IorSerializer.kt │ │ │ │ ├── NonEmptyCollectionSerializers.kt │ │ │ │ ├── OptionSerializer.kt │ │ │ │ └── SerializersModule.kt │ │ │ └── commonTest │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── core │ │ │ └── serialization │ │ │ ├── BackAgainTest.kt │ │ │ ├── Generators.kt │ │ │ └── ModuleTest.kt │ ├── arrow-raise-ktor-server │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-raise-ktor-server.api │ │ │ ├── arrow-raise-ktor-server.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-raise-ktor-server.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ │ └── commonMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── raise │ │ │ └── ktor │ │ │ └── server │ │ │ ├── OutgoingContent.kt │ │ │ ├── accumulate.kt │ │ │ ├── predef.kt │ │ │ └── routing.kt │ └── arrow-resilience-ktor-client │ │ ├── api │ │ ├── android │ │ │ └── arrow-resilience-ktor-client.api │ │ ├── arrow-resilience-ktor-client.klib.api │ │ └── jvm │ │ │ └── arrow-resilience-ktor-client.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ ├── commonMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── resilience │ │ │ └── ktor │ │ │ └── client │ │ │ ├── HttpCircuitBreaker.kt │ │ │ └── HttpRequestSchedule.kt │ │ └── jvmTest │ │ └── kotlin │ │ └── arrow │ │ └── resilience │ │ └── ktor │ │ └── client │ │ └── HttpRequestScheduleTest.kt ├── optics │ ├── arrow-optics-compose │ │ ├── api │ │ │ ├── android │ │ │ │ └── arrow-optics-compose.api │ │ │ ├── arrow-optics-compose.klib.api │ │ │ └── jvm │ │ │ │ └── arrow-optics-compose.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ └── src │ │ │ └── commonMain │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── optics │ │ │ ├── Copy.kt │ │ │ ├── Flow.kt │ │ │ └── State.kt │ ├── arrow-optics-ksp-plugin │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ └── src │ │ │ ├── main │ │ │ ├── kotlin │ │ │ │ └── arrow │ │ │ │ │ └── optics │ │ │ │ │ └── plugin │ │ │ │ │ ├── DeclarationUtils.kt │ │ │ │ │ ├── OpticsProcessor.kt │ │ │ │ │ ├── OpticsProcessorOptions.kt │ │ │ │ │ ├── OpticsProcessorProvider.kt │ │ │ │ │ └── internals │ │ │ │ │ ├── domain.kt │ │ │ │ │ ├── dsl.kt │ │ │ │ │ ├── errors.kt │ │ │ │ │ ├── info.kt │ │ │ │ │ ├── iso.kt │ │ │ │ │ ├── lenses.kt │ │ │ │ │ ├── prism.kt │ │ │ │ │ ├── processor.kt │ │ │ │ │ ├── snippets.kt │ │ │ │ │ ├── targets.kt │ │ │ │ │ └── utils.kt │ │ │ └── resources │ │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── com.google.devtools.ksp.processing.SymbolProcessorProvider │ │ │ └── test │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── optics │ │ │ └── plugin │ │ │ ├── Compilation.kt │ │ │ ├── CopyTest.kt │ │ │ ├── DSLTests.kt │ │ │ ├── IsoTests.kt │ │ │ ├── LensTests.kt │ │ │ ├── OptionalTests.kt │ │ │ ├── PrismTests.kt │ │ │ └── Utils.kt │ ├── arrow-optics-reflect │ │ ├── api │ │ │ └── arrow-optics-reflect.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ └── src │ │ │ ├── main │ │ │ └── kotlin │ │ │ │ └── arrow │ │ │ │ └── optics │ │ │ │ └── Reflection.kt │ │ │ └── test │ │ │ └── kotlin │ │ │ └── arrow │ │ │ └── optics │ │ │ └── ReflectionTest.kt │ └── arrow-optics │ │ ├── api │ │ ├── android │ │ │ └── arrow-optics.api │ │ ├── arrow-optics.klib.api │ │ └── jvm │ │ │ └── arrow-optics.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ ├── commonMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── optics │ │ │ ├── Copy.kt │ │ │ ├── Delicate.kt │ │ │ ├── Every.kt │ │ │ ├── Iso.kt │ │ │ ├── Lens.kt │ │ │ ├── Optional.kt │ │ │ ├── Prism.kt │ │ │ ├── Traversal.kt │ │ │ ├── dsl │ │ │ ├── at.kt │ │ │ ├── delicate.kt │ │ │ ├── either.kt │ │ │ ├── every.kt │ │ │ ├── filterIndex.kt │ │ │ ├── index.kt │ │ │ ├── nullable.kt │ │ │ └── option.kt │ │ │ ├── predef.kt │ │ │ ├── regex │ │ │ ├── Regex.kt │ │ │ └── dsl │ │ │ │ └── Regex.kt │ │ │ ├── std │ │ │ └── list.kt │ │ │ └── typeclasses │ │ │ ├── At.kt │ │ │ ├── Cons.kt │ │ │ ├── FilterIndex.kt │ │ │ ├── Index.kt │ │ │ └── Snoc.kt │ │ └── commonTest │ │ └── kotlin │ │ ├── arrow │ │ └── optics │ │ │ ├── CopyTest.kt │ │ │ ├── EveryTest.kt │ │ │ ├── IsoTest.kt │ │ │ ├── LensTest.kt │ │ │ ├── OptionalTest.kt │ │ │ ├── PrismTest.kt │ │ │ ├── TestDomain.kt │ │ │ ├── TraversalTest.kt │ │ │ ├── dsl │ │ │ ├── AtSyntaxTest.kt │ │ │ ├── EverySyntaxTest.kt │ │ │ └── Wrapper.kt │ │ │ ├── instances │ │ │ ├── AtInstanceTest.kt │ │ │ ├── ConsInstanceTest.kt │ │ │ ├── EitherInstanceTest.kt │ │ │ ├── FilterIndexInstanceTest.kt │ │ │ ├── IndexInstanceTest.kt │ │ │ └── SnocInstanceTest.kt │ │ │ ├── regex │ │ │ └── RegexTest.kt │ │ │ ├── std │ │ │ ├── ListTest.kt │ │ │ ├── MapTest.kt │ │ │ ├── NonEmptyListTest.kt │ │ │ ├── OptionTest.kt │ │ │ ├── StringTest.kt │ │ │ └── TupleTest.kt │ │ │ └── test │ │ │ ├── Generators.kt │ │ │ └── laws │ │ │ ├── IsoLaws.kt │ │ │ ├── Laws.kt │ │ │ ├── LensLaws.kt │ │ │ ├── OptionalLaws.kt │ │ │ ├── PrismLaws.kt │ │ │ └── TraversalLaws.kt │ │ └── examples │ │ └── example-optional-01.kt ├── resilience │ └── arrow-resilience │ │ ├── README.md │ │ ├── api │ │ ├── android │ │ │ └── arrow-resilience.api │ │ ├── arrow-resilience.klib.api │ │ └── jvm │ │ │ └── arrow-resilience.api │ │ ├── build.gradle.kts │ │ ├── gradle.properties │ │ ├── knit.properties │ │ └── src │ │ ├── commonMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── resilience │ │ │ ├── CircuitBreaker.kt │ │ │ ├── Saga.kt │ │ │ ├── Schedule.kt │ │ │ └── flow.kt │ │ ├── commonTest │ │ └── kotlin │ │ │ └── arrow │ │ │ └── resilience │ │ │ ├── CircuitBreakerTest.kt │ │ │ ├── FlowTest.kt │ │ │ ├── SagaSpec.kt │ │ │ └── ScheduleTest.kt │ │ └── jvmTest │ │ └── kotlin │ │ └── examples │ │ ├── example-circuitbreaker-01.kt │ │ ├── example-circuitbreaker-02.kt │ │ └── example-flow-01.kt ├── stack │ ├── README.md │ ├── build.gradle.kts │ └── gradle.properties └── suspendapp │ ├── suspendapp-ktor │ ├── api │ │ ├── android │ │ │ └── suspendapp-ktor.api │ │ ├── jvm │ │ │ └── suspendapp-ktor.api │ │ ├── suspendapp-ktor.api │ │ └── suspendapp-ktor.klib.api │ ├── build.gradle.kts │ ├── gradle.properties │ ├── knit.properties │ └── src │ │ ├── commonMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── continuations │ │ │ └── ktor │ │ │ └── KtorServer.kt │ │ ├── jvmMain │ │ └── kotlin │ │ │ └── arrow │ │ │ └── continuations │ │ │ └── ktor │ │ │ └── KtorServer.jvm.kt │ │ └── nonJvmMain │ │ └── kotlin │ │ └── arrow │ │ └── continuations │ │ └── ktor │ │ └── KtorServer.nonJvm.kt │ ├── suspendapp-test-app │ ├── build.gradle.kts │ └── src │ │ ├── commonMain │ │ └── kotlin │ │ │ └── app.kt │ │ ├── jsMain │ │ └── kotlin │ │ │ └── main.kt │ │ ├── jvmMain │ │ └── kotlin │ │ │ └── main.kt │ │ ├── nativeMain │ │ └── kotlin │ │ │ └── main.kt │ │ └── wasmJsMain │ │ └── kotlin │ │ └── main.kt │ ├── suspendapp-test-runner │ ├── build.gradle.kts │ └── src │ │ └── test │ │ └── kotlin │ │ ├── JsSpec.kt │ │ ├── JvmSpec.kt │ │ ├── NativeSpec.kt │ │ ├── ProcessProvider.kt │ │ ├── SuspendAppTest.kt │ │ └── WasmJsSpec.kt │ └── suspendapp │ ├── api │ ├── suspendapp.api │ └── suspendapp.klib.api │ ├── build.gradle.kts │ ├── gradle.properties │ ├── knit.properties │ └── src │ ├── commonMain │ └── kotlin │ │ └── arrow │ │ └── continuations │ │ ├── Process.kt │ │ └── SuspendApp.kt │ ├── jsMain │ └── kotlin │ │ └── arrow │ │ └── continuations │ │ └── Enviroment.js.kt │ ├── jvmMain │ └── kotlin │ │ └── arrow │ │ └── continuations │ │ └── Enviroment.jvm.kt │ ├── nativeMain │ └── kotlin │ │ └── arrow │ │ └── continuations │ │ └── Enviroment.native.kt │ └── wasmJsMain │ └── kotlin │ └── arrow │ └── continuations │ └── Enviroment.js.kt ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ └── arrow.kotlin.gradle.kts ├── generator-scripts ├── README.md └── tuple.generator.kts ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── kotlin-js-store └── yarn.lock ├── renovate.json ├── settings.gradle.kts └── static ├── CNAME └── img ├── doc └── download-report.png └── logo ├── arrow-dark.svg ├── arrow.svg └── logo-icon.svg /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{kt,kts}] 2 | indent_size = 2 3 | insert_final_newline = true 4 | max_line_length = off 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/add-company-logo-to-users.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Add company logo to users 3 | about: 'If you’re using Arrow in Production, submit this issue to get your logo added 4 | to the Arrow_kt.io website under the list of users! ' 5 | title: "[Add company logo]" 6 | labels: Arrow in Production 7 | assignees: MaureenElsberry 8 | 9 | --- 10 | 11 | **Company Name:** 12 | 13 | **Website:** 14 | 15 | **Logo:** 16 | 17 | Please upload a high-res logo of either .svg or .png to this issue. 18 | 19 | - [ ] By checking this box, I’m confirming that I have permission to add this company to the public list of users. 20 | 21 | **Optional Information:** 22 | 23 | Tell us a bit on how you’re using Arrow! We’d love to hear it: 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: What would you like to see in Arrow? 4 | title: [Request] 5 | labels: '' 6 | assignees: Maintainers 7 | 8 | --- 9 | 10 | What version are you currently using? 11 | 12 | What would you like to see? 13 | -------------------------------------------------------------------------------- /.github/workflows/auto-update-pr.yaml: -------------------------------------------------------------------------------- 1 | name: auto-update-pr 2 | on: 3 | push: 4 | branches-ignore: 5 | - main 6 | 7 | jobs: 8 | autoupdate: 9 | name: Auto update PR 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: docker://chinthakagodawita/autoupdate-action:v1 13 | env: 14 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 15 | PR_FILTER: "ready_for_review" 16 | EXCLUDED_LABELS: "Skip Auto Update PRs" 17 | MERGE_MSG: "Branch was auto-updated." 18 | -------------------------------------------------------------------------------- /.idea/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arrow-kt/arrow/1b251d145addc99caf3f16a6b0bd075f1ed6541c/.idea/icon.png -------------------------------------------------------------------------------- /arrow-libs/core/arrow-annotations/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-annotations/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Annotations 3 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-annotations/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.annotations.examples 2 | knit.dir=src/commonTest/kotlin/examples/ 3 | 4 | test.package=arrow.annotations.examples.test 5 | test.dir=src/commonTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-annotations/src/commonMain/kotlin/arrow/optics/optics.kt: -------------------------------------------------------------------------------- 1 | package arrow.optics 2 | 3 | import kotlin.annotation.AnnotationRetention.SOURCE 4 | import kotlin.annotation.AnnotationTarget.CLASS 5 | 6 | @Retention(SOURCE) 7 | @Target(CLASS) 8 | /** 9 | * Empty arrays means "Everything that matches annotated class" 10 | */ 11 | public annotation class optics(val targets: Array = emptyArray()) 12 | 13 | public enum class OpticsTarget { 14 | ISO, LENS, PRISM, OPTIONAL, DSL 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi 2 | 3 | plugins { 4 | id("arrow.kotlin") 5 | } 6 | 7 | kotlin { 8 | @OptIn(ExperimentalKotlinGradlePluginApi::class) 9 | compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") 10 | 11 | sourceSets { 12 | commonTest { 13 | dependencies { 14 | implementation(projects.arrowFxCoroutines) 15 | implementation(projects.arrowPlatform) 16 | implementation(libs.bundles.testing) 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Atomic 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.atomic.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.atomic.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/androidAndJvmMain/kotlin/arrow/atomic/Atomic.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("AtomicActual") 2 | 3 | package arrow.atomic 4 | 5 | import java.util.concurrent.atomic.AtomicReference 6 | 7 | public actual typealias Atomic = AtomicReference 8 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/androidAndJvmMain/kotlin/arrow/atomic/AtomicInt.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("AtomicIntActual") 2 | 3 | package arrow.atomic 4 | 5 | import java.util.concurrent.atomic.AtomicInteger 6 | 7 | public actual typealias AtomicInt = AtomicInteger 8 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/androidAndJvmMain/kotlin/arrow/atomic/AtomicLong.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("AtomicLongActual") 2 | 3 | package arrow.atomic 4 | 5 | import java.util.concurrent.atomic.AtomicLong 6 | 7 | public actual typealias AtomicLong = AtomicLong 8 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/commonTest/kotlin/arrow/atomic/Platform.kt: -------------------------------------------------------------------------------- 1 | package arrow.atomic 2 | 3 | import kotlinx.coroutines.test.runTest 4 | import kotlinx.coroutines.Dispatchers 5 | import kotlinx.coroutines.test.TestResult 6 | import kotlinx.coroutines.withContext 7 | 8 | fun runTestWithDelay(testBody: suspend () -> Unit): TestResult = runTest { 9 | withContext(Dispatchers.Default) { 10 | testBody() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/jsMain/kotlin/arrow/atomic/Atomic.kt: -------------------------------------------------------------------------------- 1 | package arrow.atomic 2 | 3 | public actual class Atomic actual constructor(initialValue: V) { 4 | private var internalValue: V = initialValue 5 | 6 | public actual fun get(): V = internalValue 7 | 8 | public actual fun set(value: V) { 9 | internalValue = value 10 | } 11 | 12 | public actual fun compareAndSet(expected: V, new: V): Boolean = 13 | if (expected === internalValue) { 14 | internalValue = new 15 | true 16 | } else { 17 | false 18 | } 19 | 20 | public actual fun getAndSet(value: V): V { 21 | val old = internalValue 22 | internalValue = value 23 | return old 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/jvmTest/kotlin/examples/example-atomic-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Atomic.kt by Knit tool. Do not edit. 2 | package arrow.atomic.examples.exampleAtomic01 3 | 4 | import arrow.atomic.AtomicInt 5 | import arrow.atomic.update 6 | import arrow.atomic.value 7 | import arrow.fx.coroutines.parMap 8 | 9 | suspend fun main() { 10 | val count = AtomicInt(0) 11 | (0 until 20_000).parMap { 12 | count.update(Int::inc) 13 | } 14 | println(count.value) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/nativeMain/kotlin/arrow/atomic/Atomic.kt: -------------------------------------------------------------------------------- 1 | package arrow.atomic 2 | 3 | import kotlin.concurrent.AtomicReference 4 | 5 | public actual class Atomic actual constructor(initialValue: V) { 6 | private val inner = AtomicReference(initialValue) 7 | 8 | public actual fun get(): V = inner.value 9 | 10 | public actual fun set(value: V) { 11 | inner.value = value 12 | } 13 | 14 | public actual fun compareAndSet(expected: V, new: V): Boolean = 15 | inner.compareAndSet(expected, new) 16 | 17 | public actual fun getAndSet(value: V): V = 18 | inner.getAndSet(value) 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-atomic/src/wasmJsMain/kotlin/arrow/atomic/Atomic.kt: -------------------------------------------------------------------------------- 1 | package arrow.atomic 2 | 3 | public actual class Atomic actual constructor(initialValue: V) { 4 | private var internalValue: V = initialValue 5 | 6 | public actual fun get(): V = internalValue 7 | 8 | public actual fun set(value: V) { 9 | internalValue = value 10 | } 11 | 12 | public actual fun compareAndSet(expected: V, new: V): Boolean = 13 | if (expected === internalValue) { 14 | internalValue = new 15 | true 16 | } else { 17 | false 18 | } 19 | 20 | public actual fun getAndSet(value: V): V { 21 | val old = internalValue 22 | internalValue = value 23 | return old 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-autoclose/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | implementation(projects.arrowAtomic) 10 | } 11 | } 12 | commonTest { 13 | dependencies { 14 | implementation(libs.bundles.testing) 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-autoclose/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow AutoCloseable 3 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-autoclose/knit.code.include: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ${file.name} by Knit tool. Do not edit. 2 | package ${knit.package}.${knit.name} 3 | 4 | import arrow.AutoCloseScope 5 | import arrow.autoCloseScope 6 | 7 | public class Scanner( 8 | private val path: String, 9 | ) : AutoCloseable, Iterable by listOf("Hello", "World", "!") { 10 | override fun close(): Unit = Unit 11 | } 12 | 13 | public class Printer(private val path: String) : AutoCloseable { 14 | public fun print(line: String): Unit = Unit 15 | override fun close(): Unit = Unit 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-autoclose/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.autocloseable.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.autocloseable.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ 6 | 7 | knit.include=knit.code.include -------------------------------------------------------------------------------- /arrow-libs/core/arrow-autoclose/src/androidAndJvmMain/kotlin/arrow/throwIfFatal.kt: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import kotlin.coroutines.cancellation.CancellationException 4 | 5 | @PublishedApi 6 | internal actual fun Throwable.throwIfFatal(): Throwable = 7 | when(this) { 8 | is VirtualMachineError, is ThreadDeath, is InterruptedException, is LinkageError, is CancellationException -> throw this 9 | else -> this 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-autoclose/src/nonJvmMain/kotlin/arrow/throwIfFatal.kt: -------------------------------------------------------------------------------- 1 | package arrow 2 | 3 | import kotlin.coroutines.cancellation.CancellationException 4 | 5 | @PublishedApi 6 | internal actual fun Throwable.throwIfFatal(): Throwable = if (this is CancellationException) throw this else this 7 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-cache4k/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowCore) 10 | api(libs.cache4k) 11 | } 12 | } 13 | commonTest { 14 | dependencies { 15 | implementation(libs.bundles.testing) 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-cache4k/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Cache4k 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core-high-arity/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowCore) 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core-high-arity/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Core High Arity 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core-high-arity/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.core.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.core.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/test/ 6 | test.template=knit.test.template -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core-high-arity/knit.test.template: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ${file.name} by Knit tool. Do not edit. 2 | package ${test.package} 3 | 4 | import io.kotest.core.spec.style.StringSpec 5 | 6 | class ${test.name} : StringSpec({ 7 | <#list cases as case> 8 | "${case.name}" { 9 | ${case.knit.package}.${case.knit.name}.test() 10 | } 11 | 12 | 13 | }) { 14 | override fun timeout(): Long = 1000 15 | } -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi 2 | 3 | plugins { 4 | id("arrow.kotlin") 5 | } 6 | 7 | kotlin { 8 | @OptIn(ExperimentalKotlinGradlePluginApi::class) 9 | compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") 10 | 11 | sourceSets { 12 | commonMain { 13 | dependencies { 14 | api(projects.arrowAtomic) 15 | api(projects.arrowAnnotations) 16 | } 17 | } 18 | 19 | commonTest { 20 | dependencies { 21 | implementation(projects.arrowFxCoroutines) 22 | implementation(projects.arrowPlatform) 23 | implementation(libs.bundles.testing) 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Core 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.core.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.core.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/test/ 6 | test.template=knit.test.template -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/knit.test.template: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ${file.name} by Knit tool. Do not edit. 2 | package ${test.package} 3 | 4 | import kotlin.test.Test 5 | import kotlinx.coroutines.test.runTest 6 | 7 | class ${test.name} { 8 | <#list cases as case> 9 | @Test fun ${case.knit.name}() = runTest { 10 | ${case.knit.package}.${case.knit.name}.test() 11 | } 12 | 13 | 14 | } -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/androidAndJvmMain/kotlin/arrow/core/ArrowCoreInternalException.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | @PublishedApi 4 | internal actual object ArrowCoreInternalException : RuntimeException( 5 | "Arrow-Core internal error. Please let us know and create a ticket at https://github.com/arrow-kt/arrow-core/issues/new/choose", 6 | null 7 | ) { 8 | override fun fillInStackTrace(): Throwable = this 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/androidAndJvmMain/kotlin/arrow/core/MemoizedDeepRecursiveFunction.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | import java.util.concurrent.ConcurrentHashMap 4 | import java.util.concurrent.ConcurrentMap 5 | 6 | @JvmInline 7 | public value class ConcurrentMapMemoizationCache( 8 | private val cache: ConcurrentMap = ConcurrentHashMap(), 9 | ): MemoizationCache { 10 | override fun get(key: K): V? = cache.get(key) 11 | override fun set(key: K, value: V): V = cache.putIfAbsent(key, value) ?: value 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/androidAndJvmMain/kotlin/arrow/core/NonFatal.kt: -------------------------------------------------------------------------------- 1 | @file:JvmMultifileClass 2 | @file:JvmName("NonFatalKt") 3 | package arrow.core 4 | 5 | import kotlin.coroutines.cancellation.CancellationException 6 | 7 | public actual fun NonFatal(t: Throwable): Boolean = 8 | when (t) { 9 | is VirtualMachineError, is ThreadDeath, is InterruptedException, is LinkageError, is CancellationException -> false 10 | else -> true 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/androidAndJvmMain/kotlin/arrow/core/SortedMapK.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | import java.util.SortedMap 4 | 5 | public fun SortedMap.foldLeft(b: SortedMap, f: (SortedMap, Map.Entry) -> SortedMap): SortedMap { 6 | var result = b 7 | this.forEach { result = f(result, it) } 8 | return result 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/ArrowCoreInternalException.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | @PublishedApi 4 | internal expect object ArrowCoreInternalException : RuntimeException 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Pair.kt: -------------------------------------------------------------------------------- 1 | @file:JvmMultifileClass 2 | @file:JvmName("TupleNKt") 3 | 4 | package arrow.core 5 | 6 | import kotlin.jvm.JvmMultifileClass 7 | import kotlin.jvm.JvmName 8 | 9 | public operator fun , B : Comparable> Pair.compareTo(other: Pair): Int { 10 | val first = first.compareTo(other.first) 11 | return if (first == 0) second.compareTo(other.second) 12 | else first 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Triple.kt: -------------------------------------------------------------------------------- 1 | @file:JvmMultifileClass 2 | @file:JvmName("TupleNKt") 3 | 4 | package arrow.core 5 | 6 | import kotlin.jvm.JvmMultifileClass 7 | import kotlin.jvm.JvmName 8 | 9 | public operator fun , B : Comparable, C : Comparable> Triple.compareTo(other: Triple): Int { 10 | val first = first.compareTo(other.first) 11 | return if (first == 0) { 12 | val second = second.compareTo(other.second) 13 | if (second == 0) third.compareTo(other.third) 14 | else second 15 | } else first 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/string.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | public fun String.escaped(): String = 4 | replace("\n", "\\n").replace("\r", "\\r") 5 | .replace("\"", "\\\"").replace("\'", "\\\'") 6 | .replace("\t", "\\t").replace("\b", "\\b") 7 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/utils.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | public fun constant(t: T): (P1) -> T = { _: P1 -> t } 4 | 5 | public typealias Predicate = (T) -> Boolean 6 | 7 | public fun Predicate.mapNullable(): (T?) -> Boolean = { t -> t?.let { this@mapNullable(it) } ?: false } 8 | 9 | public const val DeprecatedUnsafeAccess: String = "This function is unsafe and will be removed in future versions of Arrow. Replace or import `arrow.syntax.unsafe.*` if you wish to continue using it in this way" 10 | public const val DeprecatedAmbiguity: String = "This function is ambiguous and will be removed in future versions of Arrow" 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/BooleanTest.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | import arrow.core.test.laws.MonoidLaws 4 | import arrow.core.test.testLaws 5 | import io.kotest.property.Arb 6 | import io.kotest.property.arbitrary.boolean 7 | import kotlin.test.Test 8 | 9 | class BooleanTest{ 10 | @Test fun monoidLaws() = 11 | testLaws( 12 | MonoidLaws("Boolean", true, { x, y -> x && y }, Arb.boolean()) 13 | ) 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/NonFatalTest.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | import io.kotest.matchers.shouldBe 4 | import kotlin.test.Test 5 | 6 | class NonFatalTest { 7 | val nonFatals: List = 8 | listOf( 9 | RuntimeException(), 10 | Exception(), 11 | Throwable(), 12 | NotImplementedError() 13 | ) 14 | 15 | @Test 16 | fun usingInvoke() { 17 | nonFatals.forEach { 18 | NonFatal(it) shouldBe true 19 | } 20 | } 21 | 22 | @Test fun usingNotFatalOrThrow() { 23 | nonFatals.forEach { 24 | it.nonFatalOrThrow() shouldBe it 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/raise/predef.kt: -------------------------------------------------------------------------------- 1 | package arrow.core.raise 2 | 3 | import arrow.core.identity 4 | 5 | suspend fun Effect.value(): A = fold(::identity, ::identity) 6 | 7 | suspend fun Effect.runCont(): Any? = fold(::identity, ::identity) 8 | 9 | fun EagerEffect.value(): A = fold(::identity, ::identity) 10 | 11 | fun EagerEffect.runCont(): Any? = fold(::identity, ::identity) 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/IorUsage.java: -------------------------------------------------------------------------------- 1 | package arrow.core; 2 | 3 | public class IorUsage { 4 | 5 | public void testUsage() { 6 | Ior, Integer> bothNel = Ior.bothNel(1, 2); 7 | Ior fromNullables = Ior.fromNullables(1, null); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/java/arrow/core/OptionUsage.java: -------------------------------------------------------------------------------- 1 | package arrow.core; 2 | 3 | public class OptionUsage { 4 | 5 | public void testUsage() { 6 | Option fromNullable = Option.fromNullable(null); 7 | Option invoke = Option.invoke(1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ErrorHandlers.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEffectError01 3 | 4 | import arrow.core.raise.effect 5 | import arrow.core.raise.recover 6 | 7 | object User 8 | object Error 9 | 10 | val error = effect { raise(Error) } // Raise(error) 11 | 12 | val a = error.recover { _ -> User } // Success(User) 13 | val b = error.recover { _ -> raise("other-failure") } // Raise(other-failure) 14 | val c = error.recover { _ -> throw RuntimeException("BOOM") } // Exception(BOOM) 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ErrorHandlers.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEffectError02 3 | 4 | import arrow.core.raise.effect 5 | import arrow.core.raise.catch 6 | 7 | object User 8 | object Error 9 | 10 | val exception = effect { throw RuntimeException("BOOM") } // Exception(BOOM) 11 | 12 | val a = exception.catch { error -> error.message?.length ?: -1 } // Success(5) 13 | val b = exception.catch { raise(Error) } // Raise(error) 14 | val c = exception.catch { throw RuntimeException("other-failure") } // Exception(other-failure) 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ErrorHandlers.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEffectError03 3 | 4 | import arrow.core.raise.effect 5 | import arrow.core.raise.catch 6 | 7 | object User 8 | object Error 9 | 10 | val x = effect { 11 | throw IllegalArgumentException("builder missed args") 12 | }.catch { raise(Error) } 13 | 14 | val y = effect { 15 | throw IllegalArgumentException("builder missed args") 16 | }.catch { raise(Error) } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ErrorHandlers.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEffectError04 3 | 4 | import arrow.core.raise.effect 5 | import arrow.core.raise.mapError 6 | 7 | object User 8 | object Error 9 | 10 | val error = effect { raise(Error) } // Raise(error) 11 | 12 | val a = error.mapError { _ -> "some-failure" } // Raise(some-failure) 13 | val b = error.mapError(Any::toString) // Raise(Error) 14 | val c = error.mapError { _ -> throw RuntimeException("BOOM") } // Exception(BOOM) 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-effect-error-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ErrorHandlers.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEffectError05 3 | 4 | import arrow.core.raise.eagerEffect 5 | import arrow.core.raise.mapError 6 | 7 | object User 8 | object Error 9 | 10 | val error = eagerEffect { raise(Error) } // Raise(error) 11 | 12 | val a = error.mapError { _ -> "some-failure" } // Raise(some-failure) 13 | val b = error.mapError(Any::toString) // Raise(Error) 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither01 3 | 4 | val throwsSomeStuff: (Int) -> Double = {x -> x.toDouble()} 5 | val throwsOtherThings: (Double) -> String = {x -> x.toString()} 6 | val moreThrowing: (String) -> List = {x -> listOf(x)} 7 | val magic: (Int) -> List = { x -> 8 | val y = throwsSomeStuff(x) 9 | val z = throwsOtherThings(y) 10 | moreThrowing(z) 11 | } 12 | fun main() { 13 | println ("magic = $magic") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither02 3 | 4 | import arrow.core.Either 5 | 6 | val left: Either = 7 | Either.Left("Something went wrong") 8 | fun main() { 9 | println(left) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither03 3 | 4 | import arrow.core.Either 5 | import arrow.core.flatMap 6 | 7 | val right: Either = Either.Right(5) 8 | val value = right.flatMap{ Either.Right(it + 1) } 9 | fun main() { 10 | println("value = $value") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither04 3 | 4 | import arrow.core.Either 5 | import arrow.core.flatMap 6 | 7 | val left: Either = Either.Left("Something went wrong") 8 | val value = left.flatMap{ Either.Right(it + 1) } 9 | fun main() { 10 | println("value = $value") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither05 3 | 4 | import arrow.core.Either 5 | import arrow.core.flatMap 6 | 7 | fun parse(s: String): Int = 8 | if (s.matches(Regex("-?[0-9]+"))) s.toInt() 9 | else throw NumberFormatException("$s is not a valid integer.") 10 | 11 | fun reciprocal(i: Int): Double = 12 | if (i == 0) throw IllegalArgumentException("Cannot take reciprocal of 0.") 13 | else 1.0 / i 14 | 15 | fun stringify(d: Double): String = d.toString() 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither07 3 | 4 | import arrow.core.Either 5 | 6 | fun parse(s: String): Either = 7 | if (s.matches(Regex("-?[0-9]+"))) Either.Right(s.toInt()) 8 | else Either.Left(NumberFormatException("$s is not a valid integer.")) 9 | 10 | val notANumber = parse("Not a number") 11 | val number2 = parse("2") 12 | fun main() { 13 | println("notANumber = $notANumber") 14 | println("number2 = $number2") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-12.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither12 3 | 4 | import arrow.core.Either 5 | 6 | fun potentialThrowingCode(): String = throw RuntimeException("Blow up!") 7 | 8 | suspend fun makeSureYourLogicDoesNotHaveSideEffects(): Either = 9 | Either.catch { potentialThrowingCode() }.mapLeft { Error.SpecificError } 10 | suspend fun main() { 11 | println("makeSureYourLogicDoesNotHaveSideEffects().isLeft() = ${makeSureYourLogicDoesNotHaveSideEffects().isLeft()}") 12 | } 13 | 14 | sealed class Error { 15 | object SpecificError : Error() 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-13.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither13 3 | 4 | import arrow.core.Either 5 | 6 | val r : Either = Either.Right(7) 7 | val rightMapLeft = r.mapLeft {it + 1} 8 | val l: Either = Either.Left(7) 9 | val leftMapLeft = l.mapLeft {it + 1} 10 | fun main() { 11 | println("rightMapLeft = $rightMapLeft") 12 | println("leftMapLeft = $leftMapLeft") 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-14.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither14 3 | 4 | import arrow.core.Either.Left 5 | import arrow.core.Either 6 | 7 | val r: Either = Either.Right(7) 8 | val swapped = r.swap() 9 | fun main() { 10 | println("swapped = $swapped") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-15.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither15 3 | 4 | import arrow.core.right 5 | 6 | val right7 = 7 | 7.right() 8 | fun main() { 9 | println(right7) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-16.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither16 3 | 4 | import arrow.core.left 5 | 6 | val leftHello = 7 | "hello".left() 8 | fun main() { 9 | println(leftHello) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-17.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither17 3 | 4 | import arrow.core.left 5 | import arrow.core.getOrElse 6 | 7 | val x = "hello".left() 8 | val value = x.getOrElse { "$it world!" } 9 | fun main() { 10 | println("value = $value") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-18.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither18 3 | 4 | import arrow.core.Either 5 | import arrow.core.right 6 | 7 | val x : Either = 7.right() 8 | val fold = x.fold({ 1 }, { it + 3 }) 9 | fun main() { 10 | println("fold = $fold") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-19.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither19 3 | 4 | import arrow.core.Either 5 | import arrow.core.left 6 | 7 | val y : Either = 7.left() 8 | val fold = y.fold({ 1 }, { it + 3 }) 9 | fun main() { 10 | println("fold = $fold") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-20.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither20 3 | 4 | import arrow.core.Either 5 | import arrow.core.getOrElse 6 | 7 | val r: Either = Either.Left(NumberFormatException()) 8 | val httpStatusCode = r.getOrElse { 9 | when(it) { 10 | is NumberFormatException -> 400 11 | else -> 500 12 | } 13 | } 14 | fun main() { 15 | println("httpStatusCode = $httpStatusCode") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-21.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither21 3 | 4 | import arrow.core.Either 5 | import arrow.core.Either.Left 6 | import arrow.core.Either.Right 7 | import io.kotest.matchers.shouldBe 8 | 9 | fun test() { 10 | Left(12).isLeft { it > 10 } shouldBe true 11 | Left(7).isLeft { it > 10 } shouldBe false 12 | 13 | val right: Either = Right("Hello World") 14 | right.isLeft { it > 10 } shouldBe false 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-22.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither22 3 | 4 | import arrow.core.Either 5 | import arrow.core.Either.Left 6 | import arrow.core.Either.Right 7 | import io.kotest.matchers.shouldBe 8 | 9 | fun test() { 10 | Right(12).isRight { it > 10 } shouldBe true 11 | Right(7).isRight { it > 10 } shouldBe false 12 | 13 | val left: Either = Left("Hello World") 14 | left.isRight { it > 10 } shouldBe false 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-23.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither23 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | import io.kotest.assertions.fail 7 | 8 | fun test() { 9 | Either.Right(1) 10 | .fold({ fail("Cannot be left") }, { it + 1 }) shouldBe 2 11 | 12 | Either.Left(RuntimeException("Boom!")) 13 | .fold({ -1 }, { fail("Cannot be right") }) shouldBe -1 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-24.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither24 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | Either.Left("left").swap() shouldBe Either.Right("left") 9 | Either.Right("right").swap() shouldBe Either.Left("right") 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-25.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither25 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | Either.Right(12).map { _: Int ->"flower" } shouldBe Either.Right("flower") 9 | Either.Left(12).map { _: Nothing -> "flower" } shouldBe Either.Left(12) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-26.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither26 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | Either.Right(12).mapLeft { _: Nothing -> "flower" } shouldBe Either.Right(12) 9 | Either.Left(12).mapLeft { _: Int -> "flower" } shouldBe Either.Left("flower") 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-27.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither27 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | Either.Right(1).onRight(::println) shouldBe Either.Right(1) 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-28.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither28 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | Either.Left(2).onLeft(::println) shouldBe Either.Left(2) 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-29.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither29 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | Either.Right(12).getOrNull() shouldBe 12 9 | Either.Left(12).getOrNull() shouldBe null 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-30.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither30 3 | 4 | import arrow.core.Either 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | Either.Right(12).leftOrNull() shouldBe null 9 | Either.Left(12).leftOrNull() shouldBe 12 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-31.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither31 3 | 4 | import arrow.core.Either 5 | import arrow.core.Some 6 | import arrow.core.None 7 | import io.kotest.matchers.shouldBe 8 | 9 | fun test() { 10 | Either.Right(12).getOrNone() shouldBe Some(12) 11 | Either.Left(12).getOrNone() shouldBe None 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-32.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither32 3 | 4 | import arrow.core.Either 5 | import arrow.core.getOrElse 6 | import io.kotest.matchers.shouldBe 7 | 8 | fun test() { 9 | Either.Left(12) getOrElse { it + 5 } shouldBe 17 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-33.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither33 3 | 4 | import arrow.core.Either.Left 5 | import arrow.core.Either.Right 6 | import arrow.core.merge 7 | 8 | fun test() { 9 | Right(12).merge() // Result: 12 10 | Left(12).merge() // Result: 12 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-34.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither34 3 | 4 | import arrow.core.Either 5 | import arrow.core.recover 6 | import io.kotest.matchers.shouldBe 7 | 8 | fun test() { 9 | val error: Either = Either.Left("error") 10 | val fallback: Either = error.recover { it.length } 11 | fallback shouldBe Either.Right(5) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-either-35.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Either.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleEither35 3 | 4 | import arrow.core.Either 5 | import arrow.core.recover 6 | import io.kotest.matchers.shouldBe 7 | 8 | fun test() { 9 | val error: Either = Either.Left("error") 10 | val listOfErrors: Either, Int> = error.recover { raise(it.toList()) } 11 | listOfErrors shouldBe Either.Left(listOf('e', 'r', 'r', 'o', 'r')) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor01 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Left("tulip").isLeft() // Result: true 8 | Ior.Right("venus fly-trap").isLeft() // Result: false 9 | Ior.Both("venus", "fly-trap").isLeft() // Result: false 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor02 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Left("tulip").isRight() // Result: false 8 | Ior.Right("venus fly-trap").isRight() // Result: true 9 | Ior.Both("venus", "fly-trap").isRight() // Result: false 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor03 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Left("tulip").isBoth() // Result: false 8 | Ior.Right("venus fly-trap").isBoth() // Result: false 9 | Ior.Both("venus", "fly-trap").isBoth() // Result: true 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor04 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Right(12).map { "flower" } // Result: Right("flower") 8 | Ior.Left(12).map { "flower" } // Result: Left(12) 9 | Ior.Both(12, "power").map { "flower $it" } // Result: Both(12, "flower power") 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor05 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Right(12).mapLeft { "flower" } // Result: Right(12) 8 | Ior.Left(12).mapLeft { "flower" } // Result: Left("power") 9 | Ior.Both(12, "power").mapLeft { "flower $it" } // Result: Both("flower 12", "power") 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor06 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Left("left").swap() // Result: Right("left") 8 | Ior.Right("right").swap() // Result: Left("right") 9 | Ior.Both("left", "right").swap() // Result: Both("right", "left") 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor07 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Right(12).toEither() // Result: Either.Right(12) 8 | Ior.Left(12).toEither() // Result: Either.Left(12) 9 | Ior.Both("power", 12).toEither() // Result: Either.Right(12) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor08 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | val right = Ior.Right(12).leftOrNull() // Result: null 8 | val left = Ior.Left(12).leftOrNull() // Result: 12 9 | val both = Ior.Both(12, "power").leftOrNull() // Result: 12 10 | println("right = $right") 11 | println("left = $left") 12 | println("both = $both") 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-09.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor09 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | val right: Ior = Ior.Right(12) 8 | right.isLeft { it > 10 } // Result: false 9 | Ior.Both(12, 7).isLeft { it > 10 } // Result: false 10 | Ior.Left(12).isLeft { it > 10 } // Result: true 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-10.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor10 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | Ior.Right(12).isRight { it > 10 } // Result: false 8 | Ior.Both(12, 7).isRight { it > 10 } // Result: false 9 | val left: Ior = Ior.Left(12) 10 | left.isRight { it > 10 } // Result: true 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-ior-11.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Ior.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIor11 3 | 4 | import arrow.core.Ior 5 | 6 | fun main() { 7 | val right: Ior = Ior.Right(12) 8 | right.isBoth( {it > 10}, {it > 6 }) // Result: false 9 | Ior.Both(12, 7).isBoth( {it > 10}, {it > 6 })// Result: true 10 | val left: Ior = Ior.Left(12) 11 | left.isBoth ( {it > 10}, {it > 6 }) // Result: false 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable03 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2).padZip(listOf("a")) shouldBe listOf(1 to "a", 2 to null) 9 | listOf(1).padZip(listOf("a", "b")) shouldBe listOf(1 to "a", null to "b") 10 | listOf(1, 2).padZip(listOf("a", "b")) shouldBe listOf(1 to "a", 2 to "b") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable04 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2).padZip(listOf("a")) { l, r -> l to r } shouldBe listOf(1 to "a", 2 to null) 9 | listOf(1).padZip(listOf("a", "b")) { l, r -> l to r } shouldBe listOf(1 to "a", null to "b") 10 | listOf(1, 2).padZip(listOf("a", "b")) { l, r -> l to r } shouldBe listOf(1 to "a", 2 to "b") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable05 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2).leftPadZip(listOf("a")) { l, r -> l to r } shouldBe listOf(1 to "a") 9 | listOf(1).leftPadZip(listOf("a", "b")) { l, r -> l to r } shouldBe listOf(1 to "a", null to "b") 10 | listOf(1, 2).leftPadZip(listOf("a", "b")) { l, r -> l to r } shouldBe listOf(1 to "a", 2 to "b") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable06 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2).leftPadZip(listOf("a")) shouldBe listOf(1 to "a") 9 | listOf(1).leftPadZip(listOf("a", "b")) shouldBe listOf(1 to "a", null to "b") 10 | listOf(1, 2).leftPadZip(listOf("a", "b")) shouldBe listOf(1 to "a", 2 to "b") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable07 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2).rightPadZip(listOf("a")) { l, r -> l to r } shouldBe listOf(1 to "a", 2 to null) 9 | listOf(1).rightPadZip(listOf("a", "b")) { l, r -> l to r } shouldBe listOf(1 to "a") 10 | listOf(1, 2).rightPadZip(listOf("a", "b")) { l, r -> l to r } shouldBe listOf(1 to "a", 2 to "b") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable08 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2).rightPadZip(listOf("a")) shouldBe listOf(1 to "a", 2 to null) 9 | listOf(1).rightPadZip(listOf("a", "b")) shouldBe listOf(1 to "a") 10 | listOf(1, 2).rightPadZip(listOf("a", "b")) shouldBe listOf(1 to "a", 2 to "b") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-09.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable09 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf("A", "B").align(listOf(1, 2, 3)) { 9 | "$it" 10 | } shouldBe listOf("Ior.Both(A, 1)", "Ior.Both(B, 2)", "Ior.Right(3)") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-10.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable10 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf("A", "B") 9 | .align(listOf(1, 2, 3)) shouldBe listOf(Ior.Both("A", 1), Ior.Both("B", 2), Ior.Right(3)) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-11.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable11 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf( 9 | Pair("A", 1).bothIor(), 10 | Pair("B", 2).bothIor(), 11 | "C".leftIor() 12 | ).separateIor() shouldBe Pair(listOf("A", "B", "C"), listOf(1, 2)) 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-12.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable12 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2, 3, 4).unalign { 9 | if(it % 2 == 0) it.rightIor() 10 | else it.leftIor() 11 | } shouldBe Pair(listOf(1, null, 3, null), listOf(null, 2, null, 4)) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-13.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable13 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | emptyList().split() shouldBe null 9 | listOf("A", "B", "C").split() shouldBe Pair(listOf("B", "C"), "A") 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-14.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable14 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | val list1 = listOf(1, 2, 3) 9 | val list2 = listOf(4, 5, 6, 7, 8) 10 | list1.interleave(list2) shouldBe listOf(1, 4, 2, 5, 3, 6, 7, 8) 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-15.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable15 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | val ints = listOf(1, 2) 9 | val res = ints.unweave { i -> listOf(i, i + 1, i + 2) } 10 | res shouldBe listOf(1, 2, 2, 3, 3, 4) 11 | res shouldBe ints.interleave(ints.flatMap { listOf(it + 1, it + 2) }) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-16.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable16 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf("A".left(), 2.right(), "C".left(), 4.right()) 9 | .separateEither() shouldBe Pair(listOf("A", "C"), listOf(2, 4)) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-iterable-17.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Iterable.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleIterable17 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | listOf(1, 2, 3, 4) 9 | .separateEither { 10 | if (it % 2 == 0) "even: $it".right() else "odd: $it".left() 11 | } shouldBe Pair(listOf("odd: 1", "odd: 3"), listOf("even: 2", "even: 4")) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap01 3 | 4 | import arrow.core.zip 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | mapOf(1 to "A", 2 to "B") 9 | .zip(mapOf(1 to "1", 2 to "2", 3 to "3")) shouldBe mapOf(1 to Pair("A", "1"), 2 to Pair("B", "2")) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap02 3 | 4 | import arrow.core.zip 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | mapOf(1 to "A", 2 to "B").zip(mapOf(1 to "1", 2 to "2", 3 to "3")) { 9 | _, a, b -> "$a ~ $b" 10 | } shouldBe mapOf(1 to "A ~ 1", 2 to "B ~ 2") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap03 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | val res = mapOf(1 to 1, 2 to 2).align(mapOf(1 to "1", 2 to "2", 3 to "3")) 9 | res shouldBe mapOf(1 to Ior.Both(1, "1"), 2 to Ior.Both(2, "2"), 3 to Ior.Right("3")) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap04 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | mapOf("1" to 1, "2" to 2) 9 | .align(mapOf("1" to 1, "2" to 2, "3" to 3)) { (_, a) -> 10 | "$a" 11 | } shouldBe mapOf("1" to "Ior.Both(1, 1)", "2" to Ior.Both(2, 2), "3" to Ior.Right(3)) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap05 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | mapOf( 9 | "first" to Ior.Both("A", 1), 10 | "second" to Ior.Both("B", 2), 11 | "third" to Ior.Left("C") 12 | ).unalign() shouldBe Pair(mapOf("first" to "A", "second" to "B", "third" to "C"), mapOf("first" to 1, "second" to 2)) 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap06 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | mapOf("1" to 1, "2" to 2, "3" to 3) 9 | .unalign { (key, value) -> 10 | when(key) { 11 | "1" -> Ior.Left(value) 12 | "2" -> Ior.Right(key) 13 | else -> Ior.Both(value, key) 14 | } 15 | } shouldBe Pair(mapOf("1" to 1, "3" to 3), mapOf("2" to 2, "3" to 3)) 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap07 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | mapOf( 9 | "first" to ("A" to 1), 10 | "second" to ("B" to 2) 11 | ).unzip() shouldBe Pair(mapOf("first" to "A", "second" to "B"), mapOf("first" to 1, "second" to 2)) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-map-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from map.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleMap08 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | mapOf("first" to "A:1", "second" to "B:2", "third" to "C:3").unzip { (_, e) -> 9 | e.split(":").let { 10 | it.first() to it.last() 11 | } 12 | } shouldBe Pair( 13 | mapOf("first" to "A", "second" to "B", "third" to "C"), 14 | mapOf("first" to "1", "second" to "2", "third" to "3") 15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonemptylist-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from NonEmptyList.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleNonemptylist01 3 | 4 | import arrow.core.nonEmptyListOf 5 | import arrow.core.toNonEmptyListOrNull 6 | 7 | fun main() { 8 | println(nonEmptyListOf(1, 2, 3, 4, 5)) 9 | println(listOf(1, 2, 3).toNonEmptyListOrNull()) 10 | println(emptyList().toNonEmptyListOrNull()) 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonemptylist-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from NonEmptyList.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleNonemptylist02 3 | 4 | import arrow.core.nonEmptyListOf 5 | 6 | val value = 7 | nonEmptyListOf(1, 2, 3, 4, 5).head 8 | fun main() { 9 | println(value) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonemptylist-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from NonEmptyList.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleNonemptylist03 3 | 4 | import arrow.core.NonEmptyList 5 | import arrow.core.nonEmptyListOf 6 | 7 | fun sumNel(nel: NonEmptyList): Int = 8 | nel.foldLeft(0) { acc, n -> acc + n } 9 | val value = sumNel(nonEmptyListOf(1, 1, 1, 1)) 10 | fun main() { 11 | println("value = $value") 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonemptylist-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from NonEmptyList.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleNonemptylist04 3 | 4 | import arrow.core.nonEmptyListOf 5 | 6 | val value = 7 | nonEmptyListOf(1, 1, 1, 1).map { it + 1 } 8 | fun main() { 9 | println(value) 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-nonemptylist-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from NonEmptyList.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleNonemptylist05 3 | 4 | import arrow.core.NonEmptyList 5 | import arrow.core.nonEmptyListOf 6 | 7 | val nelOne: NonEmptyList = nonEmptyListOf(1, 2, 3) 8 | val nelTwo: NonEmptyList = nonEmptyListOf(4, 5) 9 | 10 | val value = nelOne.flatMap { one -> 11 | nelTwo.map { two -> 12 | one + two 13 | } 14 | } 15 | fun main() { 16 | println("value = $value") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption01 3 | 4 | import arrow.core.Option 5 | import arrow.core.Some 6 | import arrow.core.none 7 | 8 | val someValue: Option = Some("I am wrapped in something") 9 | val emptyValue: Option = none() 10 | fun main() { 11 | println("value = $someValue") 12 | println("emptyValue = $emptyValue") 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption02 3 | 4 | import arrow.core.None 5 | import arrow.core.Option 6 | import arrow.core.Some 7 | 8 | fun maybeItWillReturnSomething(flag: Boolean): Option = 9 | if (flag) Some("Found value") else None 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption03 3 | 4 | import arrow.core.None 5 | import arrow.core.Option 6 | import arrow.core.Some 7 | import arrow.core.getOrElse 8 | 9 | fun maybeItWillReturnSomething(flag: Boolean): Option = 10 | if (flag) Some("Found value") else None 11 | 12 | val value1 = 13 | maybeItWillReturnSomething(true) 14 | .getOrElse { "No value" } 15 | fun main() { 16 | println(value1) 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption04 3 | 4 | import arrow.core.None 5 | import arrow.core.Option 6 | import arrow.core.Some 7 | import arrow.core.getOrElse 8 | 9 | fun maybeItWillReturnSomething(flag: Boolean): Option = 10 | if (flag) Some("Found value") else None 11 | 12 | val value2 = 13 | maybeItWillReturnSomething(false) 14 | .getOrElse { "No value" } 15 | fun main() { 16 | println(value2) 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption05 3 | 4 | import arrow.core.None 5 | import arrow.core.Option 6 | import arrow.core.Some 7 | 8 | fun maybeItWillReturnSomething(flag: Boolean): Option = 9 | if (flag) Some("Found value") else None 10 | 11 | //sampleStart 12 | val valueSome = maybeItWillReturnSomething(true) is None 13 | val valueNone = maybeItWillReturnSomething(false) is None 14 | fun main() { 15 | println("valueSome = $valueSome") 16 | println("valueNone = $valueNone") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption06 3 | 4 | import arrow.core.Option 5 | 6 | val myString: String? = "Nullable string" 7 | val option: Option = Option.fromNullable(myString) 8 | fun main () { 9 | println("option = $option") 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption07 3 | 4 | import arrow.core.None 5 | import arrow.core.Option 6 | import arrow.core.Some 7 | 8 | val someValue: Option = Some(20.0) 9 | val value = when(someValue) { 10 | is Some -> someValue.value 11 | is None -> 0.0 12 | } 13 | fun main () { 14 | println("value = $value") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption08 3 | 4 | import arrow.core.None 5 | import arrow.core.Option 6 | import arrow.core.Some 7 | 8 | val noValue: Option = None 9 | val value = when(noValue) { 10 | is Some -> noValue.value 11 | is None -> 0.0 12 | } 13 | fun main () { 14 | println("value = $value") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-09.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption09 3 | 4 | import arrow.core.None 5 | import arrow.core.Option 6 | import arrow.core.Some 7 | 8 | val number: Option = Some(3) 9 | val noNumber: Option = None 10 | val mappedResult1 = number.map { it * 1.5 } 11 | val mappedResult2 = noNumber.map { it * 1.5 } 12 | fun main () { 13 | println("number = $number") 14 | println("noNumber = $noNumber") 15 | println("mappedResult1 = $mappedResult1") 16 | println("mappedResult2 = $mappedResult2") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-10.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption10 3 | 4 | import arrow.core.Option 5 | import arrow.core.Some 6 | 7 | val fold = 8 | Some(3).fold({ 1 }, { it * 3 }) 9 | fun main () { 10 | println(fold) 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-11.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption11 3 | 4 | import arrow.core.Option 5 | import arrow.core.none 6 | 7 | val fold = 8 | none().fold({ 1 }, { it * 3 }) 9 | fun main () { 10 | println(fold) 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-12.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption12 3 | 4 | import arrow.core.some 5 | import arrow.core.none 6 | 7 | val some = 1.some() 8 | val none = none() 9 | fun main () { 10 | println("some = $some") 11 | println("none = $none") 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-13.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption13 3 | 4 | import arrow.core.toOption 5 | 6 | val nullString: String? = null 7 | val valueFromNull = nullString.toOption() 8 | 9 | val helloString: String? = "Hello" 10 | val valueFromStr = helloString.toOption() 11 | fun main () { 12 | println("valueFromNull = $valueFromNull") 13 | println("valueFromStr = $valueFromStr") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-14.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption14 3 | 4 | import arrow.core.firstOrNone 5 | import arrow.core.toOption 6 | import arrow.core.Option 7 | 8 | val foxMap = mapOf(1 to "The", 2 to "Quick", 3 to "Brown", 4 to "Fox") 9 | 10 | val empty = foxMap.entries.firstOrNull { it.key == 5 }?.value.let { it?.toCharArray() }.toOption() 11 | val filled = Option.fromNullable(foxMap.entries.firstOrNull { it.key == 5 }?.value.let { it?.toCharArray() }) 12 | 13 | fun main() { 14 | println("empty = $empty") 15 | println("filled = $filled") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-15.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption15 3 | 4 | import arrow.core.Some 5 | 6 | fun main() { 7 | val value = 8 | //sampleStart 9 | Some(1).map { it + 1 } 10 | //sampleEnd 11 | println(value) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-16.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption16 3 | 4 | import arrow.core.Some 5 | import arrow.core.none 6 | 7 | fun main() { 8 | Some(12).onNone { println("flower") } // Result: Some(12) 9 | none().onNone { println("flower") } // Result: prints "flower" and returns: None 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-17.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption17 3 | 4 | import arrow.core.Some 5 | import arrow.core.none 6 | 7 | fun main() { 8 | Some(12).onSome { println("flower") } // Result: prints "flower" and returns: Some(12) 9 | none().onSome { println("flower") } // Result: None 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-18.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption18 3 | 4 | import arrow.core.Some 5 | import arrow.core.None 6 | import arrow.core.Option 7 | 8 | fun main() { 9 | Some(12).isSome { it > 10 } // Result: true 10 | Some(7).isSome { it > 10 } // Result: false 11 | 12 | val none: Option = None 13 | none.isSome { it > 10 } // Result: false 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-19.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption19 3 | 4 | import arrow.core.None 5 | import arrow.core.Some 6 | import io.kotest.matchers.shouldBe 7 | 8 | fun test() { 9 | Some(12).getOrNull() shouldBe 12 10 | None.getOrNull() shouldBe null 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-20.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption20 3 | 4 | import arrow.core.Option 5 | import arrow.core.none 6 | import arrow.core.Some 7 | import arrow.core.recover 8 | import io.kotest.matchers.shouldBe 9 | 10 | fun test() { 11 | val error: Option = none() 12 | val fallback: Option = error.recover { 5 } 13 | fallback shouldBe Some(5) 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-option-21.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleOption21 3 | 4 | import arrow.core.Option 5 | import arrow.core.none 6 | import arrow.core.Some 7 | import arrow.core.recover 8 | import io.kotest.matchers.shouldBe 9 | 10 | fun test() { 11 | val error: Option = none() 12 | fun fallback(): Option = Some(5) 13 | fun failure(): Option = none() 14 | 15 | error.recover { fallback().bind() } shouldBe Some(5) 16 | error.recover { failure().bind() } shouldBe none() 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Effect.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaise01 3 | 4 | import arrow.core.raise.Effect 5 | import arrow.core.raise.effect 6 | import arrow.core.raise.ensureNotNull 7 | import arrow.core.raise.ensure 8 | 9 | object EmptyPath 10 | 11 | fun readFile(path: String): Effect = effect { 12 | if (path.isEmpty()) raise(EmptyPath) else Unit 13 | } 14 | 15 | fun readFile2(path: String?): Effect = effect { 16 | ensureNotNull(path) { EmptyPath } 17 | ensure(path.isNotEmpty()) { EmptyPath } 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Effect.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaise03 3 | 4 | import arrow.core.Either 5 | import arrow.core.None 6 | import arrow.core.Option 7 | import arrow.core.Some 8 | import arrow.core.raise.Effect 9 | import arrow.core.raise.fold 10 | import arrow.core.identity 11 | 12 | suspend fun Effect.toEither(): Either = 13 | fold({ Either.Left(it) }) { Either.Right(it) } 14 | 15 | suspend fun Effect.toOption(): Option = 16 | fold(::identity) { Some(it) } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl01 3 | 4 | import arrow.core.raise.Raise 5 | import arrow.core.raise.recover 6 | 7 | fun Raise.failure(): Int = raise("failed") 8 | 9 | fun recovered(): Int = 10 | recover({ failure() }) { _: String -> 1 } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl05 3 | 4 | import arrow.core.Either 5 | import arrow.core.right 6 | import arrow.core.raise.either 7 | import arrow.core.raise.recover 8 | import io.kotest.matchers.shouldBe 9 | 10 | fun test() { 11 | val one: Either = 1.right() 12 | val left: Either = Either.Left("failed") 13 | 14 | either { 15 | val x = one.bind() 16 | val y = recover({ left.bind() }) { _ : String -> 1 } 17 | x + y 18 | } shouldBe Either.Right(2) 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl06 3 | 4 | import arrow.core.Either 5 | import arrow.core.raise.either 6 | import arrow.core.raise.recover 7 | import io.kotest.matchers.shouldBe 8 | 9 | fun test() { 10 | recover({ raise("failed") }) { str -> str.length } shouldBe 6 11 | 12 | either { 13 | recover({ raise("failed") }) { _ -> raise(-1) } 14 | } shouldBe Either.Left(-1) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl07 3 | 4 | import arrow.core.raise.recover 5 | import arrow.core.raise.Raise 6 | import io.kotest.matchers.shouldBe 7 | 8 | fun test() { 9 | recover( 10 | { raise("failed") }, 11 | { str -> str.length } 12 | ) { t -> t.message ?: -1 } shouldBe 6 13 | 14 | fun Raise.boom(): Int = throw RuntimeException("BOOM") 15 | 16 | recover( 17 | { boom() }, 18 | { str -> str.length } 19 | ) { t -> t.message?.length ?: -1 } shouldBe 4 20 | } 21 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl08 3 | 4 | import arrow.core.raise.recover 5 | import arrow.core.raise.Raise 6 | import io.kotest.matchers.shouldBe 7 | 8 | fun test() { 9 | recover( 10 | { raise("failed") }, 11 | { str -> str.length } 12 | ) { t -> t.message ?: -1 } shouldBe 6 13 | 14 | fun Raise.boom(): Int = throw RuntimeException("BOOM") 15 | 16 | recover( 17 | { boom() }, 18 | { str -> str.length } 19 | ) { t: RuntimeException -> t.message?.length ?: -1 } shouldBe 4 20 | } 21 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-09.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl09 3 | 4 | import arrow.core.Either 5 | import arrow.core.raise.either 6 | import arrow.core.raise.catch 7 | import io.kotest.matchers.shouldBe 8 | 9 | fun test() { 10 | catch({ throw RuntimeException("BOOM") }) { _ -> 11 | "fallback" 12 | } shouldBe "fallback" 13 | 14 | fun fetchId(): Int = throw RuntimeException("BOOM") 15 | 16 | either { 17 | catch({ fetchId() }) { t -> 18 | raise("something went wrong: ${t.message}") 19 | } 20 | } shouldBe Either.Left("something went wrong: BOOM") 21 | } 22 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-11.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl11 3 | 4 | import arrow.core.Either 5 | import arrow.core.raise.either 6 | import arrow.core.raise.withError 7 | import io.kotest.matchers.shouldBe 8 | 9 | fun test() { 10 | either { 11 | withError(String::length) { 12 | raise("failed") 13 | } 14 | } shouldBe Either.Left(6) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-raise-dsl-12.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Raise.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleRaiseDsl12 3 | 4 | import arrow.core.raise.merge 5 | import io.kotest.matchers.shouldBe 6 | import kotlin.random.Random 7 | 8 | fun test() { 9 | merge { if(Random.nextBoolean()) raise("failed") else "failed" } shouldBe "failed" 10 | } 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence02 3 | 4 | import arrow.core.align 5 | import arrow.core.Ior.Both 6 | import arrow.core.Ior.Left 7 | import arrow.core.Ior.Right 8 | import io.kotest.matchers.shouldBe 9 | 10 | fun test() { 11 | sequenceOf("A", "B") 12 | .align(sequenceOf(1, 2, 3)).toList() shouldBe listOf(Both("A", 1), Both("B", 2), Right(3)) 13 | 14 | sequenceOf("A", "B", "C") 15 | .align(sequenceOf(1, 2)).toList() shouldBe listOf(Both("A", 1), Both("B", 2), Left("C")) 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence03 3 | 4 | import arrow.core.* 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | val tags = generateSequence { "#" }.take(5) 9 | val numbers = generateSequence(0) { it + 1 }.take(3) 10 | tags.interleave(numbers).toList() shouldBe listOf("#", 0, "#", 1, "#", 2, "#", "#") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence04 3 | 4 | import arrow.core.leftPadZip 5 | 6 | val left = sequenceOf(1, 2).leftPadZip(sequenceOf(3)) { l, r -> l?.plus(r) ?: r } // Result: [4] 7 | val right = sequenceOf(1).leftPadZip(sequenceOf(3, 4)) { l, r -> l?.plus(r) ?: r } // Result: [4, 4] 8 | val both = sequenceOf(1, 2).leftPadZip(sequenceOf(3, 4)) { l, r -> l?.plus(r) ?: r } // Result: [4, 6] 9 | 10 | fun main() { 11 | println("left = $left") 12 | println("right = $right") 13 | println("both = $both") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence05 3 | 4 | import arrow.core.leftPadZip 5 | 6 | val padRight = sequenceOf(1, 2).leftPadZip(sequenceOf("a")) // Result: [Pair(1, "a")] 7 | val padLeft = sequenceOf(1).leftPadZip(sequenceOf("a", "b")) // Result: [Pair(1, "a"), Pair(null, "b")] 8 | val noPadding = sequenceOf(1, 2).leftPadZip(sequenceOf("a", "b")) // Result: [Pair(1, "a"), Pair(2, "b")] 9 | 10 | fun main() { 11 | println("padRight = $padRight") 12 | println("padLeft = $padLeft") 13 | println("noPadding = $noPadding") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence06 3 | 4 | import arrow.core.padZip 5 | 6 | val padRight = sequenceOf(1, 2).padZip(sequenceOf("a")) // Result: [Pair(1, "a"), Pair(2, null)] 7 | val padLeft = sequenceOf(1).padZip(sequenceOf("a", "b")) // Result: [Pair(1, "a"), Pair(null, "b")] 8 | val noPadding = sequenceOf(1, 2).padZip(sequenceOf("a", "b")) // Result: [Pair(1, "a"), Pair(2, "b")] 9 | 10 | fun main() { 11 | println("padRight = $padRight") 12 | println("padLeft = $padLeft") 13 | println("noPadding = $noPadding") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence07 3 | 4 | import arrow.core.padZip 5 | 6 | val padZipRight = sequenceOf(1, 2).padZip(sequenceOf(3)) { l, r -> (l?:0) + (r?:0) } // Result: [4, 2] 7 | val padZipLeft = sequenceOf(1).padZip(sequenceOf(3, 4)) { l, r -> (l?:0) + (r?:0) } // Result: [4, 4] 8 | val noPadding = sequenceOf(1, 2).padZip(sequenceOf(3, 4)) { l, r -> (l?:0) + (r?:0) } // Result: [4, 6] 9 | 10 | fun main() { 11 | println("padZipRight = $padZipRight") 12 | println("padZipLeft = $padZipLeft") 13 | println("noPadding = $noPadding") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence08 3 | 4 | import arrow.core.rightPadZip 5 | 6 | val left = sequenceOf(1, 2).rightPadZip(sequenceOf(3)) { l, r -> l + (r?:0) } // Result: [4, 2] 7 | val right = sequenceOf(1).rightPadZip(sequenceOf(3, 4)) { l, r -> l + (r?:0) } // Result: [4] 8 | val both = sequenceOf(1, 2).rightPadZip(sequenceOf(3, 4)) { l, r -> l + (r?:0) } // Result: [4, 6] 9 | 10 | fun main() { 11 | println("left = $left") 12 | println("right = $right") 13 | println("both = $both") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-09.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence09 3 | 4 | import arrow.core.rightPadZip 5 | 6 | val padRight = sequenceOf(1, 2).rightPadZip(sequenceOf("a")) // Result: [Pair(1, "a"), Pair(2, null)] 7 | val padLeft = sequenceOf(1).rightPadZip(sequenceOf("a", "b")) // Result: [Pair(1, "a")] 8 | val noPadding = sequenceOf(1, 2).rightPadZip(sequenceOf("a", "b")) // Result: [Pair(1, "a"), Pair(2, "b")] 9 | 10 | fun main() { 11 | println("padRight = $padRight") 12 | println("padLeft = $padLeft") 13 | println("noPadding = $noPadding") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-10.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence10 3 | 4 | import arrow.core.split 5 | import io.kotest.matchers.shouldBe 6 | 7 | fun test() { 8 | sequenceOf("A", "B", "C").split()?.let { (tail, head) -> 9 | head shouldBe "A" 10 | tail.toList() shouldBe listOf("B", "C") 11 | } 12 | emptySequence().split() shouldBe null 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-11.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence11 3 | 4 | import arrow.core.bothIor 5 | import arrow.core.leftIor 6 | import arrow.core.unalign 7 | 8 | fun main() { 9 | //sampleStart 10 | val result = sequenceOf(("A" to 1).bothIor(), ("B" to 2).bothIor(), "C".leftIor()).unalign() 11 | //sampleEnd 12 | println("(${result.first}, ${result.second})") 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-12.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence12 3 | 4 | import arrow.core.leftIor 5 | import arrow.core.unalign 6 | 7 | fun main() { 8 | //sampleStart 9 | val result = sequenceOf(1, 2, 3).unalign { it.leftIor() } 10 | //sampleEnd 11 | println("(${result.first.toList()}, ${result.second.toList()})") 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-13.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence13 3 | 4 | import arrow.core.unweave 5 | 6 | fun main() { 7 | //sampleStart 8 | val result = sequenceOf(1,2,3).unweave { i -> sequenceOf("$i, ${i + 1}") } 9 | //sampleEnd 10 | println(result.toList()) 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-14.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence14 3 | 4 | import arrow.core.unzip 5 | 6 | fun main() { 7 | //sampleStart 8 | val result = sequenceOf("A" to 1, "B" to 2).unzip() 9 | //sampleEnd 10 | println("(${result.first}, ${result.second})") 11 | } 12 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-15.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence15 3 | 4 | import arrow.core.unzip 5 | 6 | fun main() { 7 | //sampleStart 8 | val result = 9 | sequenceOf("A:1", "B:2", "C:3").unzip { e -> 10 | e.split(":").let { 11 | it.first() to it.last() 12 | } 13 | } 14 | //sampleEnd 15 | println("(${result.first}, ${result.second})") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/example-sequence-16.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Sequence.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.exampleSequence16 3 | 4 | import arrow.core.None 5 | import arrow.core.Some 6 | import arrow.core.filterOption 7 | import io.kotest.matchers.shouldBe 8 | 9 | fun test() { 10 | generateSequence(0) { it + 1 } 11 | .map { if (it % 2 == 0) Some(it) else None } 12 | .filterOption() 13 | .take(5) 14 | .toList() shouldBe listOf(0, 2, 4, 6, 8) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/jvmTest/kotlin/examples/test/OptionKnitTest.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Option.kt by Knit tool. Do not edit. 2 | package arrow.core.examples.test 3 | 4 | import kotlin.test.Test 5 | import kotlinx.coroutines.test.runTest 6 | 7 | class OptionKnitTest { 8 | @Test fun exampleOption20() = runTest { 9 | arrow.core.examples.exampleOption20.test() 10 | } 11 | 12 | @Test fun exampleOption21() = runTest { 13 | arrow.core.examples.exampleOption21.test() 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/nonJvmMain/kotlin/arrow/core/ArrowCoreInternalException.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | @PublishedApi 4 | internal actual object ArrowCoreInternalException : RuntimeException( 5 | "Arrow-Core internal error. Please let us know and create a ticket at https://github.com/arrow-kt/arrow-core/issues/new/choose", 6 | null 7 | ) 8 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/nonJvmMain/kotlin/arrow/core/NonFatal.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | import kotlin.coroutines.cancellation.CancellationException 4 | 5 | public actual fun NonFatal(t: Throwable): Boolean = 6 | when (t) { 7 | is CancellationException -> false 8 | else -> true 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-core/src/nonJvmMain/kotlin/arrow/core/raise/CancellationExceptionNoTrace.kt: -------------------------------------------------------------------------------- 1 | package arrow.core.raise 2 | 3 | @OptIn(DelicateRaiseApi::class) 4 | @Suppress( 5 | "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING", 6 | "SEALED_INHERITOR_IN_DIFFERENT_MODULE" 7 | ) 8 | internal actual class NoTrace actual constructor(raised: Any?, raise: Raise) : RaiseCancellationException(raised, raise) 9 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-eval/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | implementation(projects.arrowCore) 10 | } 11 | } 12 | 13 | commonTest { 14 | dependencies { 15 | implementation(projects.arrowPlatform) 16 | implementation(libs.bundles.testing) 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-eval/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Eval 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-eval/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.eval.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.eval.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-eval/src/jvmTest/kotlin/examples/example-eval-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Eval.kt by Knit tool. Do not edit. 2 | package arrow.eval.examples.exampleEval01 3 | 4 | import arrow.eval.Eval 5 | 6 | fun even(n: Int): Eval = 7 | Eval.always { n == 0 }.flatMap { 8 | if(it == true) Eval.now(true) 9 | else odd(n - 1) 10 | } 11 | 12 | fun odd(n: Int): Eval = 13 | Eval.always { n == 0 }.flatMap { 14 | if(it == true) Eval.now(false) 15 | else even(n - 1) 16 | } 17 | 18 | // if not wrapped in eval this type of computation would blow the stack and result in a StackOverflowError 19 | fun main() { 20 | println(odd(100000).value()) 21 | } 22 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-eval/src/jvmTest/kotlin/examples/example-eval-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Eval.kt by Knit tool. Do not edit. 2 | package arrow.eval.examples.exampleEval02 3 | 4 | import arrow.eval.* 5 | 6 | fun main() { 7 | val eager = Eval.now(1).map { it + 1 } 8 | println(eager.value()) 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-eval/src/jvmTest/kotlin/examples/example-eval-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Eval.kt by Knit tool. Do not edit. 2 | package arrow.eval.examples.exampleEval03 3 | 4 | import arrow.eval.* 5 | 6 | fun main() { 7 | val lazyEvaled = Eval.later { "expensive computation" } 8 | println(lazyEvaled.value()) 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-eval/src/jvmTest/kotlin/examples/example-eval-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Eval.kt by Knit tool. Do not edit. 2 | package arrow.eval.examples.exampleEval04 3 | 4 | import arrow.eval.* 5 | 6 | fun main() { 7 | val alwaysEvaled = Eval.always { "expensive computation" } 8 | println(alwaysEvaled.value()) 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-functions/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowAtomic) 10 | api(projects.arrowAnnotations) 11 | } 12 | } 13 | commonTest { 14 | dependencies { 15 | implementation(projects.arrowFxCoroutines) 16 | implementation(projects.arrowPlatform) 17 | implementation(libs.bundles.testing) 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-functions/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Functions 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-functions/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.core.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.core.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/test/ 6 | test.template=knit.test.template -------------------------------------------------------------------------------- /arrow-libs/core/arrow-functions/knit.test.template: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ${file.name} by Knit tool. Do not edit. 2 | package ${test.package} 3 | 4 | import io.kotest.core.spec.style.StringSpec 5 | 6 | class ${test.name} : StringSpec({ 7 | <#list cases as case> 8 | "${case.name}" { 9 | ${case.knit.package}.${case.knit.name}.test() 10 | } 11 | 12 | 13 | }) { 14 | override fun timeout(): Long = 1000 15 | } -------------------------------------------------------------------------------- /arrow-libs/core/arrow-functions/src/commonMain/kotlin/arrow/core/composition.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("Composition") 2 | 3 | package arrow.core 4 | 5 | import kotlin.jvm.JvmName 6 | 7 | public expect infix fun ((P1, P2) -> IP).andThen(f: (IP) -> R): (P1, P2) -> R 8 | public expect infix fun (() -> IP).andThen(f: (IP) -> R): () -> R 9 | public expect infix fun ((P1) -> IP).andThen(f: (IP) -> R): (P1) -> R 10 | public expect infix fun ((IP) -> R).compose(f: (P1) -> IP): (P1) -> R 11 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-functions/src/nonJvmMain/kotlin/arrow/core/composition-js.kt: -------------------------------------------------------------------------------- 1 | package arrow.core 2 | 3 | public actual infix fun ((P1, P2) -> IP).andThen(f: (IP) -> R): (P1, P2) -> R = 4 | { p1, p2 -> f(this(p1, p2)) } 5 | 6 | public actual infix fun (() -> IP).andThen(f: (IP) -> R): () -> R = 7 | { f(this()) } 8 | 9 | public actual infix fun ((P1) -> IP).andThen(f: (IP) -> R): (P1) -> R = 10 | { p1 -> f(this(p1)) } 11 | 12 | public actual infix fun ((IP) -> R).compose(f: (P1) -> IP): (P1) -> R = 13 | { p1 -> this(f(p1)) } 14 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi 2 | 3 | plugins { 4 | id("arrow.kotlin") 5 | } 6 | 7 | kotlin { 8 | @OptIn(ExperimentalKotlinGradlePluginApi::class) 9 | compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") 10 | 11 | sourceSets { 12 | commonMain { 13 | dependencies { 14 | implementation(kotlin("test-annotations-common")) 15 | } 16 | } 17 | jvmMain { 18 | dependencies { 19 | implementation(kotlin("test-junit5")) 20 | } 21 | } 22 | jsMain { 23 | dependencies { 24 | implementation(kotlin("test")) 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Platform 3 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.platform.examples 2 | knit.dir=src/commonTest/kotlin/examples/ 3 | 4 | test.package=arrow.platform.examples.test 5 | test.dir=src/commonTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/androidMain/kotlin/arrow/platform/Platform.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("PlatformAndroidKt") 2 | 3 | package arrow.platform 4 | 5 | public actual val platform: Platform = Platform.Android 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/androidMain/kotlin/arrow/platform/test/Flaky.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform.test 2 | 3 | public actual typealias FlakyOnJvm = NonFlakyOnThisPlatform 4 | public actual typealias FlakyOnJs = NonFlakyOnThisPlatform 5 | public actual typealias FlakyOnNative = NonFlakyOnThisPlatform 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/commonMain/kotlin/arrow/platform/Platform.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform 2 | 3 | public enum class Platform { 4 | JVM, JS, Native, WebAssembly, Android 5 | } 6 | 7 | public expect val platform: Platform 8 | 9 | /** 10 | * Heuristic about the maximum amount of stack space 11 | * one can reasonably consume in the executing platform. 12 | */ 13 | public fun stackSafeIteration(): Int = when (platform) { 14 | Platform.JVM -> 200_000 15 | else -> 1000 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/commonMain/kotlin/arrow/platform/test/Flaky.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform.test 2 | 3 | public annotation class NonFlakyOnThisPlatform 4 | 5 | public expect annotation class FlakyOnJvm() 6 | public expect annotation class FlakyOnJs() 7 | public expect annotation class FlakyOnNative() 8 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/jsMain/kotlin/arrow/platform/Platform.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform 2 | 3 | public actual val platform: Platform = Platform.JS 4 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/jsMain/kotlin/arrow/platform/test/Flaky.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform.test 2 | 3 | public actual typealias FlakyOnJvm = NonFlakyOnThisPlatform 4 | public actual typealias FlakyOnJs = kotlin.test.Ignore 5 | public actual typealias FlakyOnNative = NonFlakyOnThisPlatform 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/jvmMain/kotlin/arrow/platform/PlatformJvm.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("CurrentPlatform") 2 | package arrow.platform 3 | 4 | public actual val platform: Platform = Platform.JVM 5 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/jvmMain/kotlin/arrow/platform/test/Flaky.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform.test 2 | 3 | public actual typealias FlakyOnJvm = org.junit.jupiter.api.Disabled 4 | public actual typealias FlakyOnJs = NonFlakyOnThisPlatform 5 | public actual typealias FlakyOnNative = NonFlakyOnThisPlatform 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/nativeMain/kotlin/arrow/platform/Platform.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform 2 | 3 | public actual val platform: Platform = Platform.Native 4 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/nativeMain/kotlin/arrow/platform/test/Flaky.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform.test 2 | 3 | public actual typealias FlakyOnJvm = NonFlakyOnThisPlatform 4 | public actual typealias FlakyOnJs = NonFlakyOnThisPlatform 5 | public actual typealias FlakyOnNative = kotlin.test.Ignore 6 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/wasmJsMain/kotlin/arrow/platform/Platform.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform 2 | 3 | public actual val platform: Platform = Platform.WebAssembly 4 | -------------------------------------------------------------------------------- /arrow-libs/core/arrow-platform/src/wasmJsMain/kotlin/arrow/platform/test/Flaky.kt: -------------------------------------------------------------------------------- 1 | package arrow.platform.test 2 | 3 | public actual typealias FlakyOnJvm = NonFlakyOnThisPlatform 4 | public actual typealias FlakyOnJs = NonFlakyOnThisPlatform 5 | public actual typealias FlakyOnNative = NonFlakyOnThisPlatform 6 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-collectors/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowFxCoroutines) 10 | api(projects.arrowAtomic) 11 | api(libs.coroutines.core) 12 | } 13 | } 14 | 15 | commonTest { 16 | dependencies { 17 | implementation(libs.bundles.testing) 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-collectors/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Collectors 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowCore) 10 | api(projects.arrowAutoclose) 11 | api(libs.coroutines.core) 12 | } 13 | } 14 | 15 | commonTest { 16 | dependencies { 17 | implementation(projects.arrowCore) 18 | implementation(projects.arrowAtomic) 19 | implementation(projects.arrowPlatform) 20 | implementation(libs.bundles.testing) 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Fx Coroutines 3 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.fx.coroutines.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.fx.coroutines.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jsMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt: -------------------------------------------------------------------------------- 1 | package arrow.fx.coroutines 2 | 3 | import kotlinx.coroutines.CoroutineDispatcher 4 | import kotlinx.coroutines.Dispatchers 5 | 6 | internal actual val IODispatcher: CoroutineDispatcher = Dispatchers.Main 7 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/arrow/fx/coroutines/NamedThreadFactory.kt: -------------------------------------------------------------------------------- 1 | package arrow.fx.coroutines 2 | 3 | import arrow.atomic.AtomicInt 4 | import java.util.concurrent.ThreadFactory 5 | 6 | private val namedThreadCount = AtomicInt(0) 7 | 8 | class NamedThreadFactory(val name: String): ThreadFactory { 9 | override fun newThread(r: Runnable): Thread? = 10 | Thread(r, "$name-${namedThreadCount.getAndIncrement()}").apply { 11 | uncaughtExceptionHandler = Thread.UncaughtExceptionHandler { _, e -> 12 | e.printStackTrace() 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-flow-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from flow.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleFlow01 3 | 4 | import kotlinx.coroutines.delay 5 | import kotlinx.coroutines.flow.flowOf 6 | import kotlinx.coroutines.flow.toList 7 | import kotlinx.coroutines.flow.collect 8 | import arrow.fx.coroutines.parMap 9 | 10 | @OptIn(kotlinx.coroutines.FlowPreview::class, kotlinx.coroutines.ExperimentalCoroutinesApi::class) 11 | suspend fun main(): Unit { 12 | flowOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 13 | .parMap { a -> 14 | delay(100) 15 | a 16 | }.toList() // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-flow-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from flow.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleFlow02 3 | 4 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-parzip-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ParZip.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleParzip01 3 | 4 | import arrow.fx.coroutines.* 5 | 6 | suspend fun main(): Unit { 7 | //sampleStart 8 | val result = parZip( 9 | { "First one is on ${Thread.currentThread().name}" }, 10 | { "Second one is on ${Thread.currentThread().name}" } 11 | ) { a, b -> 12 | "$a\n$b" 13 | } 14 | //sampleEnd 15 | println(result) 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-parzip-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ParZip.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleParzip02 3 | 4 | import arrow.fx.coroutines.* 5 | import kotlinx.coroutines.Dispatchers 6 | 7 | suspend fun main(): Unit { 8 | //sampleStart 9 | val result = parZip( 10 | Dispatchers.IO, 11 | { "First one is on ${Thread.currentThread().name}" }, 12 | { "Second one is on ${Thread.currentThread().name}" } 13 | ) { a, b -> 14 | "$a\n$b" 15 | } 16 | //sampleEnd 17 | println(result) 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-parzip-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ParZip.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleParzip03 3 | 4 | import arrow.fx.coroutines.* 5 | 6 | suspend fun main(): Unit { 7 | //sampleStart 8 | val result = parZip( 9 | { "First one is on ${Thread.currentThread().name}" }, 10 | { "Second one is on ${Thread.currentThread().name}" }, 11 | { "Third one is on ${Thread.currentThread().name}" } 12 | ) { a, b, c -> 13 | "$a\n$b\n$c" 14 | } 15 | //sampleEnd 16 | println(result) 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-parzip-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ParZip.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleParzip04 3 | 4 | import arrow.fx.coroutines.* 5 | import kotlinx.coroutines.Dispatchers 6 | 7 | suspend fun main(): Unit { 8 | //sampleStart 9 | val result = parZip( 10 | Dispatchers.IO, 11 | { "First one is on ${Thread.currentThread().name}" }, 12 | { "Second one is on ${Thread.currentThread().name}" }, 13 | { "Third one is on ${Thread.currentThread().name}" } 14 | ) { a, b, c -> 15 | "$a\n$b\n$c" 16 | } 17 | //sampleEnd 18 | println(result) 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-parzip-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ParZip.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleParzip05 3 | 4 | import arrow.fx.coroutines.* 5 | 6 | suspend fun main(): Unit { 7 | //sampleStart 8 | val result = parZip( 9 | { "First one is on ${Thread.currentThread().name}" }, 10 | { "Second one is on ${Thread.currentThread().name}" }, 11 | { "Third one is on ${Thread.currentThread().name}" }, 12 | { "Fourth one is on ${Thread.currentThread().name}" } 13 | ) { a, b, c, d -> 14 | "$a\n$b\n$c\n$d" 15 | } 16 | //sampleEnd 17 | println(result) 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-resource-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Resource.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleResource07 3 | 4 | import arrow.fx.coroutines.resource 5 | import arrow.fx.coroutines.resourceScope 6 | 7 | val resource = resource { 8 | install({ 42.also { println("Getting expensive resource") } }) { r, exitCase -> 9 | println("Releasing expensive resource: $r, exit: $exitCase") 10 | } 11 | } 12 | 13 | suspend fun main(): Unit = resourceScope { 14 | val res = resource.bind() 15 | println("Expensive resource under use! $res") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-resource-10.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from Resource.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleResource10 3 | 4 | import arrow.fx.coroutines.resourceScope 5 | import arrow.fx.coroutines.autoCloseable 6 | import java.io.FileInputStream 7 | 8 | suspend fun copyFile(src: String, dest: String): Unit = 9 | resourceScope { 10 | val a: FileInputStream = autoCloseable { FileInputStream(src) } 11 | val b: FileInputStream = autoCloseable { FileInputStream(dest) } 12 | /** read from [a] and write to [b]. **/ 13 | } // Both resources will be closed accordingly to their #close methods 14 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-resourceextensions-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ResourceExtensions.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleResourceextensions02 3 | 4 | import arrow.fx.coroutines.resourceScope 5 | import arrow.fx.coroutines.closeable 6 | import java.io.FileInputStream 7 | 8 | suspend fun copyFile(src: String, dest: String): Unit = 9 | resourceScope { 10 | val a: FileInputStream = closeable { FileInputStream(src) } 11 | val b: FileInputStream = closeable { FileInputStream(dest) } 12 | /** read from `a` and write to `b`. **/ 13 | } // Both resources will be closed accordingly to their #close methods 14 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-resourceextensions-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ResourceExtensions.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleResourceextensions03 3 | 4 | import arrow.fx.coroutines.resourceScope 5 | import arrow.fx.coroutines.singleThreadContext 6 | import kotlinx.coroutines.withContext 7 | import kotlinx.coroutines.ExecutorCoroutineDispatcher 8 | 9 | suspend fun main(): Unit = resourceScope { 10 | val single: ExecutorCoroutineDispatcher = singleThreadContext("single") 11 | withContext(single) { 12 | println("I am running on ${Thread.currentThread().name}") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/jvmTest/kotlin/examples/example-resourceextensions-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from ResourceExtensions.kt by Knit tool. Do not edit. 2 | package arrow.fx.coroutines.examples.exampleResourceextensions04 3 | 4 | import arrow.fx.coroutines.fixedThreadPoolContext 5 | import arrow.fx.coroutines.resourceScope 6 | import kotlinx.coroutines.withContext 7 | import kotlinx.coroutines.ExecutorCoroutineDispatcher 8 | 9 | suspend fun main(): Unit = resourceScope { 10 | val pool: ExecutorCoroutineDispatcher = fixedThreadPoolContext(8, "custom-pool") 11 | withContext(pool) { 12 | println("I am running on ${Thread.currentThread().name}") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/nativeMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt: -------------------------------------------------------------------------------- 1 | package arrow.fx.coroutines 2 | 3 | import kotlinx.coroutines.CoroutineDispatcher 4 | import kotlinx.coroutines.Dispatchers 5 | import kotlinx.coroutines.IO 6 | 7 | internal actual val IODispatcher: CoroutineDispatcher = Dispatchers.IO 8 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-coroutines/src/wasmJsMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt: -------------------------------------------------------------------------------- 1 | package arrow.fx.coroutines 2 | 3 | import kotlinx.coroutines.CoroutineDispatcher 4 | import kotlinx.coroutines.Dispatchers 5 | 6 | internal actual val IODispatcher: CoroutineDispatcher = Dispatchers.Main 7 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/README.md: -------------------------------------------------------------------------------- 1 | # Module main 2 | # Arrow Fx STM 3 | 4 | [![Arrow Fx logo](https://raw.githubusercontent.com/arrow-kt/arrow-site/main/docs/img/fx/arrow-fx-brand-sidebar.svg?sanitize=true)](https://arrow-kt.io) 5 | 6 | Λrrow Fx STM is part of Arrow Fx [**Λrrow**](https://arrow-kt.io/docs/fx/), and the public documentation and information on how to use the library can be found [here](https://arrow-kt.io/docs/next/apidocs/arrow-fx-stm/arrow.fx.stm/-s-t-m/index.html). 7 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Fx STM 3 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.fx.stm.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.fx.stm.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/androidAndJvmMain/kotlin/arrow/fx/stm/internal/RetryException.kt: -------------------------------------------------------------------------------- 1 | package arrow.fx.stm.internal 2 | 3 | public actual object RetryException : Throwable("Arrow STM Retry. This should always be caught by arrow internally. Please report this as a bug if that is not the case!") { 4 | private fun readResolve(): Any = RetryException 5 | override fun fillInStackTrace(): Throwable { return this } 6 | } 7 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm04 3 | 4 | import arrow.fx.stm.atomically 5 | import arrow.fx.stm.stm 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val result = atomically { 10 | stm { retry() } orElse { "Alternative" } 11 | } 12 | //sampleEnd 13 | println("Result $result") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm05 3 | 4 | import arrow.fx.stm.atomically 5 | import arrow.fx.stm.stm 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val result = atomically { 10 | stm { retry() } orElse { "Alternative" } 11 | } 12 | //sampleEnd 13 | println("Result $result") 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm06 3 | 4 | import arrow.fx.stm.atomically 5 | 6 | suspend fun main() { 7 | //sampleStart 8 | val result = atomically { 9 | catch({ throw Throwable() }) { _ -> "caught" } 10 | } 11 | //sampleEnd 12 | println("Result $result") 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm07 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.read() 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm08 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.value 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-09.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm09 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.write(20) 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-10.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm10 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.set(20) 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-11.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm11 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | val x by tvar 12 | x 13 | } 14 | //sampleEnd 15 | println(result) 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-12.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm12 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | var x by tvar 12 | x = 20 13 | } 14 | //sampleEnd 15 | println(result) 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-13.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm13 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.modify { it * 2 } 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-14.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm14 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.swap(20) 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${tvar.unsafeRead()}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-15.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm15 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(10) 10 | val result = atomically { 11 | tmvar.take() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-16.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm16 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | atomically { 11 | tmvar.put(20) 12 | } 13 | //sampleEnd 14 | println("New value ${atomically { tmvar.tryTake() } }") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-17.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm17 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(30) 10 | val result = atomically { 11 | tmvar.read() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-18.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm18 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | val result = atomically { 11 | tmvar.tryTake() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-19.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm19 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(20) 10 | val result = atomically { 11 | tmvar.tryPut(30) 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-20.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm20 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | val result = atomically { 11 | tmvar.tryRead() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-21.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm21 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | val result = atomically { 11 | tmvar.isEmpty() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-22.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm22 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | val result = atomically { 11 | tmvar.isNotEmpty() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-23.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm23 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(30) 10 | val result = atomically { 11 | tmvar.swap(40) 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-24.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm24 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | val result = atomically { 11 | tsem.available() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Permits remaining ${atomically { tsem.available() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-25.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm25 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | atomically { 11 | tsem.acquire() 12 | } 13 | //sampleEnd 14 | println("Permits remaining ${atomically { tsem.available() }}") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-26.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm26 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | atomically { 11 | tsem.acquire(3) 12 | } 13 | //sampleEnd 14 | println("Permits remaining ${atomically { tsem.available() }}") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-27.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm27 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(0) 10 | val result = atomically { 11 | tsem.tryAcquire() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Permits remaining ${atomically { tsem.available() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-28.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm28 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(0) 10 | val result = atomically { 11 | tsem.tryAcquire(3) 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Permits remaining ${atomically { tsem.available() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-29.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm29 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | atomically { 11 | tsem.release() 12 | } 13 | //sampleEnd 14 | println("Permits remaining ${atomically { tsem.available() }}") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-30.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm30 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | atomically { 11 | tsem.release(2) 12 | } 13 | //sampleEnd 14 | println("Permits remaining ${atomically { tsem.available() }}") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-31.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm31 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | atomically { 11 | tq.write(2) 12 | } 13 | //sampleEnd 14 | println("Items in queue ${atomically { tq.flush() }}") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-32.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm32 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | atomically { 11 | tq += 2 12 | } 13 | //sampleEnd 14 | println("Items in queue ${atomically { tq.flush() }}") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-33.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm33 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.write(2) 12 | tq.read() 13 | } 14 | //sampleEnd 15 | println("Result $result") 16 | println("Items in queue ${atomically { tq.flush() }}") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-34.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm34 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.tryRead() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-35.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm35 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.write(2) 12 | tq.write(4) 13 | 14 | tq.flush() 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | println("Items in queue ${atomically { tq.flush() }}") 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-36.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm36 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.write(2) 12 | 13 | tq.peek() 14 | } 15 | //sampleEnd 16 | println("Result $result") 17 | println("Items in queue ${atomically { tq.flush() }}") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-37.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm37 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.tryPeek() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-38.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm38 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | atomically { 11 | tq.write(1) 12 | tq.writeFront(2) 13 | } 14 | //sampleEnd 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-39.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm39 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.isEmpty() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-40.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm40 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.isNotEmpty() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-41.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm41 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | atomically { 11 | tq.write(0) 12 | tq.removeAll { it != 0 } 13 | } 14 | //sampleEnd 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-42.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm42 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.size() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-43.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm43 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr[5] 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-44.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm44 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr[5] = 3 12 | 13 | tarr[5] 14 | } 15 | //sampleEnd 16 | println("Result $result") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-45.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm45 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr.transform { it + 1 } 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-46.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm46 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr.fold(0) { acc, v -> acc + v } 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-47.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm47 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap[1] = "Hello" 12 | 13 | tmap.remove(1) 14 | } 15 | //sampleEnd 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-48.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm48 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | val result = atomically { 11 | tmap[1] = "Hello" 12 | tmap[2] = "World" 13 | 14 | tmap.lookup(1) 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-49.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm49 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | val result = atomically { 11 | tmap[1] = "Hello" 12 | tmap[2] = "World" 13 | 14 | tmap[2] 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-50.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm50 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap.insert(10, "Hello") 12 | } 13 | //sampleEnd 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-51.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm51 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap[1] = "Hello" 12 | } 13 | //sampleEnd 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-52.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm52 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap += (1 to "Hello") 12 | } 13 | //sampleEnd 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-53.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm53 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | val result = atomically { 11 | tmap[2] = "Hello" 12 | tmap.update(2) { it.reversed() } 13 | tmap[2] 14 | } 15 | //sampleEnd 16 | println("Result $result") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-54.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm54 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap[1] = "Hello" 12 | tmap.remove(1) 13 | } 14 | //sampleEnd 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-55.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm55 3 | 4 | import arrow.fx.stm.TSet 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tset = TSet.new() 10 | val result = atomically { 11 | tset.insert("Hello") 12 | tset.member("Hello") 13 | } 14 | //sampleEnd 15 | println("Result $result") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-56.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm56 3 | 4 | import arrow.fx.stm.TSet 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tset = TSet.new() 10 | atomically { 11 | tset.insert("Hello") 12 | } 13 | //sampleEnd 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-57.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm57 3 | 4 | import arrow.fx.stm.TSet 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tset = TSet.new() 10 | atomically { 11 | tset += "Hello" 12 | } 13 | //sampleEnd 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-58.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm58 3 | 4 | import arrow.fx.stm.TSet 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tset = TSet.new() 10 | atomically { 11 | tset.insert("Hello") 12 | tset.remove("Hello") 13 | } 14 | //sampleEnd 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-59.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm59 3 | 4 | import arrow.fx.stm.atomically 5 | import arrow.fx.stm.stm 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val i = 4 10 | val result = atomically { 11 | stm { 12 | if (i == 4) retry() 13 | "Not 4" 14 | } orElse { "4" } 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-stm-60.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from STM.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleStm60 3 | 4 | import arrow.fx.stm.atomically 5 | import arrow.fx.stm.stm 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val i = 4 10 | val result = atomically { 11 | stm { 12 | check(i <= 5) // This calls retry and aborts if i <= 5 13 | "Larger than 5" 14 | } orElse { "Smaller than or equal to 5" } 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TArray.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTarray01 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun example() { 8 | //sampleStart 9 | // Create a size 10 array and fill it by using the construction function. 10 | TArray.new(10) { i -> i * 2 } 11 | // Create a size 10 array and fill it with a constant 12 | TArray.new(size = 10, 2) 13 | // Create an array from `vararg` arguments: 14 | TArray.new(5, 2, 10, 600) 15 | // Create an array from any iterable 16 | TArray.new(listOf(5,4,3,2)) 17 | //sampleEnd 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TArray.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTarray02 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr[5] 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TArray.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTarray03 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr[5] = 3 12 | 13 | tarr[5] 14 | } 15 | //sampleEnd 16 | println("Result $result") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TArray.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTarray04 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr.transform { it + 1 } 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tarray-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TArray.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTarray05 3 | 4 | import arrow.fx.stm.TArray 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tarr = TArray.new(size = 10, 2) 10 | val result = atomically { 11 | tarr.fold(0) { acc, v -> acc + v } 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmap-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMap.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmap01 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | val result = atomically { 11 | tmap.set(1, "Hello") 12 | tmap[2] = "World" 13 | 14 | tmap.lookup(1) + tmap[2] 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmap-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMap.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmap02 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap.insert(1, "Hello") 12 | tmap[2] = "World" 13 | } 14 | //sampleEnd 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmap-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMap.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmap03 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap += (1 to "Hello") 12 | tmap += (2 to "World") 13 | } 14 | //sampleEnd 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmap-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMap.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmap04 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | val result = atomically { 11 | tmap[1] = "Hello" 12 | tmap[2] = "World" 13 | 14 | tmap.update(1) { it.reversed() } 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmap-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMap.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmap05 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | val result = atomically { 11 | tmap[1] = "Hello" 12 | tmap.member(1) 13 | } 14 | //sampleEnd 15 | println("Result $result") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmap-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMap.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmap06 3 | 4 | import arrow.fx.stm.TMap 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmap = TMap.new() 10 | atomically { 11 | tmap[1] = "Hello" 12 | 13 | tmap.remove(1) 14 | } 15 | //sampleEnd 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar01 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(10) 10 | val result = atomically { 11 | tmvar.take() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar02 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | val result = atomically { 11 | tmvar.tryTake() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar03 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(30) 10 | val result = atomically { 11 | tmvar.read() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar04 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | val result = atomically { 11 | tmvar.tryRead() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar05 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | atomically { 11 | tmvar.put(20) 12 | } 13 | //sampleEnd 14 | println("New value ${atomically { tmvar.tryTake() } }") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar06 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(20) 10 | val result = atomically { 11 | tmvar.tryPut(30) 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar07 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.new(30) 10 | val result = atomically { 11 | tmvar.swap(40) 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${atomically { tmvar.tryTake() } }") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tmvar-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TMVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTmvar08 3 | 4 | import arrow.fx.stm.TMVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tmvar = TMVar.empty() 10 | val result = atomically { 11 | tmvar.isEmpty() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue01 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | atomically { 11 | tq.write(2) 12 | // or alternatively 13 | tq += 4 14 | } 15 | //sampleEnd 16 | println("Items in queue ${atomically { tq.flush() }}") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue02 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | atomically { 11 | tq.write(1) 12 | tq.writeFront(2) 13 | } 14 | //sampleEnd 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue03 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.write(2) 12 | tq.read() 13 | } 14 | //sampleEnd 15 | println("Result $result") 16 | println("Items in queue ${atomically { tq.flush() }}") 17 | } 18 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue04 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.tryRead() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue05 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.write(2) 12 | 13 | tq.peek() 14 | } 15 | //sampleEnd 16 | println("Result $result") 17 | println("Items in queue ${atomically { tq.flush() }}") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-06.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue06 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.tryPeek() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-07.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue07 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.write(2) 12 | tq.write(4) 13 | 14 | tq.flush() 15 | } 16 | //sampleEnd 17 | println("Result $result") 18 | println("Items in queue ${atomically { tq.flush() }}") 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-08.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue08 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.isEmpty() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-09.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue09 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | val result = atomically { 11 | tq.size() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tqueue-10.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TQueue.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTqueue10 3 | 4 | import arrow.fx.stm.TQueue 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tq = TQueue.new() 10 | atomically { 11 | tq.write(0) 12 | tq.removeAll { it != 0 } 13 | } 14 | //sampleEnd 15 | println("Items in queue ${atomically { tq.flush() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tsemaphore-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TSemaphore.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTsemaphore01 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | atomically { 11 | // acquire one permit 12 | tsem.acquire() 13 | // acquire 3 permits 14 | tsem.acquire(3) 15 | } 16 | //sampleEnd 17 | println("Permits remaining ${atomically { tsem.available() }}") 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tsemaphore-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TSemaphore.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTsemaphore02 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(0) 10 | val result = atomically { 11 | tsem.tryAcquire() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Permits remaining ${atomically { tsem.available() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tsemaphore-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TSemaphore.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTsemaphore03 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | atomically { 11 | tsem.release() 12 | } 13 | //sampleEnd 14 | println("Permits remaining ${atomically { tsem.available() }}") 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tsemaphore-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TSemaphore.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTsemaphore04 3 | 4 | import arrow.fx.stm.TSemaphore 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tsem = TSemaphore.new(5) 10 | val result = atomically { 11 | tsem.available() 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("Permits remaining ${atomically { tsem.available() }}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tset-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TSet.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTset01 3 | 4 | import arrow.fx.stm.TSet 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tset = TSet.new() 10 | atomically { 11 | tset.insert("Hello") 12 | tset += "World" 13 | } 14 | //sampleEnd 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tset-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TSet.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTset02 3 | 4 | import arrow.fx.stm.TSet 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tset = TSet.new() 10 | atomically { 11 | tset.insert("Hello") 12 | tset.remove("Hello") 13 | } 14 | //sampleEnd 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tset-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TSet.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTset03 3 | 4 | import arrow.fx.stm.TSet 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tset = TSet.new() 10 | val result = atomically { 11 | tset.insert("Hello") 12 | tset.member("Hello") 13 | } 14 | //sampleEnd 15 | println("Result $result") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tvar-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTvar01 3 | 4 | import arrow.fx.stm.TVar 5 | 6 | suspend fun main() { 7 | //sampleStart 8 | val tvar = TVar.new(10) 9 | val result = tvar.unsafeRead() 10 | //sampleEnd 11 | println(result) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tvar-02.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTvar02 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.read() 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tvar-03.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTvar03 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.write(20) 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tvar-04.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTvar04 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.modify { it * 2 } 12 | } 13 | //sampleEnd 14 | println(result) 15 | } 16 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/jvmTest/kotlin/examples/example-tvar-05.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from TVar.kt by Knit tool. Do not edit. 2 | package arrow.fx.stm.examples.exampleTvar05 3 | 4 | import arrow.fx.stm.TVar 5 | import arrow.fx.stm.atomically 6 | 7 | suspend fun main() { 8 | //sampleStart 9 | val tvar = TVar.new(10) 10 | val result = atomically { 11 | tvar.swap(20) 12 | } 13 | //sampleEnd 14 | println("Result $result") 15 | println("New value ${tvar.unsafeRead()}") 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/fx/arrow-fx-stm/src/nonJvmMain/kotlin/arrow/fx/stm/internal/RetryException.kt: -------------------------------------------------------------------------------- 1 | package arrow.fx.stm.internal 2 | 3 | public actual object RetryException : Throwable("Arrow STM Retry. This should always be caught by arrow internally. Please report this as a bug if that is not the case!") 4 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-jackson/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id(libs.plugins.kotlin.jvm.get().pluginId) 3 | id("arrow.kotlin") 4 | alias(libs.plugins.kotlinx.serialization) // Needed for testing only 5 | } 6 | 7 | dependencies { 8 | api(projects.arrowCore) 9 | implementation(libs.jacksonModuleKotlin) 10 | testImplementation(kotlin("test")) 11 | testImplementation(libs.bundles.testing) 12 | } 13 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-jackson/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow-Core-Jackson 3 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-jackson/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.integrations.jackson.examples 2 | knit.dir=src/test/kotlin/examples/ 3 | 4 | test.package=arrow.integrations.jackson.examples.test 5 | test.dir=src/test/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-jackson/src/test/kotlin/arrow/integrations/jackson/module/KotestInlineUtils.kt: -------------------------------------------------------------------------------- 1 | package arrow.integrations.jackson.module 2 | 3 | import io.kotest.assertions.assertionCounter 4 | import io.kotest.assertions.failure 5 | 6 | inline fun shouldNotThrowAny(block: () -> T): T { 7 | assertionCounter.inc() 8 | 9 | val thrownException = try { 10 | return block() 11 | } catch (e: Throwable) { 12 | e 13 | } 14 | 15 | throw failure( 16 | "No exception expected, but a ${thrownException::class.simpleName} was thrown with message: \"${thrownException.message}\".", 17 | thrownException, 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-retrofit/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow-Core-Retrofit 3 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-retrofit/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.core.retrofit.examples 2 | knit.dir=src/test/kotlin/examples/ 3 | 4 | test.package=arrow.core.retrofit.examples.test 5 | test.dir=src/test/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-retrofit/src/main/kotlin/arrow/retrofit/adapter/either/ResponseE.kt: -------------------------------------------------------------------------------- 1 | package arrow.retrofit.adapter.either 2 | 3 | import arrow.core.Either 4 | import okhttp3.Headers 5 | import okhttp3.Response 6 | 7 | public data class ResponseE( 8 | val raw: Response, 9 | val body: Either, 10 | ) { 11 | 12 | val code: Int = raw.code() 13 | 14 | val message: String? = raw.message() 15 | 16 | val headers: Headers = raw.headers() 17 | 18 | val isSuccessful: Boolean = raw.isSuccessful 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/networkhandling/CallErrorTestClient.kt: -------------------------------------------------------------------------------- 1 | package arrow.retrofit.adapter.either.networkhandling 2 | 3 | import arrow.core.Either 4 | import arrow.retrofit.adapter.mock.ResponseMock 5 | import retrofit2.http.Body 6 | import retrofit2.http.GET 7 | import retrofit2.http.POST 8 | 9 | interface CallErrorTestClient { 10 | 11 | @GET("/") 12 | suspend fun getEither(): Either 13 | 14 | @POST("/") 15 | suspend fun postSomething(@Body something: String): Either 16 | } 17 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/mock/ErrorMock.kt: -------------------------------------------------------------------------------- 1 | package arrow.retrofit.adapter.mock 2 | 3 | data class ErrorMock(val errorCode: Int) 4 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/mock/ResponseMock.kt: -------------------------------------------------------------------------------- 1 | package arrow.retrofit.adapter.mock 2 | 3 | import kotlinx.serialization.Serializable 4 | 5 | @Serializable 6 | data class ResponseMock(val response: String) 7 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-retrofit/src/test/kotlin/examples/example-arrow-retrofit-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from EitherCallAdapterFactory.kt by Knit tool. Do not edit. 2 | package arrow.core.retrofit.examples.exampleArrowRetrofit01 3 | 4 | import arrow.core.Either 5 | import arrow.retrofit.adapter.either.ResponseE 6 | import retrofit2.http.GET 7 | 8 | data class User(val name: String) 9 | data class ErrorBody(val msg: String) 10 | 11 | interface MyService { 12 | 13 | @GET("/user/me") 14 | suspend fun getUser(): Either 15 | 16 | @GET("/user/me") 17 | suspend fun getUserResponseE(): ResponseE 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-serialization/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | id(libs.plugins.kotlinx.serialization.get().pluginId) 4 | } 5 | 6 | kotlin { 7 | sourceSets { 8 | commonMain { 9 | dependencies { 10 | api(projects.arrowCore) 11 | api(libs.kotlinx.serializationCore) 12 | } 13 | } 14 | 15 | commonTest { 16 | dependencies { 17 | implementation(libs.kotlinx.serializationJson) 18 | implementation(libs.bundles.testing) 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-serialization/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Core Serialization 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-core-serialization/src/commonMain/kotlin/arrow/core/serialization/SerializersModule.kt: -------------------------------------------------------------------------------- 1 | package arrow.core.serialization 2 | 3 | import arrow.core.* 4 | import kotlinx.serialization.modules.SerializersModule 5 | 6 | public val ArrowModule: SerializersModule = SerializersModule { 7 | contextual(Either::class) { (a, b) -> EitherSerializer(a, b) } 8 | contextual(Ior::class) { (a, b) -> IorSerializer(a, b) } 9 | contextual(NonEmptyList::class) { (t) -> NonEmptyListSerializer(t) } 10 | contextual(NonEmptySet::class) { (t) -> NonEmptySetSerializer(t) } 11 | contextual(Option::class) { (t) -> OptionSerializer(t) } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-raise-ktor-server/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi 2 | 3 | plugins { 4 | id("arrow.kotlin") 5 | } 6 | 7 | kotlin { 8 | @OptIn(ExperimentalKotlinGradlePluginApi::class) 9 | compilerOptions.freeCompilerArgs.add("-Xcontext-receivers") 10 | 11 | sourceSets { 12 | commonMain { 13 | dependencies { 14 | api(libs.ktor.server.core) 15 | api(projects.arrowCore) 16 | } 17 | } 18 | 19 | commonTest { 20 | dependencies { 21 | implementation(libs.ktor.test) 22 | implementation(libs.bundles.testing) 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-raise-ktor-server/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Raise Ktor Server 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-raise-ktor-server/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.raise.ktor.server.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.raise.ktor.server.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-resilience-ktor-client/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(libs.ktor.client.core) 10 | api(projects.arrowResilience) 11 | implementation(projects.arrowAtomic) 12 | } 13 | } 14 | 15 | commonTest { 16 | dependencies { 17 | implementation(libs.ktor.mock) 18 | implementation(projects.arrowAtomic) 19 | implementation(libs.bundles.testing) 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-resilience-ktor-client/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Resilience Ktor Client 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/integrations/arrow-resilience-ktor-client/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.resilience.ktor.client.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.resilience.ktor.client.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-compose/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Optics for Compose 3 | # Build configuration 4 | kapt.incremental.apt=false -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-ksp-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Optics Compiler KSP Plugin 3 | POM_PACKAGING=jar 4 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-ksp-plugin/src/main/kotlin/arrow/optics/plugin/OpticsProcessorOptions.kt: -------------------------------------------------------------------------------- 1 | package arrow.optics.plugin 2 | 3 | data class OpticsProcessorOptions( 4 | val useInline: Boolean, 5 | ) { 6 | val inlineText: String = if (useInline) "inline" else "" 7 | 8 | companion object { 9 | fun from(options: Map): OpticsProcessorOptions = OpticsProcessorOptions( 10 | useInline = options.get("inline")?.toBooleanStrict() ?: false, 11 | ) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-ksp-plugin/src/main/kotlin/arrow/optics/plugin/OpticsProcessorProvider.kt: -------------------------------------------------------------------------------- 1 | package arrow.optics.plugin 2 | 3 | import com.google.devtools.ksp.processing.SymbolProcessor 4 | import com.google.devtools.ksp.processing.SymbolProcessorEnvironment 5 | import com.google.devtools.ksp.processing.SymbolProcessorProvider 6 | 7 | class OpticsProcessorProvider : SymbolProcessorProvider { 8 | override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor = OpticsProcessor(environment.codeGenerator, environment.logger, OpticsProcessorOptions.from(environment.options)) 9 | } 10 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-ksp-plugin/src/main/kotlin/arrow/optics/plugin/internals/targets.kt: -------------------------------------------------------------------------------- 1 | package arrow.optics.plugin.internals 2 | 3 | internal val ALL_TARGETS = OpticsTarget.entries 4 | internal val SEALED_TARGETS = setOf(OpticsTarget.PRISM, OpticsTarget.LENS, OpticsTarget.DSL) 5 | internal val VALUE_TARGETS = setOf(OpticsTarget.ISO, OpticsTarget.DSL) 6 | internal val OTHER_TARGETS = setOf(OpticsTarget.LENS, OpticsTarget.DSL) 7 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-ksp-plugin/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider: -------------------------------------------------------------------------------- 1 | arrow.optics.plugin.OpticsProcessorProvider -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-reflect/api/arrow-optics-reflect.api: -------------------------------------------------------------------------------- 1 | public final class arrow/optics/ReflectionKt { 2 | public static final fun getEvery (Lkotlin/reflect/KProperty1;)Larrow/optics/PTraversal; 3 | public static final fun getLens (Lkotlin/reflect/KProperty1;)Larrow/optics/PLens; 4 | public static final fun getOptional (Lkotlin/reflect/KProperty1;)Larrow/optics/POptional; 5 | public static final fun getValues (Lkotlin/reflect/KProperty1;)Larrow/optics/PTraversal; 6 | public static final fun instance (Lkotlin/reflect/KClass;)Larrow/optics/PPrism; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-reflect/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id(libs.plugins.kotlin.jvm.get().pluginId) 3 | id("arrow.kotlin") 4 | } 5 | 6 | dependencies { 7 | api(projects.arrowCore) 8 | api(projects.arrowOptics) 9 | api(kotlin("reflect")) 10 | 11 | testImplementation(kotlin("test")) 12 | testImplementation(kotlin("reflect")) 13 | testImplementation(libs.bundles.testing) 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics-reflect/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Optics Kotlin Reflection 3 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowCore) 10 | } 11 | } 12 | 13 | commonTest { 14 | dependencies { 15 | implementation(libs.bundles.testing) 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Optics 3 | # Build configuration 4 | kapt.incremental.apt=false 5 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.optics.examples 2 | knit.dir=src/commonTest/kotlin/examples/ 3 | 4 | test.package=arrow.optics.examples.test 5 | test.dir=src/commonTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/predef.kt: -------------------------------------------------------------------------------- 1 | package arrow.optics 2 | 3 | @Suppress("ClassName") 4 | internal object EMPTY_VALUE { 5 | @Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE") 6 | inline fun unbox(value: Any?): T = 7 | if (value === this) null as T else value as T 8 | } 9 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics/src/commonMain/kotlin/arrow/optics/regex/dsl/Regex.kt: -------------------------------------------------------------------------------- 1 | package arrow.optics.regex.dsl 2 | 3 | import arrow.optics.regex.onceOrMore as regexOnceOrMore 4 | import arrow.optics.regex.zeroOrMore as regexZeroOrMore 5 | import arrow.optics.Traversal 6 | 7 | public fun Traversal.onceOrMore(traversal: Traversal): Traversal = 8 | this compose regexOnceOrMore(traversal) 9 | 10 | public fun Traversal.zeroOrMore(traversal: Traversal): Traversal = 11 | this compose regexZeroOrMore(traversal) 12 | -------------------------------------------------------------------------------- /arrow-libs/optics/arrow-optics/src/commonTest/kotlin/arrow/optics/dsl/Wrapper.kt: -------------------------------------------------------------------------------- 1 | package arrow.optics.dsl 2 | 3 | import arrow.optics.Lens 4 | import arrow.optics.PLens 5 | import kotlin.jvm.JvmInline 6 | 7 | @JvmInline 8 | value class Wrapper(val value: A) { 9 | companion object { 10 | fun lens(): Lens, A> = 11 | PLens(Wrapper::value) { _, a -> Wrapper(a) } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/resilience/arrow-resilience/README.md: -------------------------------------------------------------------------------- 1 | # Module main 2 | # Arrow Fx Resilience 3 | 4 | [![Arrow Fx logo](https://raw.githubusercontent.com/arrow-kt/arrow-site/main/docs/img/fx/arrow-fx-brand-sidebar.svg?sanitize=true)](https://arrow-kt.io) 5 | 6 | Λrrow Fx Resilience is part of Arrow Fx [**Λrrow**](https://arrow-kt.io/docs/fx/). -------------------------------------------------------------------------------- /arrow-libs/resilience/arrow-resilience/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowCore) 10 | implementation(libs.coroutines.core) 11 | } 12 | } 13 | commonTest { 14 | dependencies { 15 | implementation(projects.arrowFxCoroutines) 16 | implementation(projects.arrowPlatform) 17 | implementation(libs.coroutines.test) 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /arrow-libs/resilience/arrow-resilience/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Fx Resilience -------------------------------------------------------------------------------- /arrow-libs/resilience/arrow-resilience/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.resilience.examples 2 | knit.dir=src/jvmTest/kotlin/examples/ 3 | 4 | test.package=arrow.resilience.examples.test 5 | test.dir=src/jvmTest/kotlin/examples/autogenerated/ -------------------------------------------------------------------------------- /arrow-libs/resilience/arrow-resilience/src/jvmTest/kotlin/examples/example-flow-01.kt: -------------------------------------------------------------------------------- 1 | // This file was automatically generated from flow.kt by Knit tool. Do not edit. 2 | package arrow.resilience.examples.exampleFlow01 3 | 4 | import arrow.resilience.* 5 | import kotlinx.coroutines.flow.* 6 | 7 | suspend fun main(): Unit { 8 | var counter = 0 9 | val flow = flow { 10 | emit(counter) 11 | if (++counter <= 5) throw RuntimeException("Bang!") 12 | } 13 | //sampleStart 14 | val sum = flow.retry(Schedule.recurs(5)) 15 | .reduce(Int::plus) 16 | //sampleEnd 17 | println(sum) 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/stack/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=Arrow Stack 3 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-ktor/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(projects.arrowFxCoroutines) 10 | api(libs.ktor.server.core) 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-ktor/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=SuspendApp Ktor 3 | POM_DESCRIPTION=Ktor engine creation as a Resource, which will gracefully shut down when it's finished. 4 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-ktor/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.continuations.suspendapp.examples 2 | knit.dir=src/commonTest/kotlin/examples/ 3 | 4 | test.package=arrow.continuations.suspendapp.examples.test 5 | test.dir=src/commonTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-ktor/src/jvmMain/kotlin/arrow/continuations/ktor/KtorServer.jvm.kt: -------------------------------------------------------------------------------- 1 | package arrow.continuations.ktor 2 | 3 | internal actual val ktorShutdownHookEnabled: Boolean = 4 | System.getProperty("io.ktor.server.engine.ShutdownHook", "true") == "true" 5 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-ktor/src/nonJvmMain/kotlin/arrow/continuations/ktor/KtorServer.nonJvm.kt: -------------------------------------------------------------------------------- 1 | package arrow.continuations.ktor 2 | 3 | internal actual val ktorShutdownHookEnabled: Boolean = true 4 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-test-app/src/jsMain/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | fun main() = 2 | app(js("process.env['TASK']").toString()) 3 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-test-app/src/jvmMain/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | fun main(args: Array) = 2 | app(args.firstOrNull() ?: System.getenv("MODE")) 3 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-test-app/src/nativeMain/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | fun main(args: Array) = 2 | app(args.firstOrNull()) 3 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-test-app/src/wasmJsMain/kotlin/main.kt: -------------------------------------------------------------------------------- 1 | fun main() = 2 | app(getEnv("TASK")) 3 | 4 | fun getEnv(name: String): String? = js("process.env[name]") 5 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-test-runner/src/test/kotlin/JvmSpec.kt: -------------------------------------------------------------------------------- 1 | import org.junit.jupiter.api.condition.EnabledIf 2 | import kotlin.io.path.Path 3 | import kotlin.io.path.exists 4 | import kotlin.io.path.pathString 5 | import kotlin.jvm.optionals.getOrNull 6 | 7 | @EnabledIf("enabled") 8 | class JvmSpec : SuspendAppTest() { 9 | override fun prepareProcess(mode: String) = ProcessBuilder(java, "-jar", jar!!.pathString, mode) 10 | 11 | companion object { 12 | val java = ProcessHandle.current().info().command().getOrNull() 13 | val jar = System.getProperty("jvmJar")?.let(::Path) 14 | 15 | @JvmStatic 16 | fun enabled() = java != null && jar?.exists() ?: false 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp-test-runner/src/test/kotlin/WasmJsSpec.kt: -------------------------------------------------------------------------------- 1 | import org.junit.jupiter.api.condition.EnabledIf 2 | 3 | @EnabledIf("enabled") 4 | class WasmJsSpec : JsSpec() { 5 | override val config: JsTestConfig get() = Companion.config 6 | 7 | companion object { 8 | val config = JsTestConfig("wasmJsNodeRun") 9 | 10 | @JvmStatic 11 | fun enabled() = config.validConfig() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp/api/suspendapp.api: -------------------------------------------------------------------------------- 1 | public final class arrow/continuations/SuspendAppKt { 2 | public static final fun SuspendApp-exY8QGI (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function1;JLkotlin/jvm/functions/Function2;)V 3 | public static synthetic fun SuspendApp-exY8QGI$default (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function1;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V 4 | } 5 | 6 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("arrow.kotlin") 3 | } 4 | 5 | kotlin { 6 | sourceSets { 7 | commonMain { 8 | dependencies { 9 | api(libs.coroutines.core) 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp/gradle.properties: -------------------------------------------------------------------------------- 1 | # Maven publishing configuration 2 | POM_NAME=SuspendApp 3 | -------------------------------------------------------------------------------- /arrow-libs/suspendapp/suspendapp/knit.properties: -------------------------------------------------------------------------------- 1 | knit.package=arrow.continuations.suspendapp.examples 2 | knit.dir=src/commonTest/kotlin/examples/ 3 | 4 | test.package=arrow.continuations.suspendapp.examples.test 5 | test.dir=src/commonTest/kotlin/examples/autogenerated/ 6 | -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | repositories { 2 | gradlePluginPortal() 3 | mavenCentral() 4 | google() 5 | } 6 | 7 | plugins { 8 | `kotlin-dsl` 9 | } 10 | 11 | dependencies { 12 | implementation(libs.gradlePlugin.kotlin.base) 13 | implementation(libs.gradlePlugin.kotlin.multiplatform) 14 | implementation(libs.gradlePlugin.android.library) 15 | implementation(libs.gradlePlugin.spotless) 16 | implementation(libs.gradlePlugin.animalSniffer) 17 | implementation(libs.gradlePlugin.dokka) 18 | } 19 | -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 2 | 3 | rootProject.name = "arrow-convention" 4 | 5 | dependencyResolutionManagement { 6 | repositories { 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | versionCatalogs { 11 | create("libs") { 12 | from(files("../gradle/libs.versions.toml")) 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /generator-scripts/README.md: -------------------------------------------------------------------------------- 1 | # Generators 2 | 3 | This directory is for source code generators. 4 | 5 | To use generator: 6 | - Open Arrow in IntelliJ 7 | - Right click on file 8 | - Select "Run " -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arrow-kt/arrow/1b251d145addc99caf3f16a6b0bd075f1ed6541c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "commitBodyTable": true, 6 | "packageRules": [ 7 | { 8 | "matchPackagePatterns": [ 9 | "*" 10 | ], 11 | "matchUpdateTypes": [ 12 | "major", 13 | "minor", 14 | "patch" 15 | ], 16 | "groupName": "all dependencies", 17 | "groupSlug": "all" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /static/CNAME: -------------------------------------------------------------------------------- 1 | apidocs.arrow-kt.io -------------------------------------------------------------------------------- /static/img/doc/download-report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arrow-kt/arrow/1b251d145addc99caf3f16a6b0bd075f1ed6541c/static/img/doc/download-report.png -------------------------------------------------------------------------------- /static/img/logo/logo-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | --------------------------------------------------------------------------------