I can answer b) -- S.param(image).flatMap(asLong)
asLong comes from BasicTypesHelpers.
-Ross
One more quick question about this, more of a Scala question really:
I've noticed both here and in the examples that there is a tendency to
use flatMap() instead of map(). I understand the
map would result in a Box[Box[Long]]
-
Jim Wisejw...@draga.com wrote:
I can answer b) -- S.param(image).flatMap(asLong)
asLong comes from BasicTypesHelpers.
-Ross
One more quick question about this, more of a Scala question really:
I've noticed both
They aren't. Here are the type signatures for map and flatMap, from
Box (the type on Seq is the same, but not specialized to the Box
return type):
def map[B](f: A = B): Box[B]
def flatMap[B](f: A = Box[B]): Box[B]
The key is the return type of f -- in map, it always returns what
goes in
Ross Mellgren dri...@gmail.com writes:
In your case, asLong is:
def asLong(s: String): Box[Long]
So if you used map:
Full(1234).map(asLong) // result is Full(Full(1234)), because the
result of asLong went into the Full that map creates
Conversely, flatMap removes a level of structure:
So, in my endless retweaking of this code, getting better (and learning
more lift) on each pass, I've got a rewrite rule like this
case RewriteRequest(ParsePath(image :: image :: Nil, _, _, _), _, _)
=
RewriteResponse(viewImage :: Nil, Map(image - image))
which is
I can answer b) -- S.param(image).flatMap(asLong)
asLong comes from BasicTypesHelpers.
-Ross
On Jan 4, 2010, at 4:42 PM, Jim Wise wrote:
So, in my endless retweaking of this code, getting better (and
learning
more lift) on each pass, I've got a rewrite rule like this
case
Shouldnt that be:
S.param(image).flatMap(_.asLong)
Cheers, Tim
On 4 Jan 2010, at 21:45, Ross Mellgren wrote:
S.param(image).flatMap(asLong)
--
You received this message because you are subscribed to the Google Groups
Lift group.
To post to this group, send email to
Nope, it's not a implicit extension of String or anything, it's just a
plain method def asLong(s: String): Box[Long] in BasicTypesHelpers
-Ross
On Jan 4, 2010, at 5:08 PM, Timothy Perrett wrote:
Shouldnt that be:
S.param(image).flatMap(_.asLong)
Cheers, Tim
On 4 Jan 2010, at 21:45,
Ah right yeah - I thought it was implicit :)
On 4 Jan 2010, at 22:09, Ross Mellgren wrote:
Nope, it's not a implicit extension of String or anything, it's just a
plain method def asLong(s: String): Box[Long] in BasicTypesHelpers
-Ross
On Jan 4, 2010, at 5:08 PM, Timothy Perrett wrote:
Aha!
Thanks,
Sent from my iPhone
On Jan 4, 2010, at 16:45, Ross Mellgren dri...@gmail.com wrote:
I can answer b) -- S.param(image).flatMap(asLong)
asLong comes from BasicTypesHelpers.
-Ross
On Jan 4, 2010, at 4:42 PM, Jim Wise wrote:
So, in my endless retweaking of this code,
10 matches
Mail list logo