Meaningful toString implementation #265

Closed
raimohanska opened this Issue Oct 19, 2013 · 12 comments

Projects

None yet

3 participants

@raimohanska
Contributor

How about a toString() function that would return something like this:

combineAsArray([constant(a),constant(b)])

or

take(merge(later(1, "lol"), later(2, "wat")), 1)

A quick implementation exists at 30ae4aa. And when I say quick I mean that all tests for toString are missing at the moment.

@raimohanska
Contributor

In fd95c4b, I've implementated and tested a lot of toString implementations... Still some combinators left.

My feeling is that this might be worth the effort :)

@raimohanska
Contributor

Most of the work is already done in the branch feature/dependency-graph-dispatch.

Todo: specs for the rest of the combinators.

@raimohanska
Contributor

I'm planning to include this in release 0.7.0. Help is appreciated!

@raimohanska
Contributor

Whoa. Just squeezed the toString implementations in.

So, this stuff is ready for release, and resides currently in the feature/dependency-graph-dispatch branch.

@raimohanska
Contributor

This is actually a comeback of #107.

@dnalot @hden @RoboTeddy any comments? Should we include .inspect too?

@raimohanska
Contributor

Hmm.. When running in CoffeeScript, the new toString doesn't seem to work:

var Bacon=require("./dist/Bacon")
coffee> Bacon._.toString({a:"b"})
'[object Object]'

This is weird, as the tests pass quite well and they are done in coffee too.

@hden
Contributor
hden commented Nov 4, 2013

It seem to be only happing in the REPL. Perhaps its a compiler issue?

# test.coffee
'use strict'
Bacon = require "./dist/Bacon"
console.log Bacon._.toString({a:"b"})
# shell
$ coffee test.coffee 
{a:b}
# REPL
> Bacon = require "./dist/Bacon"
...
> console.log Bacon._.toString({a:"b"})
[object Object]
@philipnilsson
Member

Yeah, I think it's Node.js, see e.g.
http://stackoverflow.com/questions/7428235/how-to-print-json-object-content-in-node-js
How
come it's an object, not a string?

On Mon, Nov 4, 2013 at 2:10 AM, Hao-kang Den notifications@github.comwrote:

It seem to be only happing in the REPL. Perhaps its a compiler issue?

test.coffee'use strict'Bacon = require "./dist/Bacon"console.log Bacon._.toString({a:"b"})

shell

$ coffee test.coffee
{a:b}

REPL

Bacon = require "./dist/Bacon"
...
console.log Bacon._.toString({a:"b"})
[object Object]


Reply to this email directly or view it on GitHubhttps://github.com/baconjs/bacon.js/issues/265#issuecomment-27659933
.

@hden
Contributor
hden commented Nov 21, 2013

It seems that this problem is fixed in the current master of coffee-script. Ready to close this issue?

@raimohanska
Contributor

The implementation is now in feature/0.7 and will be included in the 0.7.0 release.

@raimohanska
Contributor

One more thing: should we support .inspect() also?

I'm thinking about supporting toString/inspect for the following:

  • EventStream
  • Property
  • Bus
  • Event: Initial | Next | Error | End
  • Some | None

Should have tests for all of the included objects/classes.

@raimohanska raimohanska pushed a commit that referenced this issue Dec 19, 2013
Juha Paananen inspect and toString implementations for #265 3dc2ace
@raimohanska
Contributor

Added a name method as @rassie suggested in #273.

Also implemented inspect for nice node output.

Now you can

> B.once("1").name("one")
one
> B.once(1).name("stuff").take(1)
stuff.take(1)

I'm done with this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment