find solution on proposition addition and output actions run
Matt S Trout [Sat, 5 Mar 2016 07:51:52 +0000 (07:51 +0000)]
lib/DX/QueryState.pm
lib/DX/ShellSession.pm

index 68f4638..dcc79c7 100644 (file)
@@ -61,9 +61,12 @@ sub with_additional_proposition {
   my ($self, $prop) = @_;
   my $prop_seq = $self->proposition_sequence
                       ->but_append_proposition($prop);
+  my $sol_ss = $self->new_search_state_for($prop_seq)
+                    ->find_solution;
+  die "No solution" unless $sol_ss;
   $self->but(
     proposition_sequence => $prop_seq,
-    search_state => $self->new_search_state_for($prop_seq)
+    search_state => $sol_ss,
   );
 }
 
index 2fb604c..fff5d1e 100644 (file)
@@ -102,8 +102,14 @@ sub apply_predicate {
     introduces_names => $intro,
     requires_names => $need,
   );
-  my $qstate = $self->shell_state->current_query_state;
-  $qstate = $qstate->with_additional_proposition($prop);
+  my $old_qstate = $self->shell_state->current_query_state;
+  my $qstate = $old_qstate->with_additional_proposition($prop);
+  my $old_action_count = @{
+    $old_qstate->search_state->current_hypothesis->actions
+  };
+  my @actions = @{$qstate->search_state->current_hypothesis->actions};
+  push our @Result,
+    map [ output => $_ ], @actions[$old_action_count..$#actions];
   $self->_set_shell_state(
     $self->shell_state->but(
       current_query_state => $qstate