IO-Lambda
view release on metacpan or search on metacpan
IO::Lambda - nonblocking IO in functional style
===============================================
This module is another attempt to fight the horrors of non-blocking I/O
programming. The simplicity of the sequential programming is only available
when one employs threads, coroutines, or coprocesses. Otherwise state machines
are to be built, often quite complex, which fact doesn't help the clarity of
the code. This module uses closures to achieve clarity of sequential
programming with single-process, single-thread, non-blocking I/O.
The approach implemented in this module is strongly based on closures.
It emulates the blocking style, so the collection of states is local, and can
be collected under single subroutine. For example, a dumbed down HTTP protocol
can be described like in the following scheme:
lib/IO/Lambda.pm view on Meta::CPAN
print mapcar( curry { http(shift) })-> wait(@hosts);
Note: C<io> and C<lambda> are synonyms - I personally prefer C<lambda> but some
find the word slightly inappropriate, hence C<io>. See however L<Higher-order
functions> to see why it is more C<lambda> than C<io>.
=head1 DESCRIPTION
This module is another attempt to fight the horrors of non-blocking I/O. It
tries to bring back the simplicity of the declarative programming style, that
is only available when one employs threads, coroutines, or co-processes.
Usually coding non-blocking I/O for single process, single thread programs
requires construction of state machines, often fairly complex, which fact
doesn't help the code clarity, and is the reason why the asynchronous I/O
programming is often considered 'messy'. Similar to the concept of monads in
functional languages, that enforce a certain order of execution over generally
orderless functions, C<IO::Lambda> allows writing I/O callbacks in a style that
resembles the good old sequential, declarative programming.
The manual begins with code examples, then proceeds to explaining basic
assumptions, then finally gets to the complex concepts, where the real fun
( run in 0.256 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )