Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@BardurArantsson
Copy link
Contributor

@BardurArantsson BardurArantsson commented Jul 1, 2020

Since I had a need for printing to the standard error in a little console application, I thought I'd try adding support upstream :). I might be missing something, but it seems like a small little win to add it.

I'm not exactly in love with the naming here, but OTOH I couldn't come up with anything much better. I considered using simply 'E' as the suffix, but that might be a little bit too opaque. Prefixing seems a bit odd because you then get different cases for the 'p' in errPutStrLn and putStrLn which might be annoying.

EDIT: I also tried to see if there was precedent in Haskell, but they only have putStr/putStrLn and hPutStr/hPutStrLn (which is the generalized handle version which already exists in the "live" scala implementation, but isn't exposed -- presumably because of a lack of safety for arbitrary PrintStreams).

@CLAassistant
Copy link

CLAassistant commented Jul 1, 2020

CLA assistant check
All committers have signed the CLA.

@adamgfraser
Copy link
Contributor

@BardurArantsson Sorry for the delay, will review this weekend.

@BardurArantsson
Copy link
Contributor Author

BardurArantsson commented Jul 3, 2020

No worries at all! I was just a bit confused about what the exact process was :)

Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

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

Looks great! Just a couple of minor comments on naming and documentation.

* Returns the contents of the output buffer. The first value written to
* the output buffer will be the first in the sequence.
*/
val errOutput: UIO[Vector[String]] =
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe outputErr for IDE discoverability? Also update Scaladoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

I wasn't quite sure what if you'd like to have the member in the Data class changed too, so I've left it for now. (It seems reasonable to me since it isn't really an issue for IDE discoverability and it is a "thing"... "the error output".)

Let me know if you'd like me to change that too -- I have no strong opinion on it :).

@BardurArantsson
Copy link
Contributor Author

New version uploaded. Hopefully it'll get through CI without issue :)

* Accesses a `TestConsole` instance in the environment and returns the
* contents of the error buffer.
*/
val errOutput: ZIO[TestConsole, Nothing, Vector[String]] =
Copy link
Contributor

Choose a reason for hiding this comment

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

Update name to conform to change above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about missing that. Can you tell I'm a bit of a noob with this pattern? ;)

I've rebased on latest master and pushed a new version.

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries! You're contributing so you're already one step ahead! 😃

@BardurArantsson
Copy link
Contributor Author

Hm, seems to be a test failure, but I'm pure sure it's unrelated to anything I did. Not sure what the procedure here is...

(I see there's a Rerun button in the CircleCI user interface, but it's grayed out for me.)

@adamgfraser
Copy link
Contributor

I reran that test.

Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

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

Looks great! Congratulations on your first contribution to ZIO!

@adamgfraser adamgfraser merged commit 08e3738 into zio:master Jul 11, 2020
@BardurArantsson BardurArantsson deleted the add-console-stderr-1 branch July 11, 2020 16:42
@BardurArantsson
Copy link
Contributor Author

Cool, thanks! :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants