1
- =head1 Use Sub::Quote
1
+ ## Use Sub::Quote
2
2
3
3
One attempt at this exists in the sub-quotify branch.
4
4
5
5
This has several parts.
6
6
7
- First, type constraints should accept a single C< constraint> parameter, rather
8
- than both a constraint and an C< inline_generator> . If the C< constraint> is a
7
+ First, type constraints should accept a single ` constraint ` parameter, rather
8
+ than both a constraint and an ` inline_generator ` . If the ` constraint ` is a
9
9
Sub::Quote sub, we can use that for inlining. This greatly simplified the API.
10
10
11
- The same should be done for the C< coercion> & C< inline_generator> parameters for
11
+ The same should be done for the ` coercion ` & ` inline_generator ` parameters for
12
12
coercions.
13
13
14
14
Finally, the message_generator should be allow for a Sub::Quote sub and use
15
15
that for inlining if possible.
16
16
17
17
I'm not sure what the best API for the Sub::Quote subs is. Unlike with the
18
18
existing generators, Sub::Quote expects that parameters are always passed via
19
- C<@_> . This probably means that the sub you write should always look at
20
- C< $_[0]> , which is a little gross when inlining, as it means we have to jam
21
- things into C<@_> with something like:
19
+ ` @_ ` . This probably means that the sub you write should always look at
20
+ ` $_[0] ` , which is a little gross when inlining, as it means we have to jam
21
+ things into ` @_ ` with something like:
22
22
23
- local @_ = ($value);
23
+ local @_ = ($value);
24
24
25
25
Note that this also means B<not > passing in the type constraint/coercion as
26
26
the first argument. In other words, these subs are no longer methods. This is
@@ -32,12 +32,7 @@ parameterized_inline_generator sub (not a Sub::Quote). This sub shoudl
32
32
I<return > a quoted sub based on the type parameter. Sub::Quote makes this
33
33
harder than it should be because it doesn't have a very nice API. Oh well.
34
34
35
- =head1 Union types and other set operations?
36
-
37
- I'm not a huge fan of unions, they really confuse the notion of parent type,
38
- for one thing. However, set operations on types are pretty useful.
39
-
40
- =head1 Better integration with Moose
35
+ ## Better integration with Moose
41
36
42
37
Make Moose support inlining coercions and message generation with Specio objects.
43
38
@@ -47,41 +42,41 @@ it's quite broken. In particular, the relationship between constraint &
47
42
coercion objects is backwards. A constraint should have many coercions, not
48
43
vice versa. Specio gets this right.
49
44
50
- =head1 Support MooseX::Types barewords and string types with SpecioX modules
45
+ ## Support MooseX::Types barewords and string types with SpecioX modules
51
46
52
47
For barewords:
53
48
54
- use SpecioX::Declare::Barewords => qw( Specio::Library::Builtins My::Library );
49
+ use SpecioX::Declare::Barewords => qw( Specio::Library::Builtins My::Library );
55
50
56
- use Moose;
51
+ use Moose;
57
52
58
- has foo => ( isa => Str );
53
+ has foo => ( isa => Str );
59
54
60
55
For string types:
61
56
62
- use SpecioX::StringTypes => qw( Specio::Library::Builtins My::Library );
57
+ use SpecioX::StringTypes => qw( Specio::Library::Builtins My::Library );
63
58
64
- use Moose;
59
+ use Moose;
65
60
66
- has foo => ( isa => 'Str' );
61
+ has foo => ( isa => 'Str' );
67
62
68
63
Or something like that.
69
64
70
65
Internally these can both provide an attr trait and class trait that together
71
66
look up a registry for the class by name, something like:
72
67
73
- use Specio::Registry qw( registry_for_package );
68
+ use Specio::Registry qw( registry_for_package );
74
69
75
- my $registry = registry_for_package($package);
70
+ my $registry = registry_for_package($package);
76
71
77
- To parse things like C< "ArrayRef[Str]"> we need to separate the type string
72
+ To parse things like ` "ArrayRef[Str]" ` we need to separate the type string
78
73
parsing into its module that can return a data structure like:
79
74
80
- %parsed = (
81
- name => 'ArrayRef',
82
- parameter => 'Str',
83
- );
75
+ %parsed = (
76
+ name => 'ArrayRef',
77
+ parameter => 'Str',
78
+ );
84
79
85
80
Then we can look these up with:
86
81
87
- my $type = t( $parsed{name}, of => t( $parsed{parameter} ) );
82
+ my $type = t( $parsed{name}, of => t( $parsed{parameter} ) );
0 commit comments