Skip to content

Instantly share code, notes, and snippets.

@supermanue
Created April 5, 2022 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermanue/0e2715095355ef9622ccf2ead511df1a to your computer and use it in GitHub Desktop.
Save supermanue/0e2715095355ef9622ccf2ead511df1a to your computer and use it in GitHub Desktop.
User in adapter layer
import zio.experiment.domain.model.AppError
import zio.experiment.domain.model.User.{ User => UserDomain }
case class User(id: Int, name: String)
object User {
implicit class UserConversions(user: User) {
def toDomainUser: Either[AppError, UserDomain] =
UserDomain.build(user.id, user.name)
}
def fromDomainUser(domainUser: UserDomain): User =
User(domainUser.id.value, domainUser.name.value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment