poi.scala icon indicating copy to clipboard operation
poi.scala copied to clipboard

scalaz.Free$Gosub cannot be cast to scala.Tuple2 error thrown running examples

Open shyamsalimkumar opened this issue 8 years ago • 0 comments

Scala version: 2.11.8 Dependencies added

val dependencies = Seq(
  "com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2",
  "org.scalaz" %% "scalaz-core" % "7.3.0-M4",
...
  "org.apache.poi" % "poi-ooxml" % "3.14",
  "info.folone" %% "poi-scala" % "0.14")

Got the following error

scala> sheetOne.safeToFile(path).fold(ex => throw ex, identity).unsafePerformIO
java.lang.ClassCastException: scalaz.Free$Gosub cannot be cast to scala.Tuple2
  at scalaz.effect.IO$class.unsafePerformIO(IO.scala:22)
  at scalaz.effect.IOFunctions$$anon$6.unsafePerformIO(IO.scala:227)
  ... 42 elided

while trying to execute the sample code displayed

scala> import info.folone.scala.poi._
import info.folone.scala.poi._

scala> import scalaz._
import scalaz._

scala> import syntax.monoid._
import syntax.monoid._

scala> import syntax.foldable._
import syntax.foldable._

scala> import std.list._
import std.list._

scala> val sheetOne = Workbook {
   Set(Sheet("name") {
     Set(Row(1) {
       Set(NumericCell(1, 13.0/5), FormulaCell(2, "ABS(A1)"))
     },
     Row(2) {
       Set(StringCell(1, "data"), StringCell(2, "data2"))
     })
   },
   Sheet("name2") {
     Set(Row(2) {
       Set(BooleanCell(1, true), NumericCell(2, 2.4))
     })
   })
 }
sheetOne: info.folone.scala.poi.Workbook = Workbook(Set(Sheet ("name")(Set(Row (1)(Set(NumericCell(1, 2.6), FormulaCell(2, "=ABS(A1)"))), Row (2)(Set(StringCell(1, "data"), StringCell(2, "data2"))))), Sheet ("name2")(Set(Row (2)(Set(BooleanCell(1, true), NumericCell(2, 2.4)))))))

scala> val path = "/tmp/workbook.xls"
path: String = /tmp/workbook.xls

scala> sheetOne.safeToFile(path).fold(ex ⇒ throw ex, identity).unsafePerformIO

shyamsalimkumar avatar Nov 15 '16 19:11 shyamsalimkumar