Repository navigation
Fix some Fold/Scan bugs, minor doc issues - #3258
Merged
Merged
Conversation
The macOS GHC bindists hardcode the CLT SDK path of their build machine: the rts and ghci package confs of GHC 9.14.1 have /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib in library-dirs. The linker therefore uses the CLT SDK even with Xcode selected. The macos-26-arm64 image 20261013 ships CLT SDK 27.0, whose tbd files Xcode 26.6's ld rejects with "unknown architecture arm64e.x1-macos". The previous image had an older CLT SDK, and a GHC restored from the cache does not help on branches without that cache. Point the CLT MacOSX.sdk symlink at the Xcode SDK, and correct the comment that said GHC records the SDK path when it is installed.
sampleFromthen offset stride kept the elements at the indices i with (i + offset) mod stride == 0, so sampleFromthen 1 3 on [0..9] returned [2,5,8] instead of [1,4,7]. Keep the indices i >= offset with (i - offset) mod stride == 0. The existing test used offset 0, where the two agree.
distributeScan kept a fold whose step returned Done in the list of running folds, with Done as its initial action. Its result was added to the output only on the next input, and was lost if the stream ended: with the folds [Fold.take 2 Fold.sum, Fold.take 2 Fold.length] on [1,2], Fold.fromScanl (distributeScan gen) returned [] instead of [3,2].
The sum doc said that sum is not numerically stable and that foldl' (+) 0 is. sum uses Kahan-Babuska-Neumaier summation, foldl' (+) 0 is the unstable one. The Min monoid definition in the minimum doc was named maximum. The definition in the null doc, fmap isJust Fold.one, returns False for an empty stream, null returns True.
windowRange 0, and windowMinimum 0 and windowMaximum 0, failed with the message "ringsOf: window size must be > 0".
When the fold for a key terminated on the first input of that key, the
key was neither kept in the map of running folds nor added to the set of
finished keys. The next input with the same key started the fold again
and produced another result. For example, classifyScan fst with the
inner fold "take 1 sum" on [("A",1),("A",2)] emitted ("A",1) and
("A",2) instead of only ("A",1).
Fix classifyGeneric, classifyGenericIO, classifyScanGeneric and
classifyScanGenericIO, and with them classify, classifyIO, classifyScan
and classifyScanIO.
unzip applied fromJust to the result of checking that both scans produced an output, so it failed with "fromJust Nothing" whenever either scan skipped an input, although its doc says such outputs are filtered out. unzip implements (***) in the Arrow instance of Scan, and through it first and second. For example, scanr (Scan.filter odd *** Scan.identity) on [(1,1),(2,2)] failed on (2,2) instead of returning [(1,1)]. Filter out the Nothing outputs before fromJust, as teeWith does.
In the Streamly.Data.Scan example, "Scan.compose scan1 scan3" runs scan3 first, so it computed (x^2 + 3x)^2 instead of the stated x^4 + 3x^2. Swap the arguments and run main in the example to show the output. The demuxKvToMap definition applied "Fold.lmap snd" to the monadic Maybe result of the key function instead of to the fold inside it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mostly small correctness fixes in Fold and Scan combinators.