typelift/Swiftx
关于
Functional data types and functions for any project
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Swiftx
Swiftx is a Swift library containing functional abstractions and extensions to the Swift Standard Library. Swiftx is a smaller and simpler way to introduce pure functional datatypes into any codebase.
For a more full-featured library checkout Swiftz.
Setup
Swiftx can be included one of two ways:
Framework
- Drag
Swiftx.xcodeprojorSwiftx-iOS.xcodeprojinto your project tree as a subproject - Under your project's Build Phases, expand Target Dependencies
- Click the + and add Swiftx
- Expand the Link Binary With Libraries phase
- Click the + and add Swiftx
- Click the + at the top left corner to add a Copy Files build phase
- Set the directory to
Frameworks - Click the + and add Swiftx
Standalone
- Copy the swift files under
Swiftx/Swiftxinto your project.
Introduction
Swiftx provides a number of common data types and abstractions any codebase can utilize.
A small example:
import Swiftx
let str : String? = .Some("Hello ")
let greeting = (+"World") <^> str // .Some("Hello World")
Seamless interaction with existing platform libraries is also possible with minimal effort:
import Foundation
import struct Swiftx.Result
/// result now contains either an array of file paths or the error generated by `NSFileManager`.
let result : Result<[String]> = from({ ep in
let documentsDirectory : String = (NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String)
return (NSFileManager.defaultManager().contentsOfDirectoryAtPath(documentsDirectory, error: ep) as [String]?) ?? []
})
Swiftx can even help with expressions of nothingness or errors:
import Swiftx
/// We may not be able to do what we said we'd do, but this definition compiles. At runtime,
/// any code that invokes this function will immediately halt the program.
func provePEqualsNP() -> Proof<P, NP> {
return undefined()
}
System Requirements
Swiftx supports OS X 10.9+ and iOS 8.0+.
License
Swiftx is released under the BSD license.
探索相关项目
加载中…