When I code using Scalaz I often encounter problems, that there is no implicit in scope. I think there should be some default implicits somwhere in vast package scalaz, but either I don't know where or there are not any.
Suppose we want to show
any Any
in scalaz (I am using scalaz 7):
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> {def a: Any = "sratatata"; a}.show
<console>:14: error: could not find implicit value for parameter F0: scalaz.Show[Any]
{def a: Any = "sratatata"; a}.show
^
That is not working becouse there is no implicit Show[Any]
in scope.
Why Scalaz doesn't provide it? Is the good approach to use some global Show[A]
? I mean something like this:
scala> implicit def anyShow[A] = Show.showFromToString[A]
anyShow: [A]=> scalaz.Show[A]
scala> {def a: Any = "sratatata"; a}.show
res0: scalaz.Cord = sratatata
I think the same touches Equal
.
EDIT
I've tried as mentioned in answers to add import scalaz.syntax.ShowSyntax
but that doesn't resolve my problem. See:
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> import scalaz.syntax._
import scalaz.syntax._
scala> import scalaz.syntax.ToShowOps
import scalaz.syntax.ToShowOps
scala> import scalaz.syntax.ShowSyntax
import scalaz.syntax.ShowSyntax
scala> {def a: Any = "sratatata"; a}.show
<console>:19: error: could not find implicit value for parameter F0: scalaz.Show[Any]
{def a: Any = "sratatata"; a}.show
Compiler still wants some implicit scalaz.Show[Any]
.