Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thoughtbot/Runes
Infix operators for monadic functions in Swift
https://github.com/thoughtbot/Runes
Last synced: 4 days ago
JSON representation
Infix operators for monadic functions in Swift
- Host: GitHub
- URL: https://github.com/thoughtbot/Runes
- Owner: thoughtbot
- License: mit
- Created: 2015-01-08T21:09:23.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2021-09-24T16:04:00.000Z (about 3 years ago)
- Last Synced: 2024-11-30T21:02:54.538Z (12 days ago)
- Language: Swift
- Homepage: https://thoughtbot.com/open-source
- Size: 246 KB
- Stars: 830
- Watchers: 45
- Forks: 65
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - Runes - Infix operators for monadic functions in Swift. (Functional Programming / Getting Started)
- awesome-swift - Runes - Functional operators: flatMap, map, apply. (Libs / Utility)
- awesome-swift - Runes - Functional operators: flatMap, map, apply. (Libs / Utility)
- awesome-ios-star - Runes - Infix operators for monadic functions in Swift. (Functional Programming / Getting Started)
- fucking-awesome-swift - Runes - Functional operators: flatMap, map, apply. (Libs / Utility)
- awesome-swift-cn - Runes - Functional operators for Swift - flatMap, map, apply, pure. (Libs / Utility)
- awesome-swift - Runes - Infix operators for monadic functions in Swift ` 📝 a year ago ` (Utility [🔝](#readme))
README
Indecipherable symbols that some people claim have actual meaning.
[![pod](https://img.shields.io/cocoapods/v/Runes.svg)](https://cocoapods.org/)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)Please see [the documentation] for [installation] instructions.
[the documentation]: Documentation/
[installation]: Documentation/installation.md## 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:```swift
// Optional+Functor:
public func <^> (f: T -> U, x: T?) -> U?// Optional+Applicative:
public func <*> (f: (T -> U)?, x: T?) -> U?
public func <* (lhs: T?, rhs: U?) -> T?
public func *> (lhs: T?, rhs: U?) -> U?
public func pure(x: T) -> T?// Optional+Alternative:
public func <|> (lhs: T?, rhs: T?) -> T?
public func empty() -> T?// Optional+Monad:
public func >>- (x: T?, f: T -> U?) -> U?
public func -<< (f: T -> U?, x: T?) -> U?
public func >-> (f: T -> U?, g: U -> V?) -> T -> V?
public func <-< (f: U -> V?, g: T -> U?) -> T -> V?// Array+Functor:
public func <^> (f: T -> U, x: [T]) -> [U]// Array+Applicative:
public func <*> (fs: [T -> U], x: [T]) -> [U]
public func <* (lhs: [T], rhs: [U]) -> [T]
public func *> (lhs: [T], rhs: [U]) -> [U]
public func pure(x: T) -> [T]// Array+Alternative:
public func <|> (lhs: [T], rhs: [T]) -> [T]
public func empty() -> [T]// Array+Monad:
public func >>- (x: [T], f: T -> [U]) -> [U]
public func -<< (f: T -> [U], x: [T]) -> [U]
public func >-> (f: T -> [U], g: U -> [V]) -> T -> [V]
public func <-< (f: U -> [V], g: T -> [U]) -> T -> [V]// Result+Functor:
public func <^> (f: (T) -> U, a: Result) -> Result// Result+Applicative:
public func <*> (f: Result<(T) -> U, E>, a: Result) -> Result
public func <* (lhs: Result, rhs: Result) -> Result
public func *> (lhs: Result, rhs: Result) -> Result
public func pure(_ a: T) -> Result// Result+Alternative:
public func <|> (lhs: Result, rhs: @autoclosure () -> Result) -> Result// Result+Monad:
public func >>- (a: Result, f: (T) -> Result) -> Result
public func -<< (f: (T) -> Result, a: Result) -> Result
public func >-> (f: @escaping (T) -> Result, g: @escaping (U) -> Result) -> (T) -> Result
public func <-< (f: @escaping (U) -> Result, g: @escaping (T) -> Result) -> (T) -> Result
```## Contributing ##
See the [CONTRIBUTING] document. Thank you, [contributors]!
[CONTRIBUTING]: CONTRIBUTING.md
[contributors]: https://github.com/thoughtbot/Runes/graphs/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.[LICENSE]: /LICENSE
## About ##
![thoughtbot](https://thoughtbot.com/logo.png)
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][community] or look at
our product [case studies] and [hire us][hire] to help build your iOS app.[community]: https://thoughtbot.com/community?utm_source=github
[case studies]: https://thoughtbot.com/ios?utm_source=github
[hire]: https://thoughtbot.com/hire-us?utm_source=github