ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - thoughtbot/Runes: Infix operators for monadic functions in Swift
Infix operators for monadic functions in Swift. Contribute to thoughtbot/Runes development by creating an account on GitHub.
Visit Site

GitHub - thoughtbot/Runes: Infix operators for monadic functions in Swift

GitHub - thoughtbot/Runes: Infix operators for monadic functions in Swift

Indecipherable symbols that some people claim have actual meaning.

pod Carthage compatible Swift Package Manager compatible

Please see the documentation for installation instructions.

What's included?

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

Functor

  • <^> (pronounced "map")

Applicative Functor

  • <*> (pronounced "apply")
  • <* (pronounced "left sequence")
  • *> (pronounced "right sequence")
  • pure (pronounced "pure")

Alternative

  • <|> (pronounced "alternate")
  • empty (pronounced "empty")

Monad

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

Implementations

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 <* <T, U>(lhs: T?, rhs: U?) -> T?
public func *> <T, U>(lhs: T?, rhs: U?) -> U?
public func pure<T>(x: T) -> T?

// Optional+Alternative:
public func <|> <T>(lhs: T?, rhs: T?) -> T?
public func empty<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 <* <T, U>(lhs: [T], rhs: [U]) -> [T]
public func *> <T, U>(lhs: [T], rhs: [U]) -> [U]
public func pure<T>(x: T) -> [T]

// Array+Alternative:
public func <|> <T>(lhs: [T], rhs: [T]) -> [T]
public func empty<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]

// Result+Functor:
public func <^> <T, U, E>(f: (T) -> U, a: Result<T, E>) -> Result<U, E>

// Result+Applicative:
public func <*> <T, U, E>(f: Result<(T) -> U, E>, a: Result<T, E>) -> Result<U, E>
public func <* <T, U, E>(lhs: Result<T, E>, rhs: Result<U, E>) -> Result<T, E>
public func *> <T, U, E>(lhs: Result<T, E>, rhs: Result<U, E>) -> Result<U, E>
public func pure<T, E>(_ a: T) -> Result<T, E>

// Result+Alternative:
public func <|> <T, E>(lhs: Result<T, E>, rhs: @autoclosure () -> Result<T, E>) -> Result<T, E>

// Result+Monad:
public func >>- <T, U, E>(a: Result<T, E>, f: (T) -> Result<U, E>) -> Result<U, E>
public func -<< <T, U, E>(f: (T) -> Result<U, E>, a: Result<T, E>) -> Result<U, E>
public func >-> <T, U, V, E>(f: @escaping (T) -> Result<U, E>, g: @escaping (U) -> Result<V, E>) -> (T) -> Result<V, E>
public func <-< <T, U, V, E>(f: @escaping (U) -> Result<V, E>, g: @escaping (T) -> Result<U, E>) -> (T) -> Result<V, E>

Contributing

See the CONTRIBUTING document. Thank you, contributors!

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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory