1 package DX::RuleDefinitionContext;
3 use DX::PropositionSequence;
4 use DX::Predicate::Rule;
7 has arg_names => (is => 'ro', required => 1, isa => ArrayRef[Str]);
9 has proposition_sequence => (
10 is => 'rwp', lazy => 1, isa => PropositionSequence,
13 my %arg_names = map +($_ => 1), @{$self->arg_names};
14 DX::PropositionSequence->new_empty
15 ->but(external_names => \%arg_names);
20 is => 'ro', required => 1, isa => Expander, handles => [ qw(expand_args) ]
24 my ($self, $pred, @arg_strings) = @_;
25 my @args = $self->expand_args(@arg_strings);
26 my ($intro, $need) = ({}, {});
27 foreach my $arg (@args) {
29 next if $arg =~ /^\??[a-z]/; # skip globals
30 # ?Foo is intro, Foo is need
31 ($arg =~ s/^\?// ? $intro : $need)->{$arg} = 1;
33 my $prop = DX::Proposition->new(
36 introduced_names => $intro,
37 required_names => $need,
39 $self->_set_proposition_sequence(
40 $self->proposition_sequence->with_additional_proposition($prop)
47 DX::Predicate::Rule->new(
48 arg_names => $self->arg_names,
49 proposition_sequence => $self->proposition_sequence