def compile_trace(destination):
  """
  Given a destination list, returns a maintenance function that appends a trace
  string to the given list every time it is called.
  """
  def trace(net, task, result):
    nonlocal destination
    destination.append("Task {}: {}".format(task.name, result.__name__))
  return trace