GithubHelp home page GithubHelp logo

bow-swift / bow Goto Github PK

View Code? Open in Web Editor NEW
641.0 20.0 32.0 743.44 MB

๐Ÿน Bow is a cross-platform library for Typed Functional Programming in Swift

Home Page: https://bow-swift.io

License: Other

Swift 98.23% Ruby 1.77% Shell 0.01%
functional-programming category-theory functor monad swift-library free-monad tagless-final mtl cocoapods carthage swift bow effects composition fp spm declarative-programming reactive-programming hacktoberfest

bow's Introduction

bow Playground

Bow is a cross-platform library for Typed Functional Programming in Swift.

Documentation

All documentation and API reference is published in our website. Some links to key aspects of the library:

Modules

Bow is split into multiple modules that can be consumed independently. These modules are:

  • Bow: core library. Contains Higher Kinded Types emulation, function manipulation utilities, Typeclasses, Data Types, Monad Transformers, and instances for primitive types.
  • BowOptics: module to work with different optics.
  • BowRecursionSchemes: module to work with recursion schemes.
  • BowFree: module to work with Free Monads.
  • BowGeneric: module to work with generic data types.
  • BowEffects: module to work with effects.
  • BowRx: module to provide an integration with RxSwift.

There are also some modules for testing:

  • BowLaws: laws for type classes in the core module.
  • BowOpticsLaws: laws for optics.
  • BowEffectsLaws: laws for effects.
  • BowGenerators: generators for Property-based Testing for data types in the core module.
  • BowFreeGenerators: generators for Property-based Testing for data types in BowFree.
  • BowEffectsGenerators: generators for Property-based Testing for data types in BowEffects.
  • BowRxGenerators: generators for Property-based Testing for data types in BowRx.

Bow is available using Swift Package Manager, CocoaPods, and Carthage.

Swift Package Manager

Starting on Xcode 11, you can use the integration in the IDE with Swift Package manager to bring the dependencies into your project. You only need the repository URL: https://github.com/bow-swift/bow.git. For earlier versions of Xcode, create a Package.swift file similar to the next one and use the dependencies at your convenience.

// swift-tools-version:5.0

import PackageDescription

let package = Package(
    name: "BowTestProject",
    dependencies: [
        .package(url: "https://github.com/bow-swift/bow.git", from: "{version}")
    ],
    targets: [
        .target(name: "BowTestProject",
                dependencies: [
                    "Bow",
                    "BowOptics",
                    "BowRecursionSchemes",
                    "BowFree",
                    "BowGeneric",
                    "BowEffects",
                    "BowRx"]),
        .testTarget(name: "BowTestProjectTests",
                    dependencies: [
                        // Type class laws
                        "BowLaws",
                        "BowOpticsLaws",
                        "BowEffectsLaws",

                        // Generators for PBT with SwiftCheck
                        "BowGenerators",
                        "BowFreeGenerators",
                        "BowEffectsGenerators",
                        "BowRxGenerators"])
    ]
)

To build it, just run:

$ swift build

CocoaPods

You can consume each Bow module as a separate pod. You can add these lines to your Podfile at your convenience:

pod "Bow",                 "~> {version}"
pod "BowOptics",           "~> {version}"
pod "BowRecursionSchemes", "~> {version}"
pod "BowFree",             "~> {version}"
pod "BowGeneric",          "~> {version}"
pod "BowEffects",          "~> {version}"
pod "BowRx",               "~> {version}"

Testing laws:

pod "BowLaws",        "~> {version}"
pod "BowOpticsLaws",  "~> {version}"
pod "BowEffectsLaws", "~> {version}"

Generators for property-based testing with SwiftCheck:

pod "BowGenerators",              "~> {version}"
pod "BowFreeGenerators",          "~> {version}"
pod "BowEffectsGenerators",       "~> {version}"
pod "BowRxGenerators",            "~> {version}"

Carthage

Carthage will download the whole Bow project, but it will compile individual frameworks for each module that you can use separately. Add this line to your Cartfile:

github "bow-swift/Bow" ~> {version}

Contributing

If you want to contribute to this library, you can check the Issues to see some of the pending tasks.

How to run the project

Open Bow.xcodeproj in Xcode 11 (or newer) and you are ready to go. Bow uses the Swift Package Manager to handle its dependencies.

How to run the documentation project

  • Go to the root directory.
  • Run nef compile --project Documentation.app to get all dependencies.
  • Open Documentation.app and run the project.

For further information, refer to our Contribution guidelines.

How to create a new release

You can create a new release by running bundle exec fastlane release version_number:. For example, bundle exec fastlane ios release version_number: "0.8.0".

The following steps would be run:

  • Update the version in *.podspec files.
  • Create a tag with message added in the CHANGELOG file.
  • Deploy podspec files and make them publicly available.

License

Copyright (C) 2018-2021 The Bow Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

bow's People

Contributors

aballano avatar antoniomateogomez avatar bkase avatar calvellido avatar conradomateu avatar dependabot[bot] avatar devesh-shetty avatar dragna avatar dsabanin avatar ferranpujolcamins avatar gitter-badger avatar iboss-ptk avatar israelperezglez avatar jkmcclellan avatar miguelangel-dev avatar pietrocaselani avatar raulraja avatar truizlop avatar tylos avatar victorg1991 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bow's Issues

"ap" is backwards?

Swift can define ap in a much more readable (left-to-right, non-nested) format that matches Haskell. By introducing a generic at function scope we can constrain F's A to be a function between generics:

-public func ap<B>(_ ff: F<(A) -> B>) -> F<B>
+public func ap<A1, B>(_ fa: F<A1>) -> F<B> where A == (A1) -> B

And in practice:

Option.pure(add).ap(one).ap(two)

// vs. the right-to-left, awkwardly nested:
two.ap(one.ap(Option.pure(add)))

FWIW many functional libraries in Swift introduce the <*> operator, as another option. That could be an alternate consideration if the inconsistency with Arrow is an issue, though I assume Bow should be optimized for Swift syntax in general.

Rename to match Swift Foundation names

Description

There are some data types that match names in Arrow but are not aligned with how they are called in Swift. The following data types should be renamed to:

  • ListK -> ArrayK
  • MapK -> DictionaryK
  • NonEmptyList -> NonEmptyArray

Fix tests configuration

Currently, the Xcode project only includes BowTests as a test target. We need to add all our tests targets as schemes.

Ior API docs

Description

Add API reference for Ior data type.

Missing things comparing with Arrow

I've made a first pass review of the library to see what is missing and I've found some things

Optics

  • basically everything

Data

  • Sequence

Free

  • FreeApplicative
  • Trampoline

Effects

  • Rx

I didn't check in depth to see if there are methods missing yet
@raulraja

Optics

Missing things regarding optics:

  • Typeclasses: At, Each, FilterIndex, Index
  • Optics: Fold, Getter, Iso, Lens, Optional, Prism, Setter, Traversal
  • Laws for all optics

Split library to avoid unnecessary dependencies

The current implementation forces users of the library to depend on RxSwift and BrightFutures. We should split it into three:

  • Bow
  • Bow-Rx
  • Bow-BrightFutures

Any other integration with other libraries should as well be kept separately, so that users do not need to depend on unnecessary stuff.

Operator issues

A few issues with how Bow uses operators:

  • All the custom operators introduced use the same precedence group that ships with Swift (AdditionPrecedence). This prevents them from playing nicely with one another. For example, a Kleisli chain with pure compositions requires parenthesizing when >>> should take precedence over >=>.

    f
      >>> impureG
      >=> pureH
      >>> impureI
      >=> impureJ
  • Data defines infix operator >>=, but Swift already ships with >>= for bitwise shift assignment. Swift libraries tend to define >>- or >>>= instead as a result. In general, >>= seems less useful in Swift because you can define flatMap as an infix method, preserving readability where bind creates nesting.

  • Optics overloads + for composition. It might make more sense to use <<< or introduce a new operator. PureScript's profunctor package once defined .., though they use plain-ole <<< these days.

Logo and Micro site

@truizlop Maybe Israel and Calvellido can help with this but this is largely influenced by the options and choices you have on Swift.

Add GA tracker to the site

Hi there folks,

We should add the Google Analytics tracker to our websites to have more information about the visits and the impact of our library (and in the future to all the Gdocs to see how it works and how to improve it).

Here I attach the tracker we have to add it to the head of the site

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-18433785-19"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-18433785-19');
</script>

Cheers!

Delete deprecated operators.

Operators >=> and >>= were marked as deprecated in the previous release. We are deleting them for next version.

Clean up frameworks

Adding some frameworks through Carthage has polluted a little bit the project and it needs to be cleaned.

Document classes and methods

If you are documenting one of these classes, create a separate issue and assign it to yourself so that everyone knows what is being done.

We will keep track of what is documented here. For now, I will list all current classes in the library. We should also generate the HTML documents based on this (perhaps using Jazzy or similar). Sorted by priority and with an indicator of difficulty (๐Ÿ“— easy, ๐Ÿ“’ medium, ๐Ÿ“• hard to document):

Data

  • Action ๐Ÿ“•
  • ArrayK ๐Ÿ“—
  • CoT ๐Ÿ“•
  • Const ๐Ÿ“—
  • Coproduct ๐Ÿ“’
  • Coreader ๐Ÿ“’
  • CoSum ๐Ÿ“•
  • Day ๐Ÿ“•
  • DictionaryK ๐Ÿ“—
  • Either ๐Ÿ“—
  • Endo ๐Ÿ“’
  • Eval ๐Ÿ“—
  • Id ๐Ÿ“—
  • Ior ๐Ÿ“—
  • Moore ๐Ÿ“•
  • NonEmptyArray ๐Ÿ“—
  • Option ๐Ÿ“—
  • Pairing ๐Ÿ“•
  • Puller ๐Ÿ“•
  • Reader ๐Ÿ“—
  • SetK ๐Ÿ“—
  • State ๐Ÿ“—
  • Sum ๐Ÿ“•
  • Trampoline ๐Ÿ“’
  • Try ๐Ÿ“—
  • Validated ๐Ÿ“—
  • Zipper ๐Ÿ“•

Instances

  • BoolInstances ๐Ÿ“—
  • OptionInstances ๐Ÿ“—
  • NumberInstances ๐Ÿ“—
  • StringInstances ๐Ÿ“—

Syntax

  • HigherKinds ๐Ÿ“’
  • BooleanFunctions ๐Ÿ“—
  • Curry ๐Ÿ“—
  • Memoization ๐Ÿ“—
  • PartialApplication ๐Ÿ“—
  • Predef ๐Ÿ“—
  • Reverse ๐Ÿ“—

Typeclasses

  • Alternative ๐Ÿ“’
  • Applicative ๐Ÿ“—
  • ApplicativeError ๐Ÿ“—
  • Bimonad ๐Ÿ“’
  • Comonad ๐Ÿ“’
  • ComonadEnv ๐Ÿ“’
  • ComonadStore ๐Ÿ“’
  • ComonadTraced ๐Ÿ“’
  • ComonadTrans ๐Ÿ“’
  • Contravariant ๐Ÿ“—
  • Decidable ๐Ÿ“—
  • Divide ๐Ÿ“—
  • Divisible ๐Ÿ“—
  • EquatableK ๐Ÿ“—
  • Foldable ๐Ÿ“’
  • Functor ๐Ÿ“—
  • FunctorFilter ๐Ÿ“—
  • Invariant ๐Ÿ“—
  • Monad ๐Ÿ“—
  • MonadCombine ๐Ÿ“—
  • MonadError ๐Ÿ“—
  • MonadFilter ๐Ÿ“—
  • MonadReader ๐Ÿ“’
  • MonadState ๐Ÿ“’
  • MonadWriter ๐Ÿ“’
  • Monoid ๐Ÿ“—
  • Monoidal ๐Ÿ“—
  • MonoidK ๐Ÿ“—
  • NonEmptyReducible ๐Ÿ“—
  • Reducible ๐Ÿ“—
  • Selective ๐Ÿ“’
  • Semigroup ๐Ÿ“—
  • SemigroupK ๐Ÿ“—
  • Semiring ๐Ÿ“—
  • Traverse ๐Ÿ“’
  • TraverseFilter ๐Ÿ“’

Transformers

  • EitherT ๐Ÿ“’
  • OptionT ๐Ÿ“’
  • StateT ๐Ÿ“’
  • WriterT ๐Ÿ“’
  • StoreT ๐Ÿ“•
  • TracedT ๐Ÿ“•
  • EnvT ๐Ÿ“•

Effects

  • Atomic ๐Ÿ“’
  • IO ๐Ÿ“’
  • Ref ๐Ÿ“’
  • Resource ๐Ÿ“’

Effects/Foundation

  • ConsoleIO ๐Ÿ“—
  • FileManager
  • URLSession ๐Ÿ“—

Effects/Rx

  • MaybeK ๐Ÿ“’
  • ObservableK ๐Ÿ“’
  • SingleK ๐Ÿ“’

Effects/Typeclasses

  • Async ๐Ÿ“’
  • Bracket ๐Ÿ“’
  • Concurrent ๐Ÿ“’
  • ConcurrentEffect ๐Ÿ“’
  • Effect ๐Ÿ“’
  • MonadDefer ๐Ÿ“’
  • UnsafeRun ๐Ÿ“’
  • EffectComprehensions ๐Ÿ“’

Arrow

  • Cokleisli ๐Ÿ“’
  • Function0 ๐Ÿ“—
  • Function1 ๐Ÿ“—
  • FunctionK ๐Ÿ“’
  • Kleisli ๐Ÿ“’

Optics/Typeclasses

  • At ๐Ÿ“’
  • Cons ๐Ÿ“’
  • Each ๐Ÿ“’
  • FilterIndex ๐Ÿ“’
  • Index ๐Ÿ“’
  • Snoc ๐Ÿ“’

Optics

  • BoundSetter ๐Ÿ“’
  • Fold ๐Ÿ“’
  • Getter ๐Ÿ“’
  • Iso ๐Ÿ“’
  • Lens ๐Ÿ“’
  • Optional ๐Ÿ“’
  • Prism ๐Ÿ“’
  • Setter ๐Ÿ“’
  • Traversal ๐Ÿ“’

Optics/DSL

  • At+Optics ๐Ÿ“’
  • Each+Optics ๐Ÿ“’
  • Index+Optics ๐Ÿ“’
  • Kind+Optics ๐Ÿ“’

Optics/Instances

  • ArrayKOpticsInstances ๐Ÿ“’
  • ArrayOpticsInstances ๐Ÿ“’
  • ConstOpticsInstances ๐Ÿ“’
  • EitherKOpticsInstances ๐Ÿ“’
  • EitherOpticsInstances ๐Ÿ“’
  • IdOpticsInstances ๐Ÿ“’
  • IorOpticsInstances ๐Ÿ“’
  • OptionOpticsInstances ๐Ÿ“’
  • NonEmptyArrayOpticsInstances ๐Ÿ“’
  • StringOpticsInstances ๐Ÿ“’
  • TryOpticsInstances ๐Ÿ“’
  • ValidatedOpticsInstances ๐Ÿ“’

Optics/STD

  • Either+Optics ๐Ÿ“—
  • Id+Optics ๐Ÿ“—
  • Ior+Optics ๐Ÿ“—
  • ArrayK+Optics ๐Ÿ“—
  • Option+Optics ๐Ÿ“—
  • NonEmptyArray+Optics ๐Ÿ“—
  • Result+Optics ๐Ÿ“—
  • String+Optics ๐Ÿ“—
  • Try+Optics ๐Ÿ“—
  • Validated+Optics ๐Ÿ“—

Optics/Tuple

  • Tuple2 ๐Ÿ“—
  • Tuple3 ๐Ÿ“—
  • Tuple4 ๐Ÿ“—
  • Tuple5 ๐Ÿ“—
  • Tuple6 ๐Ÿ“—
  • Tuple7 ๐Ÿ“—
  • Tuple8 ๐Ÿ“—
  • Tuple9 ๐Ÿ“—
  • Tuple10 ๐Ÿ“—

Optics/Auto

  • AutoFold ๐Ÿ“—
  • AutoGetter ๐Ÿ“—
  • AutoLens ๐Ÿ“—
  • AutoOptics ๐Ÿ“—
  • AutoOptional ๐Ÿ“—
  • AutoPrism ๐Ÿ“—
  • AutoSetter ๐Ÿ“—
  • AutoTraversal ๐Ÿ“—

Free

  • Cofree ๐Ÿ“•
  • Coyoneda ๐Ÿ“•
  • Free ๐Ÿ“•
  • Yoneda ๐Ÿ“•

RecursionSchemes

  • Recursion ๐Ÿ“•

RecursionSchemes/Data

  • Fix ๐Ÿ“•
  • Mu ๐Ÿ“•
  • Nu ๐Ÿ“•

RecursionSchemes/Typeclasses

  • Birecursive ๐Ÿ“•
  • Corecursive ๐Ÿ“•
  • Recursive ๐Ÿ“•

Generic

  • Generic ๐Ÿ“•
  • HList ๐Ÿ“•
  • Product ๐Ÿ“•
  • Coproduct2 ๐Ÿ“•
  • Coproduct3 ๐Ÿ“•
  • Coproduct4 ๐Ÿ“•
  • Coproduct5 ๐Ÿ“•
  • Coproduct6 ๐Ÿ“•
  • Coproduct7 ๐Ÿ“•
  • Coproduct8 ๐Ÿ“•
  • Coproduct9 ๐Ÿ“•
  • Coproduct10 ๐Ÿ“•

Confusion about Maybe and Option

My iOS friends are about to try Bow but we are a little bit confused about naming of Option/Maybe.
Arrow for Kotlin is using Option, Bow is using Maybe and name Option is used for nullable types T?
Maybe is also in conflict with RxSwift's Maybe.

What are the reasons for using Maybe instead of Option in Bow?

Thanks for any hint!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.