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

Skip to content

Enhance combinators for working with sum types (Option, Either, etc.) #1217

@jdegoes

Description

@jdegoes

A few operators can allow digging into terms of sum types, pushing error states onto the error channel; and a couple more can allow "popping" error states off the error channel.

trait ZIO[R, E, A] {
  def left[B, C](implicit ev: A <:< Either[B, C]): ZIO[R, Option[E], B] = ???
  def right[B, C](implicit ev: A <:< Either[B, C]): ZIO[R, Option[E], C] = ???
  def some[B](implicit ev: A <:< Option[B]): ZIO[R, Option[E], B] = ???
  def none[B](implicit ev: A <:< Option[B]): ZIO[R, Option[E], Unit] = ???
  def head[B](implicit ev: A <:< List[B]): ZIO[R, Option[E], B] = ???
  
  def fuseError[E1, E2 <: E1](default: E2)(implicit ev: E <: Option[E1]): ZIO[R, E1, B] = ???

  def peelError[E1, A1 >: A](default: A1)(implicit ev: E <: Option[E1]): ZIO[R, E1, A1] = ???
}

/cc @jczuchnowski who was thinking about these issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions