question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abstract given seems useless

See original GitHub issue

Abstract given were introduced in https://github.com/lampepfl/dotty/pull/10538 . But these seem useless, as one can always define an abstract field and use a given alias:

def ord: Ord[T]
given Ord[T] = ord

Would it be possible to drop this feature, as it forces us to add an uncanny with to givens even when no structural part is needed https://github.com/lampepfl/dotty-feature-requests/issues/156

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (21 by maintainers)

github_iconTop GitHub Comments

2reactions
julienrfcommented, Dec 31, 2020

I find abstract givens useful, indeed. Abstract definitions are a common means of abstraction (abstract methods and abstract type members). We can observe that in Scala 2 abstract implicit definitions are used (e.g. in cats, endpoints4s, akka, and maybe at other places that I’m not aware of).

From a more fundamental perspective, there is a correspondence between parameters and abstract members. Both are means of abstractions, and you can refactor from one form to the other:

trait WithMembers {
  type A
  val foo: A
}
class WithParameters[A](val foo: A)

However, if we remove abstract givens, this will make it impossible to refactor this:

class Foo[A](using SemiGroup[A])

into that:

trait Foo {
  type A
  given SemiGroup[A]
}

You mentioned a workaround, which in my opinion is not only verbose, but very low-level and “mechanism-oriented” (as opposed to “intent-oriented”). I like how abstract givens removed half of the lines of this part of the compiler.

1reaction
julienrfcommented, Dec 31, 2020

That being said, if abstract givens are the only reason why we need the with connector, I agree that it’s an important drawback. Is it true that we could remove with if we didn’t support abstract givens?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are examples of useful and useless abstractions? - Quora
An abstract of a long article such as a PHD is beneficial to the reader to get the main points of the writer's...
Read more >
I believe that a lot of forms of abstract art are pointless ... - Reddit
I can't even try to give you an answer to the incredibly complex "what is art?" question you're kind of implicitly asking, because...
Read more >
Good VS. Worthless Abstract Art and What Sets It Apart
While good abstract art is more about the meaning, intent,expression and skill, worthless abstract art lacks it.
Read more >
Science Unshackled: How Obscure, Abstract, Seemingly ...
Buy Science Unshackled: How Obscure, Abstract, Seemingly Useless Scientific Research Turned Out to Be the Basis for Modern Life on Amazon.com ✓ FREE ......
Read more >
[no-useless-constructor] Skipping constructors with explicit ...
I routinely make use of inheritance and composition in my daily work, choosing whichever one is more appropriate given the circumstance. Modern ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found