[scalaz-stream] Ambiguous Implicits Error When Using RunLog

36 views
Skip to first unread message

typele...@gmail.com

unread,
Jun 17, 2015, 5:02:10 PM6/17/15
to sca...@googlegroups.com
Hello,

I posted this on StackExchange but I didn't get any responses there. I'm
hoping an expert on this forum can clear this up for me. When invoking
 runLog on this Process it throws an ambiguous implicits error which I 
am not sure how to resolve:


import scalaz._
import Scalaz._
import scalaz.stream._
import java.time._

scala> Process.iterate(LocalDate.of(2017,5,15))(x => x.minusMonths(6)).takeWhile(_.equals(LocalDate.of(2007,5,15))).runLog
<console>:20: error: ambiguous implicit values:
 both value vectorInstance in trait VectorInstances of type => scalaz.Traverse[scalaz.Scalaz.generic.IxSq] with scalaz.MonadPlus[scalaz.Scalaz.generic.IxSq] with scalaz.Each[scalaz.Scalaz.generic.IxSq] with scalaz.Index[scalaz.Scalaz.generic.IxSq] with scalaz.Length[scalaz.Scalaz.generic.IxSq] with scalaz.Zip[scalaz.Scalaz.generic.IxSq] with scalaz.Unzip[scalaz.Scalaz.generic.IxSq] with scalaz.IsEmpty[scalaz.Scalaz.generic.IxSq] with scalaz.Align[scalaz.Scalaz.generic.IxSq]{def toIndexedSeq[A](fa: scalaz.Scalaz.generic.IxSq[A]): scalaz.Scalaz.generic.IxSq[A]}
 and value callableMonad in trait CallableInstances of type => scalaz.Monad[java.util.concurrent.Callable]
 match expected type scalaz.Monad[F2]
              Process.iterate(LocalDate.of(2017,5,15))(x => x.minusMonths(6)).takeWhile(_ == LocalDate.of(2007,5,15)).runLog


My Build.sbt file is :

scalaVersion := "2.11.6"

val scalazVersion = "7.1.2"

libraryDependencies ++= Seq(
  "org.scalaz" %% "scalaz-core" % scalazVersion,
  "org.scalaz.stream" %% "scalaz-stream" % "0.7.1a"
)

initialCommands in console := "import scalaz._, Scalaz._, scalaz.stream._, java.time._"

scalacOptions in ThisBuild ++= Seq("-feature", "-unchecked", "-deprecation")

resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases"

Regards,
Iftikhar

Robert Norris

unread,
Jun 17, 2015, 5:44:28 PM6/17/15
to sca...@googlegroups.com

Hi Iftikhar, the error message is misleading. The problem is that your effect type is Nothing ... if you add toSource to lift it into Task then it works:

scala> val p = Process.iterate(LocalDate.of(2007,5,15))(x => x.minusMonths(6)).takeWhile(_.equals(LocalDate.of(2007,5,15)))
p: scalaz.stream.Process[Nothing,java.time.LocalDate] = Append(Halt(End),Vector(<function1>))

scala> p.toSource
res3: scalaz.stream.Process[scalaz.concurrent.Task,java.time.LocalDate] = Append(Halt(End),Vector(<function1>))

scala> p.toSource.runLog.run
res4: IndexedSeq[java.time.LocalDate] = Vector(2007-05-15)

Daniel Spiewak has a good intro to these ideas at 


Good luck,

- rob
-- 
You received this message because you are subscribed to the Google Groups "scalaz" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaz+un...@googlegroups.com.
To post to this group, send email to sca...@googlegroups.com.
Visit this group at http://groups.google.com/group/scalaz.
For more options, visit https://groups.google.com/d/optout.

typele...@gmail.com

unread,
Jun 18, 2015, 7:37:41 PM6/18/15
to sca...@googlegroups.com
Thanks Rob for the reply and link. Daniel's mini-tutorial is awesome; it's sorted out a lot of confusion I had regarding scalaz-stream.
Reply all
Reply to author
Forward
0 new messages