Skip to content

recursive coerce #57

@valenterry

Description

@valenterry

I often wrap newtypes in newtypes and then I want to access the basetype. Example:

@newtype case class Secret(value: String)
@newtype case class Password(value: Secret)
@newtype case class AdminPassword(value: Password)

val adminPassword: AdminPassword = ???

// Access the basetype
println(adminPassword.value.value.value)

Something like adminPassword.coerce[String] would be nice, or maybe even adminPassword.underlying. As Coercible is a typeclass, I think with the correct derivation it should be possible to get something like it.

Opinions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions