Currier transforms any Swift function into a curried version of that function. This is achieved by wrapping it in a simple 'curry' call.
Given the following function:
func myMultiply(first: Float, second: Int) -> Double {
return Double(first) * Double(second)
}
Currier will produce a curried version:
let curriedMultiply: (Float) -> (Int) -> Double = curry(myMultiply) // Currier used here!
let multiplyByTwo: (Int) -> Double = curriedMultiply(2.0) // Partial application
let result: Double = multiplyByTwo(10)
assert(20 == result) // Assertion true
The previous example can be condensed down to the following:
let sameResult = curry(myMultiply)(2.0)(10)
The unit tests provide examples of calling the curry function using different numbers of parameters. The version of the function which takes two parameters is explicitly typed and commented.
There are no external requirements for this project, just Swift.
For older versions of Swift and Xcode, please see prior releases.
The Swift Package Manager is the official tool for managing the distribution of Swift code. It is currently only available for all Apple platforms. It can also be used with Linux but this project does not fully support that at this point.
If you use it to manage your dependencies, simply add Currier to the dependencies value of your Package.swift file.
dependencies: [
.package(url: "https://github.com/tigerpixel/Currier.git", from: "1.3.0")
]
Currier is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Currier"
If you use Carthage to manage your dependencies, simply add the following line to your Cartfile:
github "tigerpixel/Currier"
If you use Carthage to build your dependencies, make sure you have added Currier.framework
to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.
git submodule update --init --recursive
from within the Currier folder.Currier.xcodeproj
into your application’s Xcode project or workspace.Currier.framework
. to the “Embedded Binaries” section.EMBEDDED_CONTENT_CONTAINS_SWIFT
build setting to “Yes”.Currier is available under the MIT license. Details can be found within the LICENSE file.
link |
Stars: 1 |
Last commit: 4 years ago |
Update to Swift Package Manager to make compatible with Swift 5.1. Added Swift Package Manager capabilities to all platforms. Updated Swift code to take advantage of Swift 5.1 features. Swiftlint version update to 0.35.0.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics