sinker

Core utility library. Provides enhanced basic types such as UInt, Array, Maybe and some more.
https://github.com/fal-works/sinker/

To install, run:

haxelib install sinker 0.6.0 

See using Haxelib in Haxelib documentation for more information.

README.md

sinker

Core utility library for Haxe.

Requires Haxe 4 (developed with v4.2.5).

Caveats

  • Basically platform-independent, however the main targets are Eval and HashLink.
  • Not yet very well tested.
  • Quite unstable!

Usage

The below enables you to use all features of sinker.

import sinker.*;
import sinker.globals.Globals.*;

using sinker.extensions.Index;

Note that some standard types (such as Array, UInt) will be shadowed with sinker types, which are not completely compatible (however you can still cast to the original types with casting methods).

Types

UInt

Unsigned integer based on Int.
#if sinker_debug checks against negative, otherwise no runtime overhead.

MaybeUInt

Represents either an UInt value or the absense of valid value.

Array

Abstract over standard Array<T> with several additional methods.
Uses UInt for length/indices.
#if sinker_debug does boundary checks when accessing elements.

Maybe

Abstract over standard Null<T> with stricter type cast control and some additional methods.
#if sinker_debug checks against null when unwrapping.

Option

Abstract over standard haxe.ds.Option<T> with some additional methods.

Result

Enum, either Ok(value: T) or Failed(message: String). Also has some additional methods.

Utility classes

The classes below have static utility methods for each type.

  • Ints
  • UInts
  • Floats
  • Arrays
  • Nulls

Static extension classes

Methods for static extension on:

  • String
  • Array<T>

And some more additional methods for specific array types:

  • Null<Array<T>>
  • Maybe<Array<T>>
  • Array<() -> Void>
  • Array<() -> Bool>

Compiler flags

flagdescription
sinker_debugEnables bound checks for UInt values and Array indices, and null checks in Maybe.unwrap(). Automatically set if --debug.

Link

FAL Haxe libraries

Contributors
fal-works
Version
0.6.0
Published
3 years ago
License
Apache

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