Blame TODO.md

Packit 42cdad
## Use Sub::Quote
Packit 42cdad
Packit 42cdad
One attempt at this exists in the sub-quotify branch.
Packit 42cdad
Packit 42cdad
This has several parts.
Packit 42cdad
Packit 42cdad
First, type constraints should accept a single `constraint` parameter, rather
Packit 42cdad
than both a constraint and an `inline_generator`. If the `constraint` is a
Packit 42cdad
Sub::Quote sub, we can use that for inlining. This greatly simplified the API.
Packit 42cdad
Packit 42cdad
The same should be done for the `coercion` & `inline_generator` parameters for
Packit 42cdad
coercions.
Packit 42cdad
Packit 42cdad
Finally, the message_generator should be allow for a Sub::Quote sub and use
Packit 42cdad
that for inlining if possible.
Packit 42cdad
Packit 42cdad
I'm not sure what the best API for the Sub::Quote subs is. Unlike with the
Packit 42cdad
existing generators, Sub::Quote expects that parameters are always passed via
Packit 42cdad
`@_`. This probably means that the sub you write should always look at
Packit 42cdad
`$_[0]`, which is a little gross when inlining, as it means we have to jam
Packit 42cdad
things into `@_` with something like:
Packit 42cdad
Packit 42cdad
    local @_ = ($value);
Packit 42cdad
Packit 42cdad
Note that this also means B<not> passing in the type constraint/coercion as
Packit 42cdad
the first argument. In other words, these subs are no longer methods. This is
Packit 42cdad
probably better for inlining anyway. Anything you wanted from the object
Packit 42cdad
should be something you can inline anyway (I hope).
Packit 42cdad
Packit 42cdad
Note that parameterizable types I<still> need to provide a
Packit 42cdad
parameterized_inline_generator sub (not a Sub::Quote). This sub shoudl
Packit 42cdad
I<return> a quoted sub based on the type parameter. Sub::Quote makes this
Packit 42cdad
harder than it should be because it doesn't have a very nice API. Oh well.
Packit 42cdad
Packit 42cdad
## Better integration with Moose
Packit 42cdad
Packit 42cdad
Make Moose support inlining coercions and message generation with Specio objects.
Packit 42cdad
Packit 42cdad
Also, define a real API for type objects and have Moose just use duck typing
Packit 42cdad
internally. However, this should I<not> be the existing Moose TC API, since
Packit 42cdad
it's quite broken. In particular, the relationship between constraint &
Packit 42cdad
coercion objects is backwards. A constraint should have many coercions, not
Packit 42cdad
vice versa. Specio gets this right.
Packit 42cdad
Packit 42cdad
## Support MooseX::Types barewords and string types with SpecioX modules
Packit 42cdad
Packit 42cdad
For barewords:
Packit 42cdad
Packit 42cdad
    use SpecioX::Declare::Barewords => qw( Specio::Library::Builtins My::Library );
Packit 42cdad
Packit 42cdad
    use Moose;
Packit 42cdad
Packit 42cdad
    has foo => ( isa => Str );
Packit 42cdad
Packit 42cdad
For string types:
Packit 42cdad
Packit 42cdad
    use SpecioX::StringTypes => qw( Specio::Library::Builtins My::Library );
Packit 42cdad
Packit 42cdad
    use Moose;
Packit 42cdad
Packit 42cdad
    has foo => ( isa => 'Str' );
Packit 42cdad
Packit 42cdad
Or something like that.
Packit 42cdad
Packit 42cdad
Internally these can both provide an attr trait and class trait that together
Packit 42cdad
look up a registry for the class by name, something like:
Packit 42cdad
Packit 42cdad
    use Specio::Registry qw( registry_for_package );
Packit 42cdad
Packit 42cdad
    my $registry = registry_for_package($package);
Packit 42cdad
Packit 42cdad
To parse things like `"ArrayRef[Str]"` we need to separate the type string
Packit 42cdad
parsing into its module that can return a data structure like:
Packit 42cdad
Packit 42cdad
    %parsed = (
Packit 42cdad
        name      => 'ArrayRef',
Packit 42cdad
        parameter => 'Str',
Packit 42cdad
    );
Packit 42cdad
Packit 42cdad
Then we can look these up with:
Packit 42cdad
Packit 42cdad
    my $type = t( $parsed{name}, of => t( $parsed{parameter} ) );