Skip to content
A library for functional data types in D language.
D Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
source/darjeeling
.gitignore
.travis.yml
README.md
darjeeling.iml
dub.sdl
dub.selections.json
win.mak

README.md

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

You can’t perform that action at this time.