Skip to content
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

ZValidation: add get, getOrElse, getOrElseWith #802

Merged
merged 3 commits into from
Nov 13, 2021

Conversation

sideeffffect
Copy link
Member

@sideeffffect sideeffffect commented Nov 13, 2021

Related ticket #791

/**
* Returns the value, because no error has occurred.
*/
final def value(implicit ev: E <:< Nothing): A = self.asInstanceOf[Success[W, A]].value
Copy link
Contributor

Choose a reason for hiding this comment

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

get and getOrElseWith? Can probably just fold with ev here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided not to use ev, because I have NonEmptyChunk[E] and although I could go out of my way to "prove" that is "absurd", it would probably be more hassle than it's worth it.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

adamgfraser
adamgfraser previously approved these changes Nov 13, 2021
@sideeffffect sideeffffect changed the title ZValidation: add valueOr and value to get out a successful value ZValidation: add get, getOrElse, getOrElseWith Nov 13, 2021
@sideeffffect sideeffffect linked an issue Nov 13, 2021 that may be closed by this pull request
@sideeffffect sideeffffect merged commit d7cab59 into zio:master Nov 13, 2021
@sideeffffect sideeffffect deleted the ZValidation-valueOr branch November 13, 2021 02:12
adamgfraser added a commit that referenced this pull request Nov 24, 2021
* Update sbt-ci-release to 1.5.9 (#747)

Co-authored-by: Ondra Pelech <ondra.pelech@gmail.com>

* Scala 3.1 (#763)

* Scala 3.1

* Use standard directory names and include laws in root

* Rename ScalaDotty to Scala3

* rename Refined -> Smart Newtype (#768)

* implement zvalidation.noneorfail (#767)

* Update mdoc, sbt-mdoc to 2.2.24 (#769)

* Update scalafmt-core to 3.0.7 (#770)

* Update sbt-bloop to 1.4.10 (#771)

* Update auxlib, javalib, nativelib, nscplugin, ... to 0.4.1 (#772)

* Update sbt-ci-release to 1.5.10 (#764)

* Run tests on 8 as the main Java version (#773)

* Update Node.js to v16 (#776)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* Update sbt-unidoc to 0.5.0 (#775)

Co-authored-by: Ondra Pelech <ondra.pelech@gmail.com>

* Update Node.js to v16.13.0 (#777)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* WIP: Begin Newtype fix (#778)

* begin newtype fix

* another attempt

* fix for scala 3

* fix example

* [RFC] Lattice foundation (#353)

* Lattice foundation

* Add Complement and Involution

* fix diagram

* JoinMeetShape

* add classic

* fix diagram

* Move to experimental

* Use type members

* Use `AndF` and `OrF`

* Add BooleanAlgebra

* fix

* Derive AndF/OrF from JoinMeetShape instances, split Complement to ExcludedMiddle and Noncontradiction

* fix diagram

* fix diagrams

* Lazy laws

* Move to experimental and split to laws and tests

* lawsNative

* Update diagram

* Absorption at the top

* Reuse laws

* Complement

* Lattice without the reification, i.e. abstract (#1)

* Improve Scala Steward config (#782)

* Update scalafmt-core to 3.0.8 (#781)

* Update autoupdate.yaml (#784)

* Update silencer-lib, silencer-lib_2.13.6, ... to 1.7.7 (#785)

* Update actions/checkout action to v2.4.0 (#788)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* fix subtype creation issue (#787)

* Update sbt-bloop to 1.4.11 (#789)

* Better error message when forgetting "inline" in Scala 3 Newtype (#790)

* better error message when forgetting "inline" in Scala 3 Newtype

* add error message when unable to read assertion at compile-time due to abstraction

* add better newtype errors for scala 2 (#792)

* Update scalafmt-core to 3.1.0 (#797)

* Update sbt-scalafix to 0.9.32 (#800)

* Update scalafmt-core to 3.1.1 (#801)

* ZValidation: add get, getOrElse, getOrElseWith (#802)

* Implement ZValidation.partition (#799)

* implement zvalidation.partition

* format

* implement partitionmapv

* Adds Associative.intercalate and ForEach.intercalate (#798)

* Update sbt-scalafmt to 2.4.4 (#805)

* Revert "Make Unit An Identity For State (#608)" (#807)

This reverts commit 85ae020.

* Update scalafmt-core to 3.1.2 (#808)

* merge fix

Co-authored-by: Scala Steward <43047562+scala-steward@users.noreply.github.com>
Co-authored-by: Kit Langton <kit.langton@gmail.com>
Co-authored-by: Adam Fraser <adam.fraser@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Alex Simkin <alex.simkin@outlook.com>
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.

Adding get, getOrElse, toFuture to zio.prelude.Validation
2 participants