From ad7f2d22a04d866d413d17aa46872aa7a18eacb0 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 4 Feb 2019 20:30:06 -0600 Subject: [PATCH] REFACTOR: simplify the base_type_of function. --- std/schema.ucg | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/std/schema.ucg b/std/schema.ucg index e0dd691..4e74af8 100644 --- a/std/schema.ucg +++ b/std/schema.ucg @@ -11,13 +11,11 @@ let base_types = [ "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}, false = acc, -}; - -// Computes the base type of a value. -let base_type_of = func (val) => reduce(base_type_reducer, {val=val, typ="null"}, base_types).typ; +}, {val=val, typ="null"}, base_types).typ; // Turns any schema check module into a compile failure. // The module must export the computed value as the result field.