Skip to content

Conversation

@gliptak
Copy link
Contributor

@gliptak gliptak commented Jun 8, 2016

No description provided.

@gliptak
Copy link
Contributor Author

gliptak commented Jun 13, 2016

@mperry Please review. Thanks

assertThat(result, is("FOO"));
}

public IO<Unit> println(final String s) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make this return the string, rather than assign it to the instance variable result.

Longer term, perhaps we need a bind method like: IO<A> bindLeft(IO<A> io, F<A, IO<B>> f) which binds, but returns the a from the left argument. But this would be another issue. I would have to check the Haskell doc to see if this exists.

Copy link
Contributor Author

@gliptak gliptak Jun 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a way to mock the println call. In general print returns Unit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. I thought it would be better to return IO<String>and return s here. Then in the method above you can replace result with readAndPrintUpper.... and remove the variable result. This would improve referential transparency.

@mperry mperry merged commit 794f9b9 into functionaljava:master Jun 19, 2016
@gliptak gliptak deleted the iocov branch June 19, 2016 22:27
@mperry mperry added the internal label Jul 1, 2016
@mperry mperry added this to the v4.6 milestone Jul 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants