-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
#607: Add missing Show instances #928
Conversation
…ow could be automatically derived for Tuples and case classes (see: https://github.com/milessabin/kittens), but ignored that possibility for now and just wrote an instance for Tuple2 to get this to work.
Current coverage is
|
Wonderful 👍. Thanks @matt-martin! See #631 for some discussion regarding the tuple instance generation that you brought up. |
👍 |
@@ -44,6 +44,8 @@ final case class WriterT[F[_], L, V](run: F[(L, V)]) { | |||
|
|||
def reset(implicit monoidL: Monoid[L], functorF: Functor[F]): WriterT[F, L, V] = | |||
mapWritten(_ => monoidL.empty) | |||
|
|||
def show(implicit F: Show[F[(L, V)]]): String = F.show(run) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm we should be able to delete this line right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adelbertc isn't the Show
instance delegating to this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the Show
instance is delegating to this method. I modeled this on the change that added a Show
instance for OptionT (see: https://github.com/typelevel/cats/pull/600/files; and in particular:
def show(implicit F: Show[F[Option[A]]]): String = F.show(value) |
Show
instance is updated accordingly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see now, I read it as Show[(L, V)]
- ignore me :-)
Randomly picked up this issue as I saw it was marked as "low hanging fruit" and I wanted to get more familiar with cats (and associated FP concepts).
One thing of note: I had to add a show instance for Tuple2 to make this work. I can't claim to be intimately familiar with Miles' Kittens project (see: https://github.com/milessabin/kittens), but it seemed like defining Show instances for Tuples and case classes would be particularly tedious and possibly something that Kittens/Shapeless could make a lot easier.
Without further ado, here is my initial attempt to address issue #607 and add a Show instance for WriterT.