Indecipherable symbols that some people claim have actual meaning.
The source on master
assumes Swift 2.0, and will be released as Runes 3.0.
If you need Swift 1.2 support, please use the 2.X series of releases.
github "thoughtbot/Runes"
Then run carthage update
.
Follow the current instructions in Carthage's README for up to date installation instructions.
Add the following to your Podfile:
pod 'Runes'
You will also need to make sure you're opting into using frameworks:
use_frameworks!
Then run pod install
with CocoaPods 0.36 or newer.
If you're a framework author, you might define your own custom types that would benefit from the operators defined in Runes. However, adding the entire Runes framework as a dependency might be too much overhead. In this case, you can use Carthage, CocoaPods, or Git to link to the file that defines the operators directly into your project. This will let you use Runes as a centralized dependency for the definition of the operators without needing to worry about additional overhead for your users.
By using Runes as a dependency in this way, it will be easier to ensure compatibility between your operator definitions and other types. This will also reduce the amount of duplication of effort across projects that want to include the same kinds of functionality.
In order to use Runes as a framework dependency, you must use git submodules. This will allow Carthage and CocoaPods to pull down the Runes source code without needing to expose the dependency to your users.
Add the following to Cartfile.private
:
github "thoughtbot/Runes"
Then run carthage update --no-use-binaries --use-submodules
. This will
ensure that you don't get any pre-built binaries that we are providing for
users who want the full Runes.framework
, and will tell Carthage to set up a
git submodule for you.
Once you've checked out the required version, you can link
Carthage/Checkouts/Runes/Source/Runes.swift
directly into your framework.
After adding Runes as a git submodule, you will need to modify your podspec to
tell CocoaPods to pull down your submodule dependencies. This is done by
passing a submodules: true
flag inside your spec's source
property.
For example, the source
for [Argo]'s main spec would look like this:
spec.source = {
git: "https://github.com/thoughtbot/Argo.git",
tag: "v#{s.version}",
submodules: true # add this line
}
Then add Runes.swift
to your spec's source_files
property. This tells
CocoaPods to include that file when building your framework.
Again, using Argo as an example, we can make our source_files
property look
like so:
spec.source_files = 'Argo/**/*.{h,swift}', 'Carthage/Checkouts/Runes/Source/Runes.swift'
Importing Runes introduces 3 new operators and one global function:
<^>
(pronounced "map")<*>
(pronounced "apply")>>-
(pronounced "flatMap") (left associative)-<<
(pronounced "flatMap") (right associative)pure
(pronounced "pure")
We also include default implementations for Optional and Array with the following type signatures:
// Optional:
public func <^><T, U>(f: T -> U, a: T?) -> U?
public func <*><T, U>(f: (T -> U)?, a: T?) -> U?
public func >>-<T, U>(a: T?, f: T -> U?) -> U?
public func -<<<T, U>(f: T -> U?, a: T?) -> U?
public func pure<T>(a: T) -> T?
// Array:
public func <^><T, U>(f: T -> U, a: [T]) -> [U]
public func <*><T, U>(fs: [T -> U], a: [T]) -> [U]
public func >>-<T, U>(a: [T], f: T -> [U]) -> [U]
public func -<<<T, U>(f: T -> [U], a: [T]) -> [U]
public func pure<T>(a: T) -> [T]
See the CONTRIBUTING document. Thank you, contributors!
Runes is Copyright (c) 2015 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.
Runes is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.
We love open source software! See our other projects or look at our product case studies and hire us to help build your iOS app.