Bow 是一个 Swift 中用于类型化函数式编程的库。
模块
Bow 被拆分成了多个模块,可以独立消费。这些模块是
Bow
:核心库。包含 Higher Kinded Types virtualization,函数操作工具,Typeclasses,数据类型,Monad Transformers 和原始类型的实例。BowOptics
:用于处理不同 optics 的模块。BowRecursionSchemes
:用于处理 recursion schemes 的模块。BowFree
:用于处理 Free Monads 的模块。BowGeneric
:用于处理泛型数据类型的模块。BowEffects
:用于处理 effects 的模块。BowBrightFutures
:提供 BrightFutures 集成的模块。BowRx
:提供 RxSwift 集成的模块。
还有一些用于测试的模块
BowLaws
:核心模块中类型类的水印。BowOpticsLaws
:optics 的水印。BowEffectsLaws
:effects 的水印。BowGenerators
:用于核心模块中数据类型的基于属性的测试生成器。BowFreeGenerators
:用于 BowFree 中数据类型的基于属性的测试生成器。BowEffectsGenerators
:用于 BowEffects 中数据类型的基于属性的测试生成器。BowRxGenerators
:用于 BowRx 中数据类型的基于属性的测试生成器。BowBrightFuturesGenerators
:用于 BowBrightFutures 中数据类型的基于属性的测试生成器。
Bow 使用 CocoaPods、Carthage 和 Swift Package Manager 提供。
CocoaPods
您可以根据需要将每个 Bow 模块作为单独的 pod 消费。您可以将以下行添加到 Podfile 中
pod "Bow", "~> {version}"
pod "BowOptics", "~> {version}"
pod "BowRecursionSchemes", "~> {version}"
pod "BowFree", "~> {version}"
pod "BowGeneric", "~> {version}"
pod "BowEffects", "~> {version}"
pod "BowRx", "~> {version}"
pod "BowBrightFutures", "~> {version}"
测试定律
pod "BowLaws", "~> {version}"
pod "BowOpticsLaws", "~> {version}"
pod "BowEffectsLaws", "~> {version}"
SwiftCheck 进行基于属性的测试的生成器
pod "BowGenerators", "~> {version}"
pod "BowFreeGenerators", "~> {version}"
pod "BowEffectsGenerators", "~> {version}"
pod "BowRxGenerators", "~> {version}"
pod "BowBrightFuturesGenerators", "~> {version}"
Carthage
Carthage 将下载整个 Bow 项目,但将为每个模块编译单一的框架,以便您可以单独使用。将以下行添加到您的 Cartfile 文件中。
github "bow-swift/Bow" ~> {version}
Swift Package Manager
创建一个类似于下面的 Package.swift
文件,并按需使用依赖。
// 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",
"BowBrightFutures"]),
.testTarget(name: "BowTestProjectTests",
dependencies: [
// Type class laws
"BowLaws",
"BowOpticsLaws",
"BowEffectsLaws",
// Generators for PBT with SwiftCheck
"BowGenerators",
"BowFreeGenerators",
"BowEffectsGenerators",
"BowRxGenerators",
"BowBrightFuturesGenerators"])
]
)
要构建它,只需运行:
$ swift build
贡献
如果您想为此库做出贡献,可以通过查看 问题 来了解一些待处理的任务。
如何运行项目
如果您还没有安装 Carthage,请先安装它。
brew install carthage
然后,运行以下命令来获取所有项目依赖:
carthage bootstrap
现在,您可以使用 Xcode 打开 Bow.xcodeproj
文件并运行测试,以验证一切是否正常工作。
许可协议
Copyright (C) 2018 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
https://apache.ac.cn/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.