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

Add support for operators that return values of the type of the type class parameter #45

Open
nrinaudo opened this issue Nov 30, 2015 · 0 comments

Comments

@nrinaudo
Copy link

For a given type class F[T], Simulacrum can currently generate operators for all methods of the shape def f(t:T): X. It would be nice if it also supported operator generation for methods of the shape def f(): T.

As a concrete example, consider the following type class:

trait Decoder[T] {
  def decode(s: String): T
}

It would be convenient for String to be enriched with a decode operator, enabling code such as "123".decode[Int] (provided a Decoder[Int] is in scope).

A possible issue would be that, in order to support subtyping of type classes, Simulacrum would need to generate 2 classes for each enhanced type - Decoder.StringOps and Decoder.AllStringOps in our example, for instance.

See this gitter thread for additional context.

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

No branches or pull requests

1 participant