Latest 1.0.5
Homepage https://github.com/yandex-money/functional-swift
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0
Authors

Yandex Money Functional Swift library

Functor

Transfer A<T> -> A<U> with T -> U

let ƒ: (T) -> U

let a: T? = T()

let b: U? = ƒ <^> a
let c: U? = U() <^ a
let d: U? = a ^> U()

Applicative

Applicative is a wrapper, that can apply wrapped function to wrapped
value.

Applicative transfer A<T> -> A<U> with A<(T) -> U>.

let ƒ: Optional<(T) -> U>

let a: T? = T()

let b: U? = ƒ <*> a

Applicative also has several auxiliary functions for applying a function
multiple arguments to the wrapped arguments:

liftA2: ((T, U) -> V, A<T>, A<U>) -> A<V>

liftA3: ((T, U, V) -> W, A<T>, A<U>, A<V>) -> A<W>

Monad

Transfer A<T> -> A<U> with T -> A<U>

let ƒ: (T) -> U?

let a: T? = T()

let b: U? = ƒ -<< a
let c: U? = a >>- ƒ

Monoid

Type which can be composed

struct Sum {
    let number: Integer

    init(_ number: Integer) {
        self.number = number
    }
}

extension Sum: Monoid {
    static func mempty() -> Sum {
        return Sum(0)
    }

    func mappend(_ monoid: Sum) -> Sum {
        return Sum(number + monoid.number)
    }
}

let numbers = [5, 8, 9, 0, 1, 7, 8]
let sum = numbers.map(Sum.init).mconcat().number // = 38

Latest podspec

{
    "name": "FunctionalSwift",
    "version": "1.0.5",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/yandex-money/functional-swift",
    "authors": {
        "Alexander Zalutskiy": "[email protected]"
    },
    "summary": "Categories and arrows (morphisms) for swift language.",
    "source": {
        "git": "https://github.com/yandex-money/functional-swift.git",
        "tag": "1.0.5"
    },
    "module_name": "FunctionalSwift",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0"
    },
    "source_files": "FunctionalSwift/**/*.swift",
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This