FP::TransparentLazy - lazy evaluation with transparent evaluation
use FP::TransparentLazy; my $a = lazy { 1 / 0 }; like((eval { # $a's evaluation is forced here print $a } || $@), qr/division by zero/); # etc., see SYNOPSIS in FP::Lazy but remove the `force` and `FORCE` # calls
This implements a variant of FP::Lazy that forces promises automatically upon access (and writes their result back to the place they are forced from, like FP::Lazy's `FORCE` does). Otherwise the two are fully interchangeable.
NOTE: this is EXPERIMENTAL. Also, should this be merged with Data::Thunk ?
The drawback of transparency might be more confusion, as it's not directly visible anymore (neither in the debugger nor the source code) what's lazy. Also, transparent forcing will be a bit more expensive CPU wise. Please give feedback about your experiences!
FP::Lazy
This is alpha software! Read the status section in the package README or on the website.
To install FunctionalPerl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FunctionalPerl
CPAN shell
perl -MCPAN -e shell install FunctionalPerl
For more information on module installation, please visit the detailed CPAN module installation guide.