Skip Menu |

This queue is for tickets about the MooseX-Types CPAN distribution.

Report information
The Basics
Id: 73668
Status: rejected
Priority: 0/
Queue: MooseX-Types

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Overload modulus
package MooseX::Types::TypeDecorator; use overload '%' => sub { my ($self, $val) = @_; $self->__type_constraint->assert_coerce($val); }; This is perhaps not as super-fantastic as my other suggestion (overloading smart match), but I still think it's quite cool. It allows: use MooseX::Types::URI qw/Uri/; my $uri = 'http://example.com/' % Uri; Or even: use MooseX::Types::URI qw/Uri/; my $uri = <STDIN>; chomp $uri; $uri %= Uri;
On Mon Jan 02 04:59:53 2012, TOBYINK wrote: Show quoted text
> package MooseX::Types::TypeDecorator; > use overload > '%' => sub { > my ($self, $val) = @_; > $self->__type_constraint->assert_coerce($val); > }; > > This is perhaps not as super-fantastic as my other suggestion > (overloading smart match), but I still think it's quite cool. It
allows: I'm really not a big fan of overloading except for the most obvious uses. This is far from obvious.