extractOpt
This commit is contained in:
@@ -165,6 +165,7 @@ class Kiss {
|
|||||||
],
|
],
|
||||||
identAliases: [
|
identAliases: [
|
||||||
// These ones won't conflict with variables and might commonly be used with (apply)
|
// These ones won't conflict with variables and might commonly be used with (apply)
|
||||||
|
"extractOpt" => Symbol("Prelude.extractOpt"),
|
||||||
"+" => Symbol("Prelude.add"),
|
"+" => Symbol("Prelude.add"),
|
||||||
"-" => Symbol("Prelude.subtract"),
|
"-" => Symbol("Prelude.subtract"),
|
||||||
"*" => Symbol("Prelude.multiply"),
|
"*" => Symbol("Prelude.multiply"),
|
||||||
|
@@ -4,6 +4,7 @@ using Std;
|
|||||||
|
|
||||||
import kiss.ReaderExp;
|
import kiss.ReaderExp;
|
||||||
import haxe.ds.Either;
|
import haxe.ds.Either;
|
||||||
|
import haxe.ds.Option;
|
||||||
import haxe.Constraints;
|
import haxe.Constraints;
|
||||||
import haxe.DynamicAccess;
|
import haxe.DynamicAccess;
|
||||||
#if js
|
#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 {
|
static function _and(values:Array<Dynamic>):Dynamic {
|
||||||
for (value in values) {
|
for (value in values) {
|
||||||
if (!truthy(value)) {
|
if (!truthy(value)) {
|
||||||
|
Reference in New Issue
Block a user