let can_produce target rule =
try
List.iter begin fun resource ->
match Resource.matchit resource target with
| Some env -> raise (Can_produce (subst env rule))
| None -> ()
end rule.prods; None
with Can_produce r -> Some r