From b679f7d315111c78e79958ba5d1fe4f7c3a1f18f Mon Sep 17 00:00:00 2001 From: dotnetCarpenter Date: Wed, 24 Feb 2021 21:24:32 +0100 Subject: [PATCH] show encaspulated types via inspect() --- support/index.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/support/index.js b/support/index.js index 31d5ab23..4253d05a 100644 --- a/support/index.js +++ b/support/index.js @@ -53,10 +53,21 @@ const inspect = (x) => { switch (typeof t) { case 'string': return `'${t}'`; - case 'object': { - const ts = Object.keys(t).map(k => [k, inspect(t[k])]); - return `{${ts.map(kv => kv.join(': ')).join(', ')}}`; - } + case 'object': + switch (t.constructor) { + case Identity: + case IO: + case Left: + case List: + case Map: + case Maybe: + case Right: + case Task: + return t[util.inspect.custom]() + default: + const ts = Object.keys(t).map(k => [k, inspect(t[k])]); + return `{${ts.map(kv => kv.join(': ')).join(', ')}}`; + } default: return String(t); }