Ok, cool to see the attr.apply code aligned with the trait. One simple question - is it safe to assume the Info/NodeSeq will never be null?
Marc On 10/01/2009, at 2:53 AM, Marius wrote: > > Ok I don't think it is a compiler bug. > > > Marc called it like: > > var singular = BindHelpers.attr("singular", {s: String => > {s.toLowerCase ...}, false} > > BUT > > the apply function is defined as > > def apply[T](key: String, f: Info => T, default: => T): T > > Note that function f takes an Info not a T as parameter and for attr > object Info = NodeSeq and not String. > > => compiler errors. > > So Marc your conversion function is provided here with a NodeSeq and > not a String so you can say: > > var singular = BindHelpers.attr[Boolean]("singular", {s: NodeSeq=> > {...}, false} > > > > Br's, > Marius > > On Jan 9, 2:59 pm, Marius <marius.dan...@gmail.com> wrote: >> I hate git on windows ... I use it for the book unfortunatelly. >> >> On Jan 9, 1:46 pm, "David Pollak" <feeder.of.the.be...@gmail.com> >> wrote: >> >> >> >>> On Fri, Jan 9, 2009 at 2:59 AM, Marius <marius.dan...@gmail.com> >>> wrote: >> >>>> That's weird. I see that someone modified the code that I committed >>>> moving most of the logic in the trait itself. I'm not sure if David >>>> did that cause in git I see "unknown" author. >> >>> Yep... it was me... from my Windows machine which has a less >>> than awesome support for Git. >> >>>> I do like those changes >>>> but I need to look later on today when I get home if they have >>>> something to do with your problem. Since apply functions are >>>> implemented in the trait itself it it seems that compiler does >>>> not see >>>> that Info abstract type is in fact a String in the attr object >>>> context. I wonder if it's a compiler bug :D >> >>> Hmmm... that'd suck. >> >> Oh yeah big time ... If indeed my assumption is correct (which I need >> to verify) I'll open a compiler bug and see if I can fix it. Worst >> case scenario rollback ... which I hope it won't be the case. >> >> >> >>>> In my tests I used similar examples as you did and worked with no >>>> problems. But I did not test with latest changed. >> >>>> Br's, >>>> Marius >> >>>> On Jan 9, 10:35 am, Marc Boschma <marc+lift...@boschma.cx<marc >>>> %2blift...@boschma.cx>> >>>> wrote: >>>>> Me either (rather embarrassing, had an old copy of >>>>> BindHelpers.scala >>>>> lying about :/ ) >> >>>>> However, a rather strange outcome... >> >>>>> [WARNING] /Users/marc/src/dad/todo/src/main/scala/com/ >>>>> liftworkshop/ >>>>> snippet/TD.scala:99: error: overloaded method value apply with >>>>> alternatives [T](String,String, >>>>> (net.liftweb.util.BindHelpers.attr.Info) => T,=> T)T <and> [T] >>>>> (String, >>>>> (net.liftweb.util.BindHelpers.attr.Info) => T,=> T)T <and> [T] >>>>> (String,String,(net.liftweb.util.BindHelpers.attr.Info) => >>>>> T)Option[T] >>>>> <and> [T](String,(net.liftweb.util.BindHelpers.attr.Info) => >>>>> T)Option[T] <and> (String,String,=> >>>>> net >>>>> .liftweb >>>>> .util.BindHelpers.attr.Info)net.liftweb.util.BindHelpers.attr.Info >>>>> <and> (String,=> >>>>> net >>>>> .liftweb >>>>> .util.BindHelpers.attr.Info)net.liftweb.util.BindHelpers.attr.Info >>>>> <and> >>>>> (String,String)Option[net.liftweb.util.BindHelpers.attr.Info] >>>>> <and> (String)Option[net.liftweb.util.BindHelpers.attr.Info] >>>>> cannot be >>>>> applied to (java.lang.String,(String) => Boolean,() => Boolean) >>>>> [WARNING] val singular: Boolean = >>>> BindHelpers.attr("singular", {s: >>>>> String => s.toLowerCase match { >> >>>>> What I find weird is that the references to >>>>> net.liftweb.util.BindHelpers.attr.Info (NodeSeq) >> >>>>> The offending line of code: >>>>> val singular: Boolean = >>>>> BindHelpers.attr("singular", >>>>> {s: String => s.toLowerCase match { >>>>> case "" => true >>>>> case "true" => true >>>>> case "t" => true >>>>> case "yes" => true >>>>> case "y" => true >>>>> case _ => false}}, () => false) >> >>>>> I have also tried >> >>>>> val singular: Boolean = >>>>> BindHelpers.attr("singular", >>>>> {s: String => s.toLowerCase match { >>>>> case "" => true >>>>> case "true" => true >>>>> case "t" => true >>>>> case "yes" => true >>>>> case "y" => true >>>>> case _ => false}}, false) >> >>>>> which gets >> >>>>> [WARNING] /Users/marc/src/dad/todo/src/main/scala/com/ >>>>> liftworkshop/ >>>>> snippet/TD.scala:99: error: type mismatch; >>>>> [WARNING] found : (String) => Boolean >>>>> [WARNING] required: (net.liftweb.util.BindHelpers.attr.Info) => >>>>> Boolean >>>>> [WARNING] val singular: Boolean = >>>> BindHelpers.attr("singular", {s: >>>>> String => s.toLowerCase match { >> >>>>> Once again the references to >>>>> (net.liftweb.util.BindHelpers.attr.Info) >>>>> => Boolean puzzle me... >> >>>>> It is like def apply[T](key: String, f: String => T, >>>>> default: => >>>>> T): T = attr(key).map(n => f(n.toString)).getOrElse(default) >>>>> doesn't match... >> >>>>> I tried to help the compiler with >> >>>>> val singular: Boolean = BindHelpers.attr[Boolean] >>>>> ("singular", {s: String => s.toLowerCase match { >>>>> case "" => true >>>>> case "true" => true >>>>> case "t" => true >>>>> case "yes" => true >>>>> case "y" => true >>>>> case _ => false}}, false) >> >>>>> and got >> >>>>> [WARNING] /Users/marc/src/dad/todo/src/main/scala/com/ >>>>> liftworkshop/ >>>>> snippet/TD.scala:99: error: overloaded method value apply with >>>>> alternatives (String,String, >>>>> (net.liftweb.util.BindHelpers.attr.Info) >>>>> => Boolean,=> Boolean)Boolean <and> (String, >>>>> (net.liftweb.util.BindHelpers.attr.Info) => Boolean,=> >>>>> Boolean)Boolean >>>>> <and> (String,String,(net.liftweb.util.BindHelpers.attr.Info) => >>>>> Boolean)Option[Boolean] <and> (String, >>>>> (net.liftweb.util.BindHelpers.attr.Info) => >>>>> Boolean)Option[Boolean] >>>>> cannot be applied to (java.lang.String,(String) => >>>>> Boolean,Boolean) >>>>> [WARNING] val singular: Boolean = >>>>> BindHelpers.attr[Boolean] >>>>> ("singular", {s: String => s.toLowerCase match { >> >>>>> Marc >> >>>>> On 09/01/2009, at 3:44 PM, David Pollak wrote: >> >>>>>> Marc, >> >>>>>> Sorry... dunno what to tell you. :-( >> >>>>>> David >> >>>>>> On Thu, Jan 8, 2009 at 3:47 PM, Marc Boschma <marc >>>>>> +lift...@boschma.cx> wrote: >>>>>> Very cool indeed, except... I now get: >> >>>>>> [WARNING] /Users/marc/src/todo/src/main/scala/com/liftworkshop/ >>>>>> snippet/TD.scala:99: error: value attr is not a member of object >>>>>> net.liftweb.util.BindHelpers >>>>>> [WARNING] val singular = BindHelpers.attr("singular", >>>>>> {s: >>>> String >>>>>> => s.toLowerCase match { >>>>>> [WARNING] ^ >>>>>> [WARNING] one error found >> >>>>>> I've cleaned out my .m2/repository and I always mvn -U clean >>>>>> install... No proxies in place. Usually works a charm. >>>>>> Frustrating as hell - I feel for those that actually make a >>>>>> living >>>>>> in the Java/Maven world (must make a mental note to not quibble >>>>>> so >>>>>> much on what those who do want to get paid :) >> >>>>>> Thoughts? >> >>>>>> Marc >> >>>>>> The full context of the code for those interested (David's todo >>>>>> app >>>>>> modified thus): >> >>>>>> (The top of the file has import net.liftweb._ and import >>>>>> util._) >> >>>>>> private def doList(reDraw: () => JsCmd)(html: NodeSeq): >>>>>> NodeSeq = { >>>>>> val singular = BindHelpers.attr("singular", {s: >>>>>> String => s.toLowerCase match { >>>>>> case "" => true >>>>>> case "true" => true >>>>>> case "t" => true >>>>>> case "yes" => true >>>>>> case "y" => true >>>>>> case _ => false}}, false) >>>>>> val l = toShow >> >>>>>> if (singular) >>>>>> l.flatMap(td => >>>>>> bind("todo", html, >>>>>> "check" -> >>>>>> ajaxCheckbox(td.done, >>>>>> v => >>>>>> {td.done(v).save; reDraw()}), >>>>>> "priority" -> >>>>>> ajaxSelect(ToDo.priorityList, Full(td.priority.toString), >>>>>> v => >>>>>> {td.priority(v.toInt).save; reDraw()}), >>>>>> "desc" -> desc(td, >>>>>> reDraw) >>>>>> )) >>>>>> else { >>>>>> val xhtmls = template(html, l.length) >> >>>>>> l.zip(xhtmls).flatMap(n => { val (td , >>>>>> xhtml) = n >>>>>> bind("todo", xhtml, >>>>>> "check" -> >>>>>> ajaxCheckbox(td.done, >>>>>> v => >>>>>> {td.done(v).save; reDraw()}), >>>>>> "priority" -> >>>>>> ajaxSelect(ToDo.priorityList, Full(td.priority.toString), >>>>>> v => >>>>>> {td.priority(v.toInt).save; reDraw()}), >>>>>> "desc" -> desc(td, >>>>>> reDraw) >>>>>> )}) >>>>>> } >>>>>> } >> >>>>>> private def template(html: NodeSeq, i: Int): >>>>>> List[NodeSeq] = >>>>>> expand(nodeSeq2List(html), i) >> >>>>>> private def nodeSeq2List(html: NodeSeq): List[NodeSeq] >>>>>> = { >> >> ... >> >> read more ยป > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---