I currently have
def list(node: NodeSeq): NodeSeq = {
val all = Thing.findAll.flatMap({
thing => bind("thing", chooseTemplate("thing", "entry", node),
"desc" -> Text(thing.desc.is),
"creator" -> thing.creatorName.getOrElse("UNKNOWN"),
"delete" -> SHtml.link("/test", () => delete(thing), Text("delete"))
)
})
all match {
case Nil => <span>No things</span>
case _ => <ol>{bind("thing", node, "entry" -> all)}</ol>
}
}
and I tried to refactor it to
def listItemHelper(node: NodeSeq): List[NodeSeq] = {
Thing.findAll.flatMap({
thing => bind("thing", chooseTemplate("thing", "entry", node),
"desc" -> Text(thing.desc.is),
"creator" -> thing.creatorName.getOrElse("UNKNOWN"),
"delete" -> SHtml.link("/test", () => delete(thing), Text("delete"))
)
})
}
def list(node: NodeSeq): NodeSeq = {
val all = listItemHelper(node)
all match {
case Nil => <span>No things</span>
case all: List[NodeSeq] => <ol>{bind("thing", node, "entry" -> all)}</ol>
case _ => <span>wtf</span>
}
}
but I get the following. I've traced all the return types and I don't see how my refactoring is any different than what would be happening internally. I even tried adding more match cases (as you can see in the refactored code) to make sure I was selecting the right type.
/Users/trenton/projects/sc2/supperclub/src/main/scala/com/runbam/snippet/Whyme.scala:37: error: overloaded method value -> with alternatives [T <: net.liftweb.util.Bindable](T with net.liftweb.util.Bindable)net.liftweb.util.Helpers.TheBindableBindParam[T] <and> (Boolean)net.liftweb.util.Helpers.BooleanBindParam <and> (Long)net.liftweb.util.Helpers.LongBindParam <and> (Int)net.liftweb.util.Helpers.IntBindParam <and> (Symbol)net.liftweb.util.Helpers.SymbolBindParam <and> (Option[scala.xml.NodeSeq])net.liftweb.util.Helpers.OptionBindParam <and> (net.liftweb.util.Box[scala.xml.NodeSeq])net.liftweb.util.Helpers.BoxBindParam <and> ((scala.xml.NodeSeq) => scala.xml.NodeSeq)net.liftweb.util.Helpers.FuncBindParam <and> (Seq[scala.xml.Node])net.liftweb.util.Helpers.TheBindParam <and> (scala.xml.Node)net.liftweb.util.Helpers.TheBindParam <and> (scala.xml.Text)net.liftweb.util.Helpers.TheBindParam <and> (scala.xml.NodeSeq)net.liftweb.util.Helpers.TheBindParam <and> (String)net.liftweb.util.Helpers.TheStrBindParam cannot be applied to (List[scala.xml.NodeSeq])
case all: List[NodeSeq] => <ol>{bind("thing", node, "entry" -> all)}</ol>
^