JaviSoto / Runes

Infix operators for monadic functions in Swift

Home Page:https://thoughtbot.com/open-source

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indecipherable symbols that some people claim have actual meaning.

Carthage compatible

Installation

Note that as of Runes 1.2, master will assume Swift 1.2. The Runes 1.1.x series of releases are considered stable for long-term use.

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.

What's included?

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]

Contributing

See the CONTRIBUTING document. Thank you, contributors!

Need Help?

We offer 1-on-1 coaching. We can help you with functional programming in Swift, get started writing unit tests, and convert from Objective-C to Swift. Get in touch.

License

Runes is Copyright (c) 2015 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About

thoughtbot

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.

About

Infix operators for monadic functions in Swift

https://thoughtbot.com/open-source

License:MIT License


Languages

Language:Swift 92.3%Language:Ruby 4.1%Language:C++ 3.1%Language:Shell 0.5%