Latest 0.1.0
Homepage https://github.com/to4iki/Reader
License MIT
Platforms ios 8.0
Authors

Build Status
Carthage compatible

Reader monad in Swift, inspired by implemention with Scala.

Overview

Reader is a wrapper for function that take some Input and produce Element.

// init(_:)
let reader = Reader<Int, Int> { $0 + 2 }

// execute(_:)
reader.execute(1) // 3
reader.execute(2) // 4

// map(_:)
reader
    .map { $0 * 2 }
    .execute(3) // 10

// flatMap(_:)
reader
    .flatMap { i1 in Reader<Int, Int> { i2 in i1 * i2 } }
    .execute(4) // 24

:syringe:

Simple and static Dependency Injection is possible with Reader

example: Playground

Installation

Carthage

Add following line into your Cartfile and run carthage update.

github "to4iki/Reader"

SwiftPackage Manager

Add following line into your Package.swift and run swift build.

dependencies: [
    .Package(url: "https://github.com/to4iki/Reader.git", majorVersion: 0)
]

Latest podspec

{
    "name": "Reader",
    "version": "0.1.0",
    "summary": "Reader monad in Swift",
    "description": "Reader, a wrapper for function that take some Input and produce Element.",
    "homepage": "https://github.com/to4iki/Reader",
    "source_files": "Sources/Reader/*.swift",
    "pod_target_xcconfig": {
        "SWIFT_WHOLE_MODULE_OPTIMIZATION": "YES",
        "APPLICATION_EXTENSION_API_ONLY": "YES"
    },
    "source": {
        "git": "https://github.com/to4iki/Reader.git",
        "tag": "0.1.0"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Toshiki Takezawa": "[email protected]"
    },
    "social_media_url": "https://twitter.com/to4iki",
    "platforms": {
        "ios": "8.0"
    },
    "swift_version": "4.0"
}

Pin It on Pinterest

Share This