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 test suite to check when composition works or not #1083

Closed
wants to merge 3 commits into from

Conversation

julien-truffaut
Copy link
Member

CompositionGenericOpticsTest make me think we should still offer non-overloaded compose methods.

We could add andThenLens, andThenOptional, ... but recommend to use them only when facing type inference issue which should hopefully be rare.

@yilinwei
Copy link
Collaborator

This will break once inheritance is added right? (the subclass would be valid).

@julien-truffaut
Copy link
Member Author

@yilinwei What would break? I think we should postpone the decision on keeping non-overloaded method once we see the impact of inheritance + variance in Scala 2 and 3.

@yilinwei
Copy link
Collaborator

yilinwei commented Feb 21, 2021

Sorry, "breaks" is the wrong word. Let me be a bit more specific; if the return type of the composition is a sub-type the test still passes. I wonder if this form is better so it doesn't pass even if the sub-type is returned.

sealed trait Foo

trait Bar extends Foo
trait Baz extends Bar

object Bar {
  def apply(): Bar = ???
}

sealed trait ¬[A]

sealed trait NotLowPriority {
  given notambig[A]: ¬[A]  = ???
}

// Trick from shapeless
object ¬ extends NotLowPriority {
  given ambig1 [A](using a: A): ¬[A] = ???
  given ambig2 [A](using a: A): ¬[A] = ???
}


object Test {
  val optic = Bar()
  summon[optic.type <:< Bar]
  summon[¬[optic.type <:< Baz]]
}

@julien-truffaut
Copy link
Member Author

I added thoses tests directly to #1088

@julien-truffaut julien-truffaut deleted the compose-test branch February 22, 2021 15:33
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

Successfully merging this pull request may close these issues.

2 participants