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

Skip to content

Conversation

@politrons
Copy link
Contributor

I know with the migration of Scalaz to dev.zio the fromOption operator was refactor to allow use composition and other goodies to use Option instead the wrapped value.

Still in my team and other teams in my organization they claim they still want to have an operator to extract the value from the option once we transform into IO. And they will like to have still an operator IO[Unit, A]

That's why I bring back the feature we had in scalaz here with the tmp name fromOptionValue that return IO[Unit, A]

Again I understand the reasons why the operator was refactor, and I'm just bringing another alternative for those that dont want use the goodies of the new operator.

This MR is still work in progress, and only in case it's consider I will continue working with documentation and all the necessary stuff.

@andreamarcolin Finally I close and create a new PR take a look when you have some time.

adamgfraser
adamgfraser previously approved these changes Aug 30, 2020
@politrons
Copy link
Contributor Author

politrons commented Aug 30, 2020

@adamgfraser do you know if those test that are failing, are flaky test?, I've been checking and are not related with this feature. And in local fails only some times. I think there must be some RC with the timeouts

@adamgfraser
Copy link
Contributor

@politrons Yes they are. You want to revert the change to the other test just so we aren’t messing with unrelated things and then I will rerun the tests so we can get this merged?

@politrons
Copy link
Contributor Author

@adamgfraser I already revert the test. With some more context I could try to fix those flaky test.
For now let's see if we're lucky and the pipeline pass this time, and we can merge this

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.

Thanks for your work on this!

@adamgfraser adamgfraser merged commit 7780978 into zio:master Aug 31, 2020
/**
* @see See [[zio.ZIO.getOrFailUnit]]
*/
def getOrFailUnit[A](v: => Option[A]): IO[Unit, A] = ZIO.getOrFailUnit(v)
Copy link
Member

Choose a reason for hiding this comment

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

@adamgfraser Shouldn't this be IO[None.type, A] as per more recent convention?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jdegoes The goal of this constructor was to have a variant for users who want Unit in the error channel instead of None.type. So we have ZIO.fromOption for the normal recommended usage, ZIO.getOrFailUnit for if you really want Unit in the error channel, and ZIO.getOrFail for if you want NoSuchElementException in the error channel (for example, for unifying with other errors that are a subtype of Throwable). Does that make sense?

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