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.

Implement Show typeclass

See original GitHub issue

The goal is to automatically provide a better toString for case classes with field names.

Example :

case class Person(name: String, age: Int)
implicit personShow = ... // calling macro here
val p = Person("bob", 40)
Show.show(p) // returns  "Person(name = bob, age = 40)"
//or 
// import implicit class
p.show // returns  "Person(name = bob, age = 40)"

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
oraclewalidcommented, Oct 15, 2017

To use the macro from external project, I think user must add addCompilerPlugin("org.scalameta" % "paradise" % "3.0.0-M10" cross CrossVersion.full) to build.sbt, then external projet can call ShowMacro

0reactions
loicdescottecommented, Nov 2, 2017

Remaining tasks for a first version of Show (using show branch) :

  • make the macro usable from the tests (should work for any client of the lib too)
  • move the case classes outside the Show.scala file (move to the right test)
  • move show tests at the same level as other tests
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 6. Using Typeclasses - Real World Haskell
An instance type of this typeclass is any type that implements the ... It returns a String representing that data. ghci reports the...
Read more >
Show - Typelevel
Show. Show. Show is an alternative to the Java toString method. It is defined by a single function show : def show(a: A):...
Read more >
Haskell Show type class in a function - Stack Overflow
When I want to print the output of this function in ghci, Haskell seems to be confused as to which instance of Show...
Read more >
Introduction to Haskell Typeclasses - Serokell
A type has an instance of a typeclass if it implements the methods of that typeclass. We can define these instances by hand,...
Read more >
Text.Show - Hackage - Haskell.org
The shows functions return a function that prepends the output String to an existing String . This allows constant-time concatenation of results using...
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