Minor breaking changes -- LiftRules.getResourceAsStream and LiftRules.finder

34 views
Skip to first unread message

David Pollak

unread,
Dec 31, 2009, 3:48:34 PM12/31/09
to liftweb
Folks,

I've changed LiftRules.getResourceAsStream and LiftRules.finder to return Box[Applier[InputStream]] rather than Box[InputStream].

Applier has a single method, apply[T] which takes an InputStream => T and insures the InputStream is closed.

This change is unlikely to impact much code out there, but does make sure that InputStreams are closed.

If any of the folks out there that name things better than I do (at least I didn't call it Apply_A_Tron), please feel free to suggest name changes, variance changes, etc.

Thanks,

David

--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Naftoli Gugenheim

unread,
Dec 31, 2009, 3:56:42 PM12/31/09
to lif...@googlegroups.com
StreamManager? (as in automatic resource management)
Stream
Don't like the above that much but nothing better comes to mind. Anyone?
Also should it be apply, or doWith for consistency with AnyVars?


-------------------------------------
David Pollak<feeder.of...@gmail.com> wrote:

Folks,

Thanks,

David

--

You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.


greekscala

unread,
Jan 2, 2010, 7:58:16 AM1/2/10
to Lift
Hello,

I think applier is to general. applier for...? As Naftoli said, a name
like StreamManager
or StreamHandler is clearer for a newbie like me.

best regards

On 31 Dez. 2009, 21:48, David Pollak <feeder.of.the.be...@gmail.com>
wrote:


> Folks,
>
> I've changed LiftRules.getResourceAsStream and LiftRules.finder to return
> Box[Applier[InputStream]] rather than Box[InputStream].
>
> Applier has a single method, apply[T] which takes an InputStream => T and
> insures the InputStream is closed.
>
> This change is unlikely to impact much code out there, but does make sure
> that InputStreams are closed.
>
> If any of the folks out there that name things better than I do (at least I
> didn't call it Apply_A_Tron), please feel free to suggest name changes,
> variance changes, etc.
>
> Thanks,
>
> David
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net

> Beginning Scalahttp://www.apress.com/book/view/1430219890

Timothy Perrett

unread,
Jan 2, 2010, 8:07:02 AM1/2/10
to Lift
Yeah - I too dont like the name "Applier".

StreamManager[T] sounds cool to me.

Cheers, Tim

Heiko Seeberger

unread,
Jan 2, 2010, 8:26:08 AM1/2/10
to lif...@googlegroups.com
StreamManager[T] sounds cool to me.

+1

Heiko

My job: weiglewilczek.com
My blog: heikoseeberger.name
Follow me: twitter.com/hseeberger
OSGi on Scala: scalamodules.org
Lift, the simply functional web framework: liftweb.net

Naftoli Gugenheim

unread,
Jan 3, 2010, 12:34:39 AM1/3/10
to liftweb
I actually like StreamHandler better than StreamManager. StreamManager sounds like a something more complex.


David Pollak

unread,
Jan 4, 2010, 11:51:05 AM1/4/10
to lif...@googlegroups.com
On Sat, Jan 2, 2010 at 9:34 PM, Naftoli Gugenheim <nafto...@gmail.com> wrote:
I actually like StreamHandler better than StreamManager. StreamManager sounds like a something more complex.

The implementation:

trait Applier[T] {
  def apply[R](f: T => R): R
}


Has nothing to do with Streams.  It's a close cousin of a Function.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890

Naftoli Gugenheim

unread,
Jan 4, 2010, 1:07:33 PM1/4/10
to lif...@googlegroups.com
Ah, I misunderstood. Where is it defined?

-------------------------------------
David Pollak<feeder.of...@gmail.com> wrote:


The implementation:

>> liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>


>> .
>> For more options, visit this group at
>> http://groups.google.com/group/liftweb?hl=en.
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to

> liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>


> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>

--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

David Pollak

unread,
Jan 4, 2010, 1:09:20 PM1/4/10
to lif...@googlegroups.com
On Mon, Jan 4, 2010 at 10:07 AM, Naftoli Gugenheim <nafto...@gmail.com> wrote:
Ah, I misunderstood. Where is it defined?

Helpers.scala
 

Naftoli Gugenheim

unread,
Jan 4, 2010, 1:43:48 PM1/4/10
to lif...@googlegroups.com
Maybe my repo is out of sync? Is it on master? When was it committed?
git grep Applier is not turning it up. Is that command incorrect?
Thanks.

Helpers.scala

> <liftweb%2Bunsu...@googlegroups.com<liftweb%252Buns...@googlegroups.com>


> >
> >> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/liftweb?hl=en.
> >>
> >>
> >>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>

> <liftweb%2Bunsu...@googlegroups.com<liftweb%252Buns...@googlegroups.com>

Ross Mellgren

unread,
Jan 4, 2010, 1:45:41 PM1/4/10
to lif...@googlegroups.com
You're probably out of date. Here is the commit that introduced it:

http://github.com/dpp/liftweb/commit/5073a224cca39ab94ff3c3f7f4a8d093869e8f52

-Ross

Naftoli Gugenheim

unread,
Jan 4, 2010, 1:59:33 PM1/4/10
to lif...@googlegroups.com, dri...@gmail.com
I don't have access to a browser right now. Do you mind telling me the date of that commit? Thanks.

-------------------------------------
Ross Mellgren<dri...@gmail.com> wrote:

http://github.com/dpp/liftweb/commit/5073a224cca39ab94ff3c3f7f4a8d093869e8f52

-Ross

--

To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.

Ross Mellgren

unread,
Jan 4, 2010, 2:01:41 PM1/4/10
to Naftoli Gugenheim, lif...@googlegroups.com
commit 5073a224cca39ab94ff3c3f7f4a8d093869e8f52
Author: David Pollak <nom nom nom>
Date: Thu Dec 31 12:21:24 2009 -0800

Force closing of streams. More graceful restart of ActorPing

-Ross

Kris Nuttycombe

unread,
Jan 4, 2010, 3:51:42 PM1/4/10
to lif...@googlegroups.com
On Mon, Jan 4, 2010 at 9:51 AM, David Pollak
<feeder.of...@gmail.com> wrote:
>
>
> On Sat, Jan 2, 2010 at 9:34 PM, Naftoli Gugenheim <nafto...@gmail.com>
> wrote:
>>
>> I actually like StreamHandler better than StreamManager. StreamManager
>> sounds like a something more complex.
>
> The implementation:
>
> trait Applier[T] {
>   def apply[R](f: T => R): R
> }
>
>
> Has nothing to do with Streams.  It's a close cousin of a Function.


I believe that this is actually the type signature of the Thrush
combinator - it's a pretty generally useful type. I have the following
in my codebase:

implicit def any2Thrush[T](t: T): Thrush[T] = new Thrush[T](t)

class Thrush[T](t: T) {
def ->*[U](f: T => U): U = f(t)

Alex Boisvert

unread,
Jan 4, 2010, 4:03:01 PM1/4/10
to lif...@googlegroups.com
Instead of:

LiftRules.getResourceAsStream(name: String): Box[InputStream]

I'd suggest:

LiftRules.doWithResource[T](name: String)(f: InputStream => T): Box[T].

And if you need laziness, you could use one of the usual suspects: "lazy val", unapplied function, FatLazy, etc.

alex


--

David Pollak

unread,
Jan 5, 2010, 12:18:37 PM1/5/10
to lif...@googlegroups.com
On Mon, Jan 4, 2010 at 1:03 PM, Alex Boisvert <alex.b...@gmail.com> wrote:
Instead of:

LiftRules.getResourceAsStream(name: String): Box[InputStream]

I'd suggest:

LiftRules.doWithResource[T](name: String)(f: InputStream => T): Box[T].


Sounds good.  Please open a ticket and make it happen. ;-)
 

Alex Boisvert

unread,
Jan 9, 2010, 9:31:15 AM1/9/10
to lif...@googlegroups.com
This change has now been pushed to master.

LiftRules.finder() has been removed since it offered (unsafe) duplicate functionality.

cheers,
alex

David Pollak

unread,
Jan 9, 2010, 1:00:31 PM1/9/10
to lif...@googlegroups.com
On Sat, Jan 9, 2010 at 6:31 AM, Alex Boisvert <alex.b...@gmail.com> wrote:
This change has now been pushed to master.

LiftRules.finder() has been removed since it offered (unsafe) duplicate functionality.

Excellent!  Thanks!
 
Reply all
Reply to author
Forward
0 new messages