Description

A library for functional data types in D.

Package Information

Version0.3.0 (2016-May-27)
Homepage https://github.com/Gab-km/darjeeling
Repository https://github.com/Gab-km/darjeeling
LicenseBSL-1.0
CopyrightCopyright © 2016, Kazuhiro Matsushima
AuthorsKazuhiro Matsushima
Registered byKazuhiro Matsushima
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

Darjeeling

A library for functional data types in D.

Build Status

Dub version

Usage

import std.stdio : writeln;
import darjeeling.maybe : Maybe;
import darjeeling.either : Either;
import darjeeling.trial : Trial;

void main()
{
    auto maybe = Maybe!int.just(42);
    if (maybe.isJust)
    {
        writeln(maybe.fromJust());  //#=> 42
    }
    
    auto either = Either!(string, int).right(33-4);
    if (either.isRight)
    {
        writeln(either.right());    //#=> 29
    }
    
    auto trial = Trial!int.trying({
        auto x = 1;
        if (x > 0) throw new Exception("positive");
        return x;
    });
    if (trial.isFailure)
    {
        auto left = trial.getOrLeft();
        writeln(left.left().msg);   //#=> positive
    }
}

Installation

You can use this package with DUB:

dependencies {
    "darjeeling": "~>0.3.0"
}

Documentation

TODO

Available versions

0.3.0 0.2.0 0.1.0 ~master