mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
REFACTOR: simplify the base_type_of function.
This commit is contained in:
parent
b571ead599
commit
ad7f2d22a0
@ -11,13 +11,11 @@ let base_types = [
|
|||||||
"module",
|
"module",
|
||||||
];
|
];
|
||||||
|
|
||||||
let base_type_reducer = func (acc, f) => select (acc.val is f), f, {
|
// Computes the base type of a value.
|
||||||
|
let base_type_of = func (val) => reduce(func (acc, f) => select (acc.val is f), f, {
|
||||||
true = acc{typ = f},
|
true = acc{typ = f},
|
||||||
false = acc,
|
false = acc,
|
||||||
};
|
}, {val=val, typ="null"}, base_types).typ;
|
||||||
|
|
||||||
// Computes the base type of a value.
|
|
||||||
let base_type_of = func (val) => reduce(base_type_reducer, {val=val, typ="null"}, base_types).typ;
|
|
||||||
|
|
||||||
// Turns any schema check module into a compile failure.
|
// Turns any schema check module into a compile failure.
|
||||||
// The module must export the computed value as the result field.
|
// The module must export the computed value as the result field.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user