3 ms·
You would implement the sort so that it either: 1: Returns the sorted list (once finished) 2: Returns an intermediate state containing the progress of the sor
by jhomedall 8y ago
You would implement the sort so that it either:
1: Returns the sorted list (once finished)
2: Returns an intermediate state containing the progress of the sort in addition to the current state of the sort.
You would repeatedly pass the intermediate state to the sorting function until finished. You can use the progress component of the intermediate state to track progress.
Something like the following (I don't actually write Haskell, so this could probably be represented better):
data SomeIntermediateState = ...
data Progress = Double
data SortState a =
Complete [a]
| InProgress (SomeIntermediateState, Progress)
sortInit :: [a] -> SortState
sort :: SortState -> SortState