-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log arbitrary JSON-like object? #17
Comments
Is there ever a good reason to log the representation of a value unless you're debugging? (In which case |
I'm not convinced that it should exist here. This function would necessarily expose runtime representations of data, which, more often than not, are private implementation details (consider If you want to print out a representation of some data at runtime for consumption by other tools, there are better options for this, such as simple-json or argonaut. If you want to just print any old representation for a data type which doesn't necessarily have a |
Because @garyb asked for a case in which one would want to do this: For practical motivations behind this topic, I am using a logging system which says "Structured logging: Single-line JSON objects written to standard output or standard error will be read into Stackdriver as structured log entries." So, I need to send an object to stdout, right? Well, after doing some testing, I discovered this documentation is wrong, and I need to send a JSON-formatted string to stdout. (I send them a support ticket to update that misleading doc.) After discovering that stdout only accepts strings (duh, in hindsight), I decided to dig into how So for my purposes, I think I no longer need a If the formatting starts doing differently than I expect, I'll just switch to So, for people who come to this issue later: Do you really want to use |
Looks like
traceAny :: a -> Effect Unit
was added to this library awhile ago, then later removed.Some arguments against that type signature:
There's also the argument that it's possibly not referentially transparent.
I think it should exist here, though, in some form.
The
console.log
docs on MDN says it accepts any JS object. All PS types are JS objects at runtime, so we could say thata -> Effect Unit
is a good description.On the other hand, we could describe it as
Json -> Effect Unit
, whereJson
is a type which represents a data structure of "idiomatic primitive JSON types" in JavaScript, like plain-old objects (not classes), arrays, numbers, and strings.We could do a constraint on
a
and implement that constraint like justinwoo/simple-json did:Json a => a -> Effect Unit
.The text was updated successfully, but these errors were encountered: