=begin pod :kind("Type") :subkind("role") :category("composite")

=TITLE role QuantHash

=SUBTITLE Object hashes with a limitation on the type of values

    role QuantHash does Associative { }

The C<QuantHash> role provides the basic functionality shared by the
L<Setty|/type/Setty>, L<Baggy|/type/Baggy> and L<Mixy|/type/Mixy> roles.  These
provide object hashes whose values are limited in some way.

C<QuantHashes> are what L<set operators|/language/setbagmix> use internally.

=head1 Methods

=head2 method hash

    method hash()

Coerces the C<QuantHash> object to a L<Hash|/type/Hash> (by stringifying the objects
for the keys) with the values of the hash limited to the same limitation as
C<QuantHash>, and returns that.

=head2 method Hash

    method Hash()

Coerces the C<QuantHash> object to a L<Hash|/type/Hash> (by stringifying the objects
for the keys) without any limitations on the values, and returns that.

=head2 method of

    method of()

Returns the type of value a value of this C<QuantHash> may have.  This is
typically L<Bool|/type/Bool> for L<Setty|/type/Setty>, L<UInt|/type/UInt> for
L<Baggy|/type/Baggy> or L<Real|/type/Real> for L<Mixy|/type/Mixy> roles.

=head2 method keyof

    method keyof()

Returns the type of value a key of this subclass of C<QuantHash> may have. This
is typically L<Mu|/type/Mu>, which is also the default for punned QuantHashes.

=head2 method Setty

    method Setty(--> Setty:D)

Coerce the C<QuantHash> object to the equivalent object that uses the L<Setty|/type/Setty>
role. Note that for L<Mixy|/type/Mixy> type coercion items with negative values will be skipped.

    my %b is Bag = one => 1, two => 2;
    say %b.Setty; # OUTPUT: «Set(one two)␤»
    my %m is Mix = one => 1, minus => -1;
    say %m.Setty; # OUTPUT: «Set(one)␤»

=head2 method Baggy

    method Baggy(--> Baggy:D)

Coerce the C<QuantHash> object to the equivalent object that uses the L<Baggy|/type/Baggy>
role. Note that for L<Mixy|/type/Mixy> type coercion items with negative values will be skipped.

    my %s is Set = <one two>;
    say %s.Baggy; # OUTPUT: «Bag(one two)␤»
    my %m is Mix = one => 1, minus => -1;
    say %m.Baggy; # OUTPUT: «Bag(one)␤»

=head2 method Mixy

    method Mixy(--> Mixy:D)

Coerce the C<QuantHash> object to the equivalent object that uses the L<Mixy|/type/Mixy>
role.

    my %s is Set = <one two>;
    say %s.Mixy; # OUTPUT: «Mix(one two)␤»
    my %b is Bag = one => 1, two => 2;
    say %b.Mixy; # OUTPUT: «Mix(one two(2))␤»

=end pod

# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
