NAME
FP::PureHash
SYNOPSIS
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/ );
DESCRIPTION
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.
TODO
- 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?
SEE ALSO
Implements: FP::Abstract::Pure, FP::Abstract::Map, FP::Abstract::Equal, FP::Abstract::Show
NOTE
This is alpha software! Read the status section in the package README or on the website.