FP::PureHash
use FP::PureHash; use FP::Show; use FP::Predicates; my $h= purehash hi=>123, there=> "World"; my $h2= $h->set("hi", "again"); is $h->ref("there"), "World"; is $$h{there}, "World"; is show($h), "purehash('hi'=> 123, 'there'=> 'World')"; is show($h2), "purehash('hi'=> 'again', 'there'=> 'World')"; is is_pure($h2), 1; like( (eval { purehash hi=> 1, hi=> 1, there=> 2 } || $@), qr/^duplicate key: 'hi' at/ ); like( (eval { $$h{there_} || 1} || $@), # the detailed exception message may change! qr/^Attempt to access disallowed key 'there_' in a restricted hash/ );
Hash tables, currently based simply on Perl's internal hashes. They are immutable, and restricted which means that accessing non-existing keys yields an exception.
- performant functional updates (currently the `set` method simply copies the whole table)
- more methods, move/adapt set functionality from FP::Hash and FP::HashSet
- a maybe_ref that returns FP::Failure or FP::Maybe ?
- non-string keys?
Implements: FP::Abstract::Map.
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.