txt: ## quanthash.md
  role QuantHash
  
  Object hashes with a limitation on the type of values
  
  ```raku
  role QuantHash does Associative { }
  ```
  
  The `QuantHash` role provides the basic functionality shared by the [`Setty`](/type/Setty), [`Baggy`](/type/Baggy) and [`Mixy`](/type/Mixy) roles. These provide object hashes whose values are limited in some way.
  
  `QuantHashes` are what [set operators](/language/setbagmix) use internally.
  
  # [Methods](#role_QuantHash "go to top of document")[§](#Methods "direct link")
  
  ## [method hash](#role_QuantHash "go to top of document")[§](#method_hash "direct link")
  
  ```raku
  method hash()
  ```
  
  Coerces the `QuantHash` object to a [`Hash`](/type/Hash) (by stringifying the objects for the keys) with the values of the hash limited to the same limitation as `QuantHash`, and returns that.
  
  ## [method Hash](#role_QuantHash "go to top of document")[§](#method_Hash "direct link")
  
  ```raku
  method Hash()
  ```
  
  Coerces the `QuantHash` object to a [`Hash`](/type/Hash) (by stringifying the objects for the keys) without any limitations on the values, and returns that.
  
  ## [method Map](#role_QuantHash "go to top of document")[§](#method_Map "direct link")
  
  ```raku
  method Map()
  ```
  
  Available as of the 2021.02 release of the Rakudo compiler.
  
  Coerces the `QuantHash` object to a [`Map`](/type/Map) (by stringifying the objects for the keys) without any limitations on the values, and returns that.
  
  ## [method of](#role_QuantHash "go to top of document")[§](#method_of "direct link")
  
  ```raku
  method of()
  ```
  
  Returns the type of value a value of this `QuantHash` may have. This is typically [`Bool`](/type/Bool) for [`Setty`](/type/Setty), [`UInt`](/type/UInt) for [`Baggy`](/type/Baggy) or [`Real`](/type/Real) for [`Mixy`](/type/Mixy) roles.
  
  ## [method keyof](#role_QuantHash "go to top of document")[§](#method_keyof "direct link")
  
  ```raku
  method keyof()
  ```
  
  Returns the type of value a key of this subclass of `QuantHash` may have. This is typically [`Mu`](/type/Mu), which is also the default for punned QuantHashes.
  
  ## [method Capture](#role_QuantHash "go to top of document")[§](#method_Capture "direct link")
  
  ```raku
  method Capture()
  ```
  
  Returns the object as a [`Capture`](/type/Capture) by previously coercing it to a [`Hash`](/type/Hash).
  
  ## [method list](#role_QuantHash "go to top of document")[§](#method_list "direct link")
  
  ```raku
  multi method list(QuantHash:D:)
  ```
  
  Returns a list of [`Pair`](/type/Pair) objects of all keys and values in the QuantHash.
  
  ## [method Setty](#role_QuantHash "go to top of document")[§](#method_Setty "direct link")
  
  ```raku
  method Setty(--> Setty:D)
  ```
  
  Coerce the `QuantHash` object to the equivalent object that uses the [`Setty`](/type/Setty) role. Note that for [`Mixy`](/type/Mixy) type coercion items with negative values will be skipped.
  
  ```raku
  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)␤»
  ```
  
  ## [method Baggy](#role_QuantHash "go to top of document")[§](#method_Baggy "direct link")
  
  ```raku
  method Baggy(--> Baggy:D)
  ```
  
  Coerce the `QuantHash` object to the equivalent object that uses the [`Baggy`](/type/Baggy) role. Note that for [`Mixy`](/type/Mixy) type coercion items with negative values will be skipped.
  
  ```raku
  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)␤»
  ```
  
  ## [method Mixy](#role_QuantHash "go to top of document")[§](#method_Mixy "direct link")
  
  ```raku
  method Mixy(--> Mixy:D)
  ```
  
  Coerce the `QuantHash` object to the equivalent object that uses the [`Mixy`](/type/Mixy) role.
  
  ```raku
  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))␤»
  ```
  
  # [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")
  
  Type relations for `QuantHash`
  
  
  
  raku-type-graph
  
  
  
  QuantHash
  QuantHash
  
  
  Associative
  Associative
  
  
  QuantHash->Associative
  
  
  
  Setty
  Setty
  
  
  Setty->QuantHash
  
  
  
  Baggy
  Baggy
  
  
  Baggy->QuantHash
  
  
  
  Mu
  Mu
  
  
  Any
  Any
  
  
  Any->Mu
  
  
  
  Set
  Set
  
  
  Set->Setty
  
  
  
  Set->Any
  
  
  
  SetHash
  SetHash
  
  
  SetHash->Setty
  
  
  
  SetHash->Any
  
  
  
  Bag
  Bag
  
  
  Bag->Baggy
  
  
  
  Bag->Any
  
  
  
  BagHash
  BagHash
  
  
  BagHash->Baggy
  
  
  
  BagHash->Any
  
  
  
  Mixy
  Mixy
  
  
  Mixy->Baggy
  
  
  
  Mix
  Mix
  
  
  Mix->Any
  
  
  
  Mix->Mixy
  
  
  
  MixHash
  MixHash
  
  
  MixHash->Any
  
  
  
  MixHash->Mixy
  
  [Expand chart above](/assets/typegraphs/QuantHash.svg)
  