├── .github ├── ISSUE_TEMPLATE │ ├── bug.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── swift.yml ├── .gitignore ├── Package.resolved ├── Package.swift ├── README.md ├── Sources ├── BowLite │ └── Headers.swift ├── BowLiteCore │ ├── Data │ │ ├── Array │ │ │ ├── Array+Applicative.swift │ │ │ ├── Array+Foldable.swift │ │ │ ├── Array+Functor.swift │ │ │ ├── Array+FunctorFilter.swift │ │ │ ├── Array+Monad.swift │ │ │ ├── Array+Traverse.swift │ │ │ └── Array+Utilities.swift │ │ ├── Const │ │ │ ├── Const+Applicative.swift │ │ │ ├── Const+Functor.swift │ │ │ └── Const.swift │ │ ├── Either │ │ │ ├── Either+Applicative.swift │ │ │ ├── Either+ApplicativeError.swift │ │ │ ├── Either+Functor.swift │ │ │ ├── Either+Monad.swift │ │ │ └── Either.swift │ │ ├── Eval │ │ │ ├── Eval+Applicative.swift │ │ │ ├── Eval+Comonad.swift │ │ │ ├── Eval+Functor.swift │ │ │ ├── Eval+Monad.swift │ │ │ └── Eval.swift │ │ ├── Function │ │ │ ├── Function+Applicative.swift │ │ │ ├── Function+Contravariant.swift │ │ │ ├── Function+Functor.swift │ │ │ ├── Function+Monad.swift │ │ │ ├── Function+MonadReader.swift │ │ │ └── Function.swift │ │ ├── Id │ │ │ ├── Id+Applicative.swift │ │ │ ├── Id+Functor.swift │ │ │ ├── Id+Monad.swift │ │ │ └── Id.swift │ │ ├── Ior │ │ │ ├── Ior+Applicative.swift │ │ │ ├── Ior+Functor.swift │ │ │ ├── Ior+Monad.swift │ │ │ └── Ior.swift │ │ ├── Kleilsi │ │ │ └── Kleisli.swift │ │ ├── NonEmptyArray │ │ │ ├── NonEmptyArray+Applicative.swift │ │ │ ├── NonEmptyArray+Foldable.swift │ │ │ ├── NonEmptyArray+Functor.swift │ │ │ ├── NonEmptyArray+FunctorFilter.swift │ │ │ ├── NonEmptyArray+Monad.swift │ │ │ ├── NonEmptyArray+Traverse.swift │ │ │ └── NonEmptyArray.swift │ │ ├── Optional │ │ │ ├── Optional+Applicative.swift │ │ │ ├── Optional+ApplicativeError.swift │ │ │ ├── Optional+Functor.swift │ │ │ ├── Optional+FunctorFilter.swift │ │ │ ├── Optional+Monad.swift │ │ │ └── Optional+Utilities.swift │ │ ├── Pair │ │ │ ├── Pair+Applicative.swift │ │ │ ├── Pair+Functor.swift │ │ │ ├── Pair+Monad.swift │ │ │ └── Pair.swift │ │ ├── Result │ │ │ ├── Result+Applicative.swift │ │ │ ├── Result+ApplicativeError.swift │ │ │ ├── Result+Functor.swift │ │ │ ├── Result+Monad.swift │ │ │ └── Result+Utilities.swift │ │ ├── State │ │ │ ├── State+Applicative.swift │ │ │ ├── State+Functor.swift │ │ │ ├── State+Monad.swift │ │ │ ├── State+MonadState.swift │ │ │ └── State.swift │ │ ├── Store │ │ │ ├── Store+Applicative.swift │ │ │ ├── Store+Comonad.swift │ │ │ ├── Store+ComonadStore.swift │ │ │ ├── Store+Functor.swift │ │ │ └── Store.swift │ │ ├── Trampoline │ │ │ └── Trampoline.swift │ │ ├── Try │ │ │ ├── Try+Applicative.swift │ │ │ ├── Try+ApplicativeError.swift │ │ │ ├── Try+Functor.swift │ │ │ ├── Try+Monad.swift │ │ │ └── Try.swift │ │ ├── Validated │ │ │ ├── Validated+Applicative.swift │ │ │ ├── Validated+ApplicativeError.swift │ │ │ ├── Validated+Functor.swift │ │ │ └── Validated.swift │ │ └── Writer │ │ │ ├── Writer+Applicative.swift │ │ │ ├── Writer+Functor.swift │ │ │ ├── Writer+Monad.swift │ │ │ ├── Writer+MonadWriter.swift │ │ │ └── Writer.swift │ ├── Instances │ │ ├── BoolInstances.swift │ │ ├── NumberInstances.swift │ │ └── StringInstances.swift │ ├── Syntax │ │ ├── BooleanFunctions.swift │ │ ├── Composition.swift │ │ ├── Curry.swift │ │ ├── Memoization.swift │ │ ├── PartialApplication.swift │ │ ├── Predef.swift │ │ └── Reverse.swift │ └── Typeclasses │ │ ├── Monoid.swift │ │ ├── Semigroup.swift │ │ └── Semiring.swift ├── BowLiteEffects │ ├── Atomic.swift │ ├── Data │ │ ├── Array+ConcurrentTraverse.swift │ │ ├── Array+TraverseIO.swift │ │ ├── NonEmptyArray+ConcurrentTraverse.swift │ │ └── NonEmptyArray+TraverseIO.swift │ ├── EnvIO │ │ ├── EnvIO+Applicative.swift │ │ ├── EnvIO+ApplicativeError.swift │ │ ├── EnvIO+Async.swift │ │ ├── EnvIO+Concurrent.swift │ │ ├── EnvIO+Functor.swift │ │ ├── EnvIO+Monad.swift │ │ ├── EnvIO+MonadDefer.swift │ │ ├── EnvIO+MonadReader.swift │ │ └── EnvIO.swift │ ├── Foundation │ │ ├── ConsoleIO.swift │ │ ├── FileManager+Common.swift │ │ ├── FileManager+iOS+Mac.swift │ │ └── URLSession.swift │ ├── IO │ │ ├── IO+Applicative.swift │ │ ├── IO+ApplicativeError.swift │ │ ├── IO+Async.swift │ │ ├── IO+Bracket.swift │ │ ├── IO+Concurrent.swift │ │ ├── IO+Functor.swift │ │ ├── IO+Monad.swift │ │ ├── IO+MonadDefer.swift │ │ └── IO.swift │ ├── Internal │ │ ├── DispatchTimeInterval+Extensions.swift │ │ └── Queue.swift │ ├── Kleisli │ │ └── Kleisli+IO.swift │ ├── MonadComprehensions │ │ ├── BindingOperator.swift │ │ ├── EnvIO │ │ │ ├── EnvIOBindingExpression.swift │ │ │ ├── EnvIOBindingOperator.swift │ │ │ ├── EnvIOBoundVar.swift │ │ │ ├── EnvIOConcurrent.swift │ │ │ └── EnvIOMonadComprehensions.swift │ │ └── IO │ │ │ ├── IOBindingExpression.swift │ │ │ ├── IOBindingOperator.swift │ │ │ ├── IOBoundVar.swift │ │ │ ├── IOConcurrent.swift │ │ │ └── IOMonadComprehensions.swift │ ├── Ref.swift │ ├── Resource.swift │ └── Schedule.swift └── BowLiteOptics │ ├── AffineTraversal.swift │ ├── Lens.swift │ ├── Prism.swift │ └── Traversal.swift ├── Tests ├── BowLiteCoreTests │ ├── Data │ │ ├── Array │ │ │ ├── Array+ApplicativeTest.swift │ │ │ ├── Array+FunctorTest.swift │ │ │ └── Array+MonadTest.swift │ │ ├── Const │ │ │ ├── Const+ApplicativeTest.swift │ │ │ ├── Const+Arbitrary.swift │ │ │ └── Const+FunctorTest.swift │ │ ├── Either │ │ │ ├── Either+ApplicativeErrorTest.swift │ │ │ ├── Either+ApplicativeTest.swift │ │ │ ├── Either+Arbitrary.swift │ │ │ ├── Either+FunctorTest.swift │ │ │ └── Either+MonadTest.swift │ │ ├── Eval │ │ │ ├── Eval+ApplicativeTest.swift │ │ │ ├── Eval+Arbitrary.swift │ │ │ ├── Eval+FunctorTest.swift │ │ │ └── Eval+MonadTest.swift │ │ ├── Function │ │ │ ├── Function+ApplicativeTest.swift │ │ │ ├── Function+Arbitrary.swift │ │ │ ├── Function+Equatable.swift │ │ │ ├── Function+FunctorTest.swift │ │ │ └── Function+MonadTest.swift │ │ ├── Id │ │ │ ├── Id+ApplicativeTest.swift │ │ │ ├── Id+Arbitrary.swift │ │ │ ├── Id+FunctorTest.swift │ │ │ └── Id+MonadTest.swift │ │ ├── Ior │ │ │ ├── Ior+ApplicativeTest.swift │ │ │ ├── Ior+Arbitrary.swift │ │ │ ├── Ior+FunctorTest.swift │ │ │ └── Ior+MonadTest.swift │ │ ├── NonEmptyArray │ │ │ ├── NonEmptyArray+ApplicativeTest.swift │ │ │ ├── NonEmptyArray+Arbitrary.swift │ │ │ ├── NonEmptyArray+FunctorTest.swift │ │ │ └── NonEmptyArray+MonadTest.swift │ │ ├── Optional │ │ │ ├── Optional+ApplicativeErrorTest.swift │ │ │ ├── Optional+ApplicativeTest.swift │ │ │ ├── Optional+FunctorTest.swift │ │ │ └── Optional+MonadTest.swift │ │ ├── Pair │ │ │ ├── Pair+ApplicativeTest.swift │ │ │ ├── Pair+Arbitrary.swift │ │ │ ├── Pair+FunctorTest.swift │ │ │ └── Pair+MonadTest.swift │ │ ├── Result │ │ │ ├── Result+ApplicativeErrorTest.swift │ │ │ ├── Result+ApplicativeTest.swift │ │ │ ├── Result+FunctorTest.swift │ │ │ └── Result+MonadTest.swift │ │ ├── State │ │ │ ├── State+ApplicativeTest.swift │ │ │ ├── State+Arbitrary.swift │ │ │ ├── State+Equatable.swift │ │ │ ├── State+FunctorTest.swift │ │ │ └── State+MonadTest.swift │ │ ├── Store │ │ │ ├── Store+ApplicativeTest.swift │ │ │ ├── Store+Arbitrary.swift │ │ │ ├── Store+Equatable.swift │ │ │ └── Store+FunctorTest.swift │ │ ├── Try │ │ │ ├── Try+ApplicativeErrorTest.swift │ │ │ ├── Try+ApplicativeTest.swift │ │ │ ├── Try+Arbitrary.swift │ │ │ ├── Try+Equatable.swift │ │ │ ├── Try+FunctorTest.swift │ │ │ └── Try+MonadTest.swift │ │ ├── Validated │ │ │ ├── Validated+ApplicativeErrorTest.swift │ │ │ ├── Validated+ApplicativeTest.swift │ │ │ ├── Validated+Arbitrary.swift │ │ │ └── Validated+FunctorTest.swift │ │ └── Writer │ │ │ ├── Writer+ApplicativeTest.swift │ │ │ ├── Writer+Arbitrary.swift │ │ │ ├── Writer+FunctorTest.swift │ │ │ └── Writer+MonadTest.swift │ ├── Instances │ │ ├── BoolInstancesTest.swift │ │ ├── NumberInstancesTest.swift │ │ └── StringInstancesTest.swift │ └── Syntax │ │ ├── BooleanFunctionsTest.swift │ │ ├── CompositionTest.swift │ │ ├── CurryTest.swift │ │ ├── MemoizationTest.swift │ │ ├── PartialApplicationTest.swift │ │ ├── PredefTest.swift │ │ └── ReverseTest.swift ├── BowLiteEffectsTests │ ├── EnvIO │ │ ├── EnvIO+ApplicativeErrorTest.swift │ │ ├── EnvIO+ApplicativeTest.swift │ │ ├── EnvIO+Arbitrary.swift │ │ ├── EnvIO+ConcurrentTest.swift │ │ ├── EnvIO+Equatable.swift │ │ ├── EnvIO+FunctorTest.swift │ │ └── EnvIO+MonadTest.swift │ └── IO │ │ ├── IO+ApplicativeErrorTest.swift │ │ ├── IO+ApplicativeTest.swift │ │ ├── IO+Arbitrary.swift │ │ ├── IO+ConcurrentTest.swift │ │ ├── IO+Equatable.swift │ │ ├── IO+FunctorTest.swift │ │ └── IO+MonadTest.swift └── BowLiteLaws │ ├── AnyError.swift │ ├── BindingOperatorOverload.swift │ ├── CustomStringConvertibleLaws.swift │ ├── EquatableLaws.swift │ ├── MonoidLaws.swift │ ├── PropertyOperatorOverload.swift │ ├── SemigroupLaws.swift │ └── SemiringLaws.swift └── assets └── bow-lite-banner.png /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug 3 | about: Report malfunctioning of the library 4 | title: [Bug] 5 | labels: '' 6 | assignees: Maintainers 7 | 8 | --- 9 | 10 | ## Description 11 | 12 | *Explain the problem you are experiencing.* 13 | 14 | ## Expected outcome 15 | 16 | *Describe the result you should obtain.* 17 | 18 | ## Observed outcome 19 | 20 | *Describe the result you are obtaining instead.* 21 | 22 | ## Code to reproduce the Bug 23 | 24 | *Provide minimum code, together with imports, that we can execute to reproduce the bug.* 25 | 26 | ```swift 27 | // Your code here 28 | ``` 29 | 30 | ## Bow modules, version, platform 31 | 32 | *Indicate which modules you are using from Bow Lite and which versions. If you are not using public releases, provide branch and commit hash, but we suggest you to only use published releases. Indicate which platform you are targetting (iOS, macOS, tvOS, watchOS, playground)* 33 | 34 | ## Tooling 35 | 36 | - Xcode version: 37 | 38 | ## Other 39 | 40 | *Include any other details that can help us fix this bug efficiently.* 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Request new functionality in Bow Lite 4 | title: [Request] 5 | labels: '' 6 | assignees: Maintainers 7 | 8 | --- 9 | 10 | ## Description 11 | 12 | *Describe your proposal for new functionality.* 13 | 14 | ## Sample usage 15 | 16 | *Provide sample code of how the new functionality should work.* 17 | 18 | ## Potential implementation 19 | 20 | *Provide an outline of how this functionality could be implemented.* 21 | 22 | ## Modules 23 | 24 | *List the modules that may be affected by this new functionality. Describe if any new modules will need to be created.* 25 | 26 | ## Breaking changes 27 | 28 | *Describe possible breaking changes that may happen if this functionality is included.* 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Related issues 2 | 3 | *Reference issues that you are addressing with this pull request.* 4 | 5 | ## Goal 6 | 7 | *Describe the objective of these changes.* 8 | 9 | ## Implementation details 10 | 11 | *Describe any remarkable decisions that you made in the implementation of these changes.* 12 | 13 | ## Testing details 14 | 15 | *Describe any remarkable decisions that you made in the tests of these changes. 16 | -------------------------------------------------------------------------------- /.github/workflows/swift.yml: -------------------------------------------------------------------------------- 1 | name: Compile and test 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | macos: 7 | name: macos 8 | runs-on: macos-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Switch Xcode version 13 | run: sudo xcode-select -s /Applications/Xcode_11.4.1.app/Contents/Developer 14 | - name: Run tests 15 | run: swift test 16 | - name: Generate linux tests 17 | run: swift test --generate-linuxmain 18 | - name: Cached auto-generate linux tests 19 | uses: actions/upload-artifact@v1 20 | with: 21 | name: generate-linuxmain 22 | path: Tests 23 | 24 | linux: 25 | name: linux 26 | needs: macos 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - uses: actions/checkout@v2 31 | - name: Clean Tests 32 | run: rm -rf Tests 33 | - name: Get auto-generate linux tests 34 | uses: actions/download-artifact@v1 35 | with: 36 | name: generate-linuxmain 37 | path: Tests 38 | - name: Remove generated artifact 39 | uses: geekyeggo/delete-artifact@v1 40 | with: 41 | name: generate-linuxmain 42 | failOnError: false 43 | - name: Run tests 44 | run: swift test --parallel --num-workers 4 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Swift Package Manager 2 | .DS_Store 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | .build 7 | .swiftpm 8 | 9 | # Linux - generated swift files 10 | LinuxMain.swift 11 | **/XCTestManifests.swift 12 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "SwiftCheck", 6 | "repositoryURL": "https://github.com/bow-swift/SwiftCheck.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "748359f9a95edf94d0c4664102f104f56b1ff1fb", 10 | "version": "0.12.1" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |  2 | 3 |
4 |
5 |
6 |
7 |
8 | >
9 |
10 | Bow Lite is a cross-platform library for Typed Functional Programming in Swift. It is a lightweight version of [Bow](https://github.com/bow-swift/bow) where some complexity, like Higher Kinded Type emulation, has been removed.
11 |
12 | ## Documentation
13 |
14 | All documentation is available in [our website](https://bow-swift.io/). Notice that the documentation presents all examples using the full version of Bow. Although Bow Lite maintains compatibility with the API of Bow, there may be cases where there are some variations.
15 |
16 | ## Modules
17 |
18 | Bow Lite offers an umbrella module `BowLite` that contains:
19 |
20 | - **BowLiteCore**: a collection of the main data types typically used in FP projects, that you can find in the core module of Bow.
21 | - **BowLiteEffects**: an implementation of the `IO` and `EnvIO` data types to deal with side effects, that you can find in the BowEffects module.
22 | - **BowLiteOptics**: a monomorphic implementation of some optics, that you can find in the BowOptics module.
23 |
24 | ## How to get it
25 |
26 | Bow Lite is available using Swift Package Manager. You can include it using the corresponding wizard in Xcode, or adding the following line to your `Package.swift` manifest:
27 |
28 | ```swift
29 | .package(url: "https://github.com/bow-swift/bow-lite.git", from: "{version}")
30 | ```
31 |
32 | ```swift
33 | import BowLite
34 | ```
35 |
36 | # License
37 |
38 | Copyright (C) 2018-2021 The Bow Authors
39 |
40 | Licensed under the Apache License, Version 2.0 (the "License");
41 | you may not use this file except in compliance with the License.
42 | You may obtain a copy of the License at
43 |
44 | http://www.apache.org/licenses/LICENSE-2.0
45 |
46 | Unless required by applicable law or agreed to in writing, software
47 | distributed under the License is distributed on an "AS IS" BASIS,
48 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49 | See the License for the specific language governing permissions and
50 | limitations under the License.
51 |
--------------------------------------------------------------------------------
/Sources/BowLite/Headers.swift:
--------------------------------------------------------------------------------
1 | @_exported import BowLiteCore
2 | @_exported import BowLiteEffects
3 | @_exported import BowLiteOptics
4 |
5 | precedencegroup KleisliCompositionPrecedence {
6 | associativity: left
7 | }
8 |
9 | infix operator >=>: KleisliCompositionPrecedence
10 |
11 | precedencegroup CompositionPrecedence {
12 | associativity: left
13 | }
14 |
15 | infix operator <<<: CompositionPrecedence
16 | infix operator >>>: CompositionPrecedence
17 |
18 | precedencegroup PartialApplicationPrecedence {}
19 |
20 | infix operator |> : PartialApplicationPrecedence
21 |
22 | infix operator <- : AssignmentPrecedence
23 | prefix operator |<-
24 |
25 | // Using operator / to obtain prisms, as seen on
26 | // Pointfree's Case Paths: https://github.com/pointfreeco/swift-case-paths
27 | prefix operator /
28 |
--------------------------------------------------------------------------------
/Sources/BowLiteCore/Data/Array/Array+Functor.swift:
--------------------------------------------------------------------------------
1 | public extension Array {
2 | /// Given a function, provides a new function lifted to the context of this type.
3 | ///
4 | /// - Parameter f: Function to be lifted.
5 | /// - Returns: Function in the context of this type.
6 | static func lift(_ f: @escaping (Element) -> B) -> (Array