unsplash/sum-types

Improve appearance of nullary members in console logs

OliverJAsh opened this issue · 1 comments

I'm not sure if this is possible.

Currently nullary members appear as functions. It's difficult to view the contents (tag and value).

image

console.dir helps because it allows us to inspect properties on the function:

Screen.Recording.2022-10-28.at.11.42.51.mov
samhh commented

The most relevant issue is #44 and its fix #45. A less hacky solution would solve this but I couldn't think of anything else at the time that didn't have worse tradeoffs.

In Haskell-land you can't print without a Show instance. I know we're taking a similar approach on Web. It's not quite as ergonomic mind given the need to pass typeclass instances around.

It looks like we could do something like this on Node but I don't know about browsers:

> { [Symbol.for('nodejs.util.inspect.custom')]: () => 'foo' }
foo