1 =head1 Declaration keywords
5 Declares a subtype of a type, a collection of instances of that type
6 which adhere to a given condition.
8 my subset Positive of Num where { $^n > 0 };
13 This subtype can then be referred to anywhere an ordinary class or role can.
15 The condition block will want to check the instance for some relation being
16 upheld. The instance can be referred to in the following three ways:
18 { $_ > 0 } # as the topic variable $_
19 -> $n { $n > 0 } # as an explicit names parameter
20 { $^n > 0 } # as a placeholder parameter
22 You cannot instantiate subtypes. In other words, this doesn't work:
24 my Positive $p .= new;
26 To export a subset type, put the export trait just before the C<where>:
28 subset DNA of Str is export where { all(.comb) eq 'A'|'C'|'G'|'T' };