Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/typelift/swiftx
Functional data types and functions for any project
https://github.com/typelift/swiftx
Last synced: 4 days ago
JSON representation
Functional data types and functions for any project
- Host: GitHub
- URL: https://github.com/typelift/swiftx
- Owner: typelift
- License: bsd-3-clause
- Created: 2015-01-22T05:23:52.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-21T10:29:40.000Z (about 5 years ago)
- Last Synced: 2024-12-16T18:16:25.145Z (6 days ago)
- Language: Swift
- Size: 289 KB
- Stars: 219
- Watchers: 13
- Forks: 28
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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](https://github.com/typelift/swiftz).
Setup
-----Swiftx can be included one of two ways:
**Framework**
- Drag `Swiftx.xcodeproj` or `Swiftx-iOS.xcodeproj` into 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/Swiftx` into your project.
Introduction
------------Swiftx provides a number of common data types and abstractions any codebase can utilize.
A small example:
```swift
import Swiftxlet str : String? = .Some("Hello ")
let greeting = (+"World") <^> str // .Some("Hello World")
```Seamless interaction with existing platform libraries is also possible with
minimal effort:```swift
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:
```swift
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{
return undefined()
}
```System Requirements
===================Swiftx supports OS X 10.9+ and iOS 8.0+.
License
=======Swiftx is released under the BSD license.