Sub::Meta::Returns - meta information about return values
use Sub::Meta::Returns; my $r = Sub::Meta::Returns->new( scalar => 'Int', # optional list => 'ArrayRef', # optional void => 'Void', # optional ); $r->scalar; # 'Int' $r->list; # 'ArrayRef' $r->void; # 'Void'
Constructor of Sub::Meta::Returns.
Sub::Meta::Returns
A type for value when called in scalar context.
scalar
method scalar() => Maybe[Any]
has_scalar
method has_scalar() => Bool
Whether Sub::Meta::Returns has scalar type or not.
set_scalar($type)
method set_scalar(Any $type) $self
Setter for scalar.
A type for value when called in list context.
list
method list() => Maybe[Any]
has_list
method has_list() => Bool
Whether Sub::Meta::Returns has list type or not.
set_list($type)
method set_list(Any $type) => $self
Setter for list.
A type for value when called in void context.
void
method void() => Maybe[Any]
has_void
method has_void() => Bool
Whether Sub::Meta::Returns has void type or not.
set_void($type)
method set_void(Any $type) => $self
Setter for void.
coercions.
coerce
method coerce() => Maybe[Any]
has_coerce
method has_coerce() => Bool
Whether Sub::Meta::Returns has coercions or not.
set_coerce($bool)
method set_coerce(Bool $bool) => $self
Setter for coerce.
method is_same_interface(InstanceOf[Sub::Meta::Returns] $other_meta) => Bool
A boolean value indicating whether Sub::Meta::Returns object is same or not. Specifically, check whether scalar, list and void are equal.
method is_relaxed_same_interface(InstanceOf[Sub::Meta::Returns] $other_meta) => Bool
A boolean value indicating whether Sub::Meta::Returns object is same or not. Specifically, check whether scalar, list and void are satisfy the condition of $self side:
$self
my $meta = Sub::Meta::Returns->new(scalar => 'Str') my $other = Sub::Meta::Returns->new(scalar => 'Str', list => 'Int'); $meta->is_same_interface($other); # NG $meta->is_relaxed_same_interface($other); # OK. The reason is that $meta does not specify the list type.
method is_same_interface_inlined(InstanceOf[Sub::Meta::Returns] $other_meta) => Str
Returns inlined is_same_interface string.
is_same_interface
method is_relaxed_same_interface_inlined(InstanceOf[Sub::Meta::Returns] $other_meta) => Str
Returns inlined is_relaxed_same_interface string.
is_relaxed_same_interface
method error_message(InstanceOf[Sub::Meta::Returns] $other_meta) => Str
Return the error message when the interface is not same. If same, then return empty string.
method relaxed_error_message(InstanceOf[Sub::Meta::Returns] $other_meta) => Str
Return the error message when the interface does not satisfy the $self meta. If match, then return empty string.
method display() => Str
Returns the display of Sub::Meta::Returns:
use Sub::Meta::Returns; use Types::Standard qw(Tuple Str); my $meta = Sub::Meta::Returns->new(Tuple[Str,Str]); $meta->display; # 'Tuple[Str,Str]'
Copyright (C) kfly8.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
kfly8 <kfly@cpan.org>
To install Sub::Meta, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Meta
CPAN shell
perl -MCPAN -e shell install Sub::Meta
For more information on module installation, please visit the detailed CPAN module installation guide.