unison icon indicating copy to clipboard operation
unison copied to clipboard

revisit/cleanup how numbered args are generated and used

Open aryairani opened this issue 1 year ago • 2 comments

We have Output (the original) and NumberedOutput (meant for numbered args, but especially for generating and numbering output at the same time), and evidently (as seen in #4601, #4603) started to diverge in how we create numbered args.

I remember finding respondNumbered awkward to use in some cases, and using respond + manually setting numbered args is more flexible (though also more error prone)

Let's discuss whether we want to continue to have two kinds of output, two ways of setting numbered args, or whether there's something we can do to consolidate and facilitate their use.

aryairani avatar Jan 10 '24 20:01 aryairani

Restated: Review the current respondNumbered design, and decide if it's worth it to make it better? And/or make a plan to convert to whatever consistent thing.

aryairani avatar May 29 '24 19:05 aryairani

I think NumberedOutput is the right direction, but could go farther with sharing logic between the pretty output and the numbered args.

Here are some thoughts:

  • we don’t need Output as well – outputs without numbered results can just return the empty list of numbered args (which no longer causes the previous numbered args to be cleared) and
  • instead of notifyNumbered :: NumberedOutput -> (Pretty, [StructuredArgument]), the type should be something more like notifyNumbered :: NumberedOutput -> ([(Section, [a])], forall f. (Functor f) => [(Section, f a)] -> Pretty, forall f. (Functor f) => f a -> f StructuredArgument), which would help ensure that the Pretty and numberedArgs are built from the same list of results.

sellout avatar Jun 26 '24 22:06 sellout