EindbaasExpress / handsonscala-issuemigrator

Part of the HandsOnScala Course
0 stars 0 forks source link

error: uPickle does not know how to write [scala.collection.immutable.Seq[Int]] #39

Open EindbaasExpress opened 2 years ago

EindbaasExpress commented 2 years ago

I notice the documentation says uPickle can write immutable Seqs, but I find the opposite to be true - it only seems to be able to write the mutable (Predef) version.

As shown below, it can write scala.collection.immutable.List so I imagine the fix should be simple.

Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_05).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import upickle._
import upickle._

scala> write(Seq(1, 2, 3))
res0: String = [1,2,3]

scala> write(List(1,2,3))
res1: String = [1,2,3]

scala> import scala.collection.immutable.Seq
import scala.collection.immutable.Seq

scala> write(Seq(1, 2, 3))
<console>:12: error: uPickle does not know how to write [scala.collection.immutable.Seq[Int]]s; define an implicit Writer[scala.collection.immutable.Seq[Int]] to teach it how
              write(Seq(1, 2, 3))
                   ^

ID: 21 Original Author: longshorej