MouseX::Types::Data::Monad::Either - Type constraints for Data::Monad::Either
use Data::Monad::Either qw( right left ); use MouseX::Types::Data::Monad::Either; use Smart::Args qw( args ); sub from_api { args my $json => 'Either[Left[Str] | Right[Int]]'; $json->flat_map(sub { # ... }); } from_api(right(1)); from_api(left('some error'));
MouseX::Types::Data::Monad::Either defines a type constraint for Data::Monad::Either.
Either type requires a union type that consists of Left and Right types.
Either
Left
Right
The reason for this strange requirement is that Mouse::Meta::TypeConstraint cannot have multiple type parameters.
Mouse, Data::Monad::Either
Copyright (C) aereal.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
aereal <aereal@aereal.org>
To install MouseX::Types::Data::Monad, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MouseX::Types::Data::Monad
CPAN shell
perl -MCPAN -e shell install MouseX::Types::Data::Monad
For more information on module installation, please visit the detailed CPAN module installation guide.