Latest Lift 2.5 Snapshot Doesn't allow passing in NodeSeqs?

168 views
Skip to first unread message

Matt Farmer

unread,
Aug 30, 2012, 3:01:04 PM8/30/12
to lif...@googlegroups.com
Hey everybody,

I know that we're nearing a code freeze for the 2.5-M1 release, so I wanted to make sure I brought this to everyone's attention. I updated the copy of the Lift snapshot that I'm running today to find that there were some compile bugs when attempting to pass NodeSeqs directly into CSS selector functions. So, for example, a line like this:

("script [src]" #> jQueryUrl)(xhtml)

Yields a type mismatch error:

[error]  found   : scala.xml.NodeSeq
[error]  required: net.liftweb.util.ComputeTransformRules[String]

Of course, String is the type of the jQueryUrl variable. However, when I roll back to commit aae6082bcea0420b9d2cbc87a7cc85e4b74a6c30, where Antonio's AJAX stuff was merged, everything compiles fine. So it was introduced in the recent batch of commits. Is this a known side effect of an intentional change or no? I'm also seeing other errors that seem to imply that something may be wrong. Among them...

[error]  found   : Int with scala.xml.NodeSeq => scala.xml.NodeSeq
[error]  required: scala.xml.NodeSeq

I don't have time right this second to work up an example project, but if whoever reads this feels like I should I am certainly able to. All the same, I wanted to make sure this at least got mentioned regardless of my insane schedule so that it doesn't catch anybody by surprise when the M1 rolls.

Cheers,

Matt Farmer

Diego Medina

unread,
Aug 30, 2012, 3:04:33 PM8/30/12
to lif...@googlegroups.com
On Thu, Aug 30, 2012 at 3:01 PM, Matt Farmer <matt....@openstudy.com> wrote:
> Hey everybody,
>
> I know that we're nearing a code freeze for the 2.5-M1 release, so I wanted
> to make sure I brought this to everyone's attention. I updated the copy of
> the Lift snapshot that I'm running today to find that there were some
> compile bugs when attempting to pass NodeSeqs directly into CSS selector
> functions. So, for example, a line like this:
>
> ("script [src]" #> jQueryUrl)(xhtml)


This is due to the new type class based css transform, if memory
serves well, you can get around this by using:

("script [src]" #> jQueryUrl).apply(xhtml)

I wish I could find the email where I saw that, I'll keep looking just in case.

Thanks

Diego


>
> Yields a type mismatch error:
>
> [error] found : scala.xml.NodeSeq
> [error] required: net.liftweb.util.ComputeTransformRules[String]
>
> Of course, String is the type of the jQueryUrl variable. However, when I
> roll back to commit aae6082bcea0420b9d2cbc87a7cc85e4b74a6c30, where
> Antonio's AJAX stuff was merged, everything compiles fine. So it was
> introduced in the recent batch of commits. Is this a known side effect of an
> intentional change or no? I'm also seeing other errors that seem to imply
> that something may be wrong. Among them...
>
> [error] found : Int with scala.xml.NodeSeq => scala.xml.NodeSeq
> [error] required: scala.xml.NodeSeq
>
> I don't have time right this second to work up an example project, but if
> whoever reads this feels like I should I am certainly able to. All the same,
> I wanted to make sure this at least got mentioned regardless of my insane
> schedule so that it doesn't catch anybody by surprise when the M1 rolls.
>
> Cheers,
>
> Matt Farmer
>
> --
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
>
>



--
Diego Medina
Lift/Scala Developer
di...@fmpwizard.com
http://www.fmpwizard.com

Andreas Joseph Krogh

unread,
Aug 30, 2012, 3:05:08 PM8/30/12
to lif...@googlegroups.com
This is a consequence of using type-classes for CSS Selector Transforms, so you'll have to re-write those to:
(".stuff" #> jQueryUrl).apply(xhtml)

Or scala thinks (xhtml) is an explicit parameter for the implicit used by the type-class
-- 
Andreas Joseph Krogh<and...@officenet.no>  - mob: +47 909 56 963
Senior Software Developer / CEO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc

Diego Medina

unread,
Aug 30, 2012, 3:14:25 PM8/30/12
to lif...@googlegroups.com
Yes ( I think):

scala> import net.liftweb.util.Helpers._
import net.liftweb.util.Helpers._

scala> ("script [src]" #> "jQueryUrl")(<script src="here">data</script>)
<console>:11: error: type mismatch;
found : scala.xml.Elem
required: net.liftweb.util.ComputeTransformRules[java.lang.String]
("script [src]" #> "jQueryUrl")(<script src="here">data</script>)
^

scala> import xml.NodeSeq
import xml.NodeSeq

scala> ("script [src]" #> "jQueryUrl")(<script src="here">data</script>)
<console>:12: error: type mismatch;
found : scala.xml.Elem
required: net.liftweb.util.ComputeTransformRules[java.lang.String]
("script [src]" #> "jQueryUrl")(<script src="here">data</script>)
^

scala> ("script [src]" #> "jQueryUrl").apply(<script src="here">data</script>)
res2: scala.xml.NodeSeq = NodeSeq(<script src="jQueryUrl">data</script>)

scala>

Regards,

Naftoli Gugenheim

unread,
Aug 31, 2012, 4:36:16 PM8/31/12
to lif...@googlegroups.com
Yes, because the #> method needs an implicit parameter, so if you write  "xx".#>(yy)(zz), scala thinks zz is for the implicit parameter.
As Diego said, one workaround is "xx" #> yy apply zz. Another is:
val a = "xx" #> yy
a(zz)


On Thu, Aug 30, 2012 at 3:04 PM, Diego Medina <di...@fmpwizard.com> wrote:
Reply all
Reply to author
Forward
0 new messages