Infix operators for monadic functions in Swift
Swift Shell Ruby Objective-C Vim script
Latest commit 043c8b2 Nov 12, 2016 @gfontenot gfontenot Rework README
The README was getting to be a sprawling inconsistent mess. I've done a
few things here:

- Started to break out the README into smaller documentation files.
Right now it's just the installation instructions and version
compatibility, but it's a start.
- Reorganize the functions we're exporting to make it a little easier to
- Standardize the markdown header format
- Add cocoapods and swift package manager badges for completeness

Indecipherable symbols that some people claim have actual meaning.

pod Carthage compatible Swift Package Manager compatible

Please see the documentation for version compatibility and installation information.

What's included?

Importing Runes introduces several new operators and one global function that correspond to common Haskell typeclasses:


  • <^> (pronounced "map")

Applicative Functor

  • <*> (pronounced "apply")
  • pure (pronounced "pure")


  • >>- (pronounced "flatMap") (left associative)
  • -<< (pronounced "flatMap") (right associative)
  • >-> (pronounced "Monadic compose") (left associative)
  • <-< (pronounced "Monadic compose") (right associative)


We also include default implementations for Optional and Array with the following type signatures:

// Optional+Functor:
public func <^> <T, U>(f: T -> U, x: T?) -> U?

// Optional+Applicative:
public func <*> <T, U>(f: (T -> U)?, x: T?) -> U?
public func pure<T>(x: T) -> T?

// Optional+Monad:
public func >>- <T, U>(x: T?, f: T -> U?) -> U?
public func -<< <T, U>(f: T -> U?, x: T?) -> U?
public func >-> <T, U, V>(f: T -> U?, g: U -> V?) -> T -> V?
public func <-< <T, U, V>(f: U -> V?, g: T -> U?) -> T -> V?

// Array+Functor:
public func <^> <T, U>(f: T -> U, x: [T]) -> [U]

// Array+Applicative:
public func <*> <T, U>(fs: [T -> U], x: [T]) -> [U]
public func pure<T>(x: T) -> [T]

// Array+Monad:
public func >>- <T, U>(x: [T], f: T -> [U]) -> [U]
public func -<< <T, U>(f: T -> [U], x: [T]) -> [U]
public func >-> <T, U, V>(f: T -> [U], g: U -> [V]) -> T -> [V]
public func <-< <T, U, V>(f: U -> [V], g: T -> [U]) -> T -> [V]


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.