From 6dda6bac66f8ff008e03be62f79a223d0b200437 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 11 Jan 2023 22:27:00 +0000 Subject: [PATCH] more composable magic --- packages/core/util.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/core/util.mjs b/packages/core/util.mjs index 19ff7c126..b56b23be0 100644 --- a/packages/core/util.mjs +++ b/packages/core/util.mjs @@ -147,7 +147,16 @@ export function curry(func, overload, arity = func.length) { return func.apply(this, args); } else { const partial = function (...args2) { - return curried.apply(this, args.concat(args2)); + const result = curried.apply(this, args.concat(args2)); + if (args.length == arity - 1) { + // The penultimate arg.. so add some composition magic + // TODO - To make this useful, we also need to add stub functions for every pattern method to + // do the actual composing + result.__compose = function (pat) { + return result(pat); + }; + } + return result; }; if (overload) { overload(partial, args);