extractOpt

This commit is contained in:
2025-08-07 18:18:10 -05:00
parent c0ab63cdb0
commit 6085697914
2 changed files with 9 additions and 0 deletions

View File

@@ -165,6 +165,7 @@ class Kiss {
],
identAliases: [
// These ones won't conflict with variables and might commonly be used with (apply)
"extractOpt" => Symbol("Prelude.extractOpt"),
"+" => Symbol("Prelude.add"),
"-" => Symbol("Prelude.subtract"),
"*" => Symbol("Prelude.multiply"),

View File

@@ -4,6 +4,7 @@ using Std;
import kiss.ReaderExp;
import haxe.ds.Either;
import haxe.ds.Option;
import haxe.Constraints;
import haxe.DynamicAccess;
#if js
@@ -76,6 +77,13 @@ class Prelude {
};
}
public static function extractOpt<T>(opt:Option<T>) {
return switch (opt) {
case Some(v): v;
default: throw 'Failed to extract Option: $opt';
};
}
static function _and(values:Array<Dynamic>):Dynamic {
for (value in values) {
if (!truthy(value)) {