option-tools

Extra tools for haxe.ds.Option
https://bitbucket.org/pantagruel74/option-tools/

To install, run:

haxelib install option-tools 0.0.2 

See using Haxelib in Haxelib documentation for more information.

README.md

option-tools

Description

Package adds extra-functionality to haxe.ds.Option.

Requirements

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

Example of usage

package test;

import haxe.ds.Option;

using OptionTools;

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

API

    /**
        Checks that Option is Some
    **/
    public static inline function isSome<T>(
        t: Option<T>
    ): Bool {...}

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

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

    /**
        Apply Optional function to Option value or continue None
    **/
    public static inline function andThen<T>(
        t: Option<T>, 
        fn: (a: T) -> Option<T>
    ): Option<T> {...}

    /**
        Apply function to Option value or continue None
    **/
    public static inline function map<A, B>(
        t: Option<A>, 
        fn: (a: A) -> B
    ): Option<B> {...}

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

Author

Anatoly Starodubtsev Tostar74@mail.ru

Contributors
Anatoly_Starodubtsev
Version
0.0.2
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