- at compile-time with arguments 'Foo' and 'TYPEDSCALAR' and is
- expected to return the desired package and method name (in that
- order). If any of those is "undef", the default value will be used
- instead.
+ at compile-time with arguments 'Str' and 'TYPEDSCALAR' and is
+ expected to return :
+
+ * either an empty list, in which case the current typed lexical
+ definition will be skipped (thus it won't be altered to trigger
+ a run-time hook) ;
+
+ use Lexical::Types as => sub { return $_[0] =~ /Str/ ? @_ : () };
+ my Str $y; # calls Str->TYPEDSCALAR
+ my Int $x; # nothing special
+
+ * or the desired package and method name, in that order (if any of
+ those is "undef", the default value will be used instead).
+
+ use Lexical::Types as => sub { 'My', 'new_' . lc($_[0]) };
+ my Str $x; # the coderef indicates to call My->new_str
+
+ Note that if the type is a constant, $_[0] will be set to the
+ *value* of constant and not to its name.