I hate git on windows ... I use it for the book unfortunatelly. On Jan 9, 1:46 pm, "David Pollak" <[email protected]> wrote: > On Fri, Jan 9, 2009 at 2:59 AM, Marius <[email protected]> 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 > > <[email protected]<marc%[email protected]>> > > 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 > > > > [email protected]> 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] = { > > > > val es = html.elements.toList.filter(_ match { > > > > case Text(s) if (s.trim.length == 0) => > > > > false // remove whitespace text > > > > case _ => true > > > > }) > > > > es match { > > > > // it was just white space, return it > > > > case Nil => List(html) > > > > > // are all the nodes the same (prefix == > > > > lift)? > > > > // this allows the use of different snippets > > > > as the different templates... > > > > case x :: xs if (x.prefix == "lift" && > > > > xs.foldLeft(true)( (t, n) => (t && > > > > n.prefix == x.prefix) )) => es > > > > > // are all the nodes the same (prefix, label)? > > > > case x :: xs => { > > > > if (xs.foldLeft(true)( (t, n) => (t > > > > && n.prefix == x.prefix && n.label == x.label) )) > > > > es > > > > else List(html) // nope, return > > > > origional sequence... > > > > } > > > > } > > > > } > > > > > // duplicate a list until it is at least as long as *i* > > > > private def expand(xhtmls: List[NodeSeq], i: Int): > > > > List[NodeSeq] = > > > > if (i > 0) > > > > expand(xhtmls ::: xhtmls, i - xhtmls.length) > > > > else > > > > xhtmls > > > > > On 09/01/2009, at 5:08 AM, David Pollak wrote: > > > > >> On Thu, Jan 8, 2009 at 9:54 AM, Marius <[email protected]> > > > >> wrote: > > > > >> Ok, I just committed the updates. Now both BindHelpers.attr and > > > >> S.attr > > > >> implement AttrHelpers trait where we have a bunch of overloaded > > > >> apply, > > > > >> I would have liked to use Option[NodeSeq] for S.attr as well but this > > > >> would be a breaking change and breaking changes are frozen now. So > > > >> S.attr("someparam") still returns a Box[String]. However I added 2 > > > >> helper function ~ that would return Option[NodeSeq], so you can call > > > >> S.attr ~("someparam") and get back an Option[NodeSeq]. > > > > >> I know we could have used implicits to convert from Box[String] to > > > >> Option[NodeSeq] but I feel that this would be an abuse of implicits > > > >> as > > > >> the use of implicits IMHO should be motivated byt strong design > > > >> rationales and I think this is the case. > > > > >> Thoughts? > > > > >> Very cool! > > > > >> Br's, > > > >> Marius > > > > >> On Jan 7, 7:40 pm, Marius <[email protected]> wrote: > > > >> > I'll look into it. > > > > >> > On Jan 7, 7:38 pm, "David Pollak" <[email protected]> > > > >> > wrote: > > > > >> > > Marc, > > > > >> > > Good suggestion. Marius -- do you want to do this... maybe > > > >> even turn the > > > >> > > pattern into a trait that we can apply over and over? > > > > >> > > Thanks, > > > > >> > > David > > > > >> > > On Tue, Jan 6, 2009 at 9:57 PM, Marc Boschma > > > > ... > > > > read more » > > -- > Lift, the simply functional web frameworkhttp://liftweb.net > Collaborative Task Managementhttp://much4.us > Follow me:http://twitter.com/dpp > Git some:http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
