sum-types icon indicating copy to clipboard operation
sum-types copied to clipboard

Improve appearance of nullary members in console logs

Open OliverJAsh opened this issue 2 years ago • 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:

https://user-images.githubusercontent.com/921609/198569067-ad6e2aae-04e5-4360-98a9-264dee63d725.mov

OliverJAsh avatar Oct 28 '22 10:10 OliverJAsh

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

samhh avatar Oct 28 '22 12:10 samhh