=pod

=encoding utf-8

=head1 NAME

Type::API::Constraint::Inlinable - allows a string of code to be generated to check a given variable

=head1 INTERFACE

Implementations of Type::API::Constraint::Inlinable B<MUST> also implement
L<Type::API::Constraint>.

Implementations B<MUST> provide the following methods:

=over

=item C<< $constraint->can_be_inlined >>

Returns a boolean indicating whether inlining support is available for this
type constraint.

=item C<< $constraint->inline_check($variable_name) >>

C<< $variable_name >> will be a string such as C<< '$_' >> or C<< '$_[0]' >>.
Should return a string of code that may be evaluated to determine the
pass/failure of the value in the given variable. The string B<MUST NOT>
include C<return>, C<goto> or other flow control keywords that would make
it unsuitable for inlining into a larger function.

=back

I<< There is not currently any mechanism to request that the string of code
in a particular programming language, nor a mechanism for the implementation
to indicate what language it has generated. However, the implementations that
have been investigated have returned Perl 5 code. Nevertheless, this is an
area for further investigation. >>

Implementations C<MAY> advertise that they support this interface by returning
true for C<< $constraint->DOES("Type::API::Constraint::Inlinable") >>.

=head1 SEE ALSO

=head2 Implementations

The following CPAN classes are known to implement
Type::API::Constraint::Inlinable:

=over

=item *

L<Specio::Constraint::Simple> (and several other classes in the Specio distribution)

=item *

L<Type::Tiny> (and its subclasses)

=back

The following CPAN classes implement this interface with a minor difference;
the C<inline_check> method is called C<_inline_check> instead. Tools wishing
to make use of this interface should consider supporting this variation.

=over

=item *

L<Moose::Meta::TypeConstraint> (and its subclasses)

=item *

L<MooseX::Meta::TypeDecorator>

=back

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENCE

This software is copyright (c) 2013 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

=cut
