summaryrefslogtreecommitdiff
path: root/lib/Type/Tiny/_HalfOp.pm
blob: 725a46edd522b41c8395f24b6306f1b1cc6158ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package Type::Tiny::_HalfOp;

use 5.008001;
use strict;
use warnings;

BEGIN {
	$Type::Tiny::_HalfOp::AUTHORITY = 'cpan:TOBYINK';
	$Type::Tiny::_HalfOp::VERSION   = '2.001_000';
}

$Type::Tiny::_HalfOp::VERSION =~ tr/_//d;

sub new {
	my ( $class, $op, $param, $type ) = @_;
	bless {
		op    => $op,
		param => $param,
		type  => $type,
	}, $class;
}

sub complete {
	require overload;
	my ( $self, $type ) = @_;
	my $complete_type = $type->parameterize( @{ $self->{param} } );
	my $method        = overload::Method( $complete_type, $self->{op} );
	$complete_type->$method( $self->{type}, undef );
}

1;

__END__

=pod

=encoding utf-8

=for stopwords pragmas

=head1 NAME

Type::Tiny::_HalfOp - half-completed overloaded operation

=head1 STATUS

This module is considered part of Type-Tiny's internals. It is not
covered by the
L<Type-Tiny stability policy|Type::Tiny::Manual::Policies/"STABILITY">.

=head1 DESCRIPTION

This is not considered part of Type::Tiny's public API.

It is a class representing a half-completed overloaded operation.

=head2 Constructor

=over

=item C<< new($operation, $param, $type) >>

=back

=head2 Method

=over

=item C<< complete($type) >>

=back

=head1 BUGS

Please report any bugs to
L<https://github.com/tobyink/p5-type-tiny/issues>.

=head1 AUTHOR

Graham Knop E<lt>haarg@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENCE

This software is copyright (c) 2014, 2017-2022 by Graham Knop.

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.