Skip to content

Instantly share code, notes, and snippets.

@pelotom
Created April 27, 2013 00:21
Show Gist options
  • Save pelotom/5471331 to your computer and use it in GitHub Desktop.
Save pelotom/5471331 to your computer and use it in GitHub Desktop.
Why doesn't traverseU work with State? Why must traverseS exist as a special case?
scala> import scalaz._, Scalaz._, Unapply._
import scalaz._
import Scalaz._
import Unapply._
scala> List(1, 2, 3).traverseU((i: Int) => i.pure[({type f[a] = State[Int, a]})#f])
<console>:17: error: Unable to unapply type `scalaz.IndexedStateT[[+X]X,Int,Int,Int]` into a type constructor of kind `M[_]` that is classified by the type class `scalaz.Applicative`
1) Check that the type class is defined by compiling `implicitly[scalaz.Applicative[<type constructor>]]`.
2) Review the implicits in object Unapply, which only cover common type 'shapes'
(implicit not found: scalaz.Unapply[scalaz.Applicative, scalaz.IndexedStateT[[+X]X,Int,Int,Int]])
List(1, 2, 3).traverseU((i: Int) => i.pure[({type f[a] = State[Int, a]})#f])
^
scala> List(1, 2, 3).traverseS((i: Int) => i.pure[({type f[a] = State[Int, a]})#f])
res8: scalaz.State[Int,List[Int]] = scalaz.package$State$$anon$3@414e3789
@pelotom
Copy link
Author

pelotom commented Apr 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment