in reply to Re^2: RFC: Inline::Blocks or inline as a keyword?
in thread RFC: Inline::Blocks or inline as a keyword?
Each type constraint knows how to generate a string of Perl code for validating a value, given a variable name for the value.
For example:
$ perl -MDevel::Hide=Ref::Util::XS,Type::Tiny::XS -MTypes::Standard=-t +ypes -E'say HashRef->inline_check(q/$myvar/)' Devel::Hide hides Ref/Util/XS.pm, Type/Tiny/XS.pm (ref($myvar) eq 'HASH')
So the ArrayRef[HashRef] type constraint can use that when generating a longer bit of code to validate an arrayref of hashrefs:
$ perl -MDevel::Hide=Ref::Util::XS,Type::Tiny::XS -MTypes::Standard=-t +ypes -E'say ArrayRef->of(HashRef)->inline_check(q/$myvar/)' Devel::Hide hides Ref/Util/XS.pm, Type/Tiny/XS.pm do { (ref($myvar) eq 'ARRAY') and do { my $ok = 1; for my $i (@{$myvar +}) { ($ok = 0, last) unless (ref($i) eq 'HASH') }; $ok } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: RFC: Inline::Blocks or inline as a keyword?
by LanX (Saint) on Sep 09, 2018 at 21:34 UTC | |
by tobyink (Canon) on Sep 18, 2018 at 08:23 UTC |