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.

terse syntax for typeclass instances

See original GitHub issue

When creating a typeclass instance, one must do a lot of boileplate. The instance pattern is well known but still has boilerplate.

implicit val FooBar: Foo[Bar] = instance { b => ... }

It would be nice if this something like this were possible

implicit val _: Foo[Bar] = instance { b => ... }

Which is still full of boilerplate, so better suggestions would be good. The linked ticket talks about a lot of the more general cases and is worth reading.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
sjrdcommented, Jul 26, 2017

Actually it’s already possible to define an implicit that can’t be used explicitly:

I don’t think that’s intended. IMO that’s a bug. The compiler should not allow you to do that, since it is clearly violating the privateness of object Foo.

1reaction
fommilcommented, Jul 17, 2017

oh, it’s IMPLICIT 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing, and Understanding Type Classes - okmij.org
Describing three strategies of implementing type classes, aiming to clarify their behavior.
Read more >
Typeclasses — Coq 8.16.1 documentation
The syntax for class and instance declarations is the same as the record syntax of Coq: Class classname (p1 : t1) ⋯ (pn...
Read more >
dnvriend/type-classes-example: A small study project ... - GitHub
The syntax to create a type class instance for 'Format' is very terse, that is because we are using a macro that has...
Read more >
Haskell type class instance syntax - Stack Overflow
A Functor has to be parametrised by another type, that is it is a "type level function" that takes one "concrete type" and...
Read more >
A Tutorial on Typeclasses in Coq - Software Foundations
Classes and Instances. To automate converting various kinds of data into strings, we begin by defining a typeclass called Show. Class Show A...
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