ndmitchell / extra

Extra Haskell functions
Other
94 stars 37 forks source link

Documentation of `zipFrom` is misleading #76

Closed fendor closed 3 years ago

fendor commented 3 years ago
-- | 'zip' against an enumeration.
--   Never truncates the output - raises an error if the enumeration runs out.
--
-- > \i xs -> zip [i..] xs == zipFrom i xs
-- > zipFrom False [1..3] == [(False,1),(True, 2)]

Never truncates the output

source: https://github.com/ndmitchell/extra/blob/f1f20850580eb6a26955e279d6b3bf70af71c716/src/Data/List/Extra.hs#L240

The fix depends on the actual intention, but since this is a released function, I suggest to change this to something like

Truncates the output if the enumeration runs out

Happy to provide a PR if that is the intent of the function.

ndmitchell commented 3 years ago

Thanks for the catch. It was deliberate, see 6d052846c07489caaf449ffa0eca864694c96bf8. The reasoning was for consistency with Haskell zip, so that's probably what people expect.

But I forgot to update the docs, despite adding a test case showing it truncating stuff. I've done so now, most appreciated!