Re: [Lift] Safe handling of long params

2010-01-05 Thread Jim Wise
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

Re: [Lift] Safe handling of long params

2010-01-05 Thread Naftoli Gugenheim
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

Re: [Lift] Safe handling of long params

2010-01-05 Thread Ross Mellgren
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

Re: [Lift] Safe handling of long params

2010-01-05 Thread Jim Wise
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:

[Lift] Safe handling of long params

2010-01-04 Thread Jim Wise
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

Re: [Lift] Safe handling of long params

2010-01-04 Thread Ross Mellgren
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

Re: [Lift] Safe handling of long params

2010-01-04 Thread Timothy Perrett
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

Re: [Lift] Safe handling of long params

2010-01-04 Thread Ross Mellgren
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,

Re: [Lift] Safe handling of long params

2010-01-04 Thread Timothy Perrett
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:

Re: [Lift] Safe handling of long params

2010-01-04 Thread Jim Wise
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,