result-tools

Extra tools result.Result
https://bitbucket.org/pantagruel74/result-tools/

To install, run:

haxelib install result-tools 0.0.1 

See using Haxelib in Haxelib documentation for more information.

README.md

result-tools

Description

Package adds extra-functionality to result.Result.

Requirements

Package tested for Haxe >= 4.0. The functionality or it missing of the package for lesser versions has not been tested.

Depends by

result

Example of usage

package test;

import resut.Result;

using ResultTools;

function someFunctionality(): Int {
    function addTwo(a: Int) return a + 2;
    var a = Ok(12);
    return a.map(addTwo).getWithDefault(13); //will return 12
}

API

    /**
        Checks that Result is Ok
    **/
    public static inline function isOk<T, E>(
        t: Result<T, E>
    ): Bool {...}

    /**
        Try to get value of Result or throws Exception
    **/
    public static inline function getVal<T, E>(
        t: Result<T, E>
    ): T {...}

    /**
        Try to get value of Result or get default value
    **/
    public static inline function getWithDefault<T, E>(
        t: Result<T, E>, 
        a: T
    ): T {...}

    /**
        Apply Resultable function to Result value or continue Error
    **/
    public static inline function andThen<T, B, E>(
        t: Result<T, E>, 
        fn: (a: T) -> Result<B, E>
    ): Result<B, E> {...}

    /**
        Apply function to Result value or continue Error
    **/
    public static inline function map<T, B, E>(
        t: Result<T, E>,
        fn: (a: T) -> B
    ): Result<B, E> {...}

    /**
        Apply filtering function to value of Result or continue Error
    **/
    public static inline function filter<T, E>(
        t: Result<T, E>, 
        fn: (a: T) -> Bool, 
        errVal: E
    ): Result<T, E> {...}

Author

Anatoly Starodubtsev Tostar74@mail.ru

Contributors
Anatoly_Starodubtsev
Version
0.0.1
Published
3 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂