Skip to content

Newtypes with phantom types #80

Description

@JakobBruenker

Hi, as far as I can tell, using newtypes together with phantom types isn't supported at the moment, i.e. essentially

case class Identifier[T](value: String)

but as a newtype instead of as a case class.

The straightforward thing to try would be

type Identifier[T] = Identifier.Type

object Identifier extends NewtypeWrapped[String]

However, this doesn't provide any type safety, since for any A and B, Identifier[A] and Identifier[B] are the same type.

I'm not sure what the right design here would be, but I think it would be useful to have - assuming I'm not missing an existing way to do it.

Cheers!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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