Skip to content

Commit a281663

Browse files
committed
Explain behaviour of zipInPlace when lengths do not match
1 parent bb12a14 commit a281663

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/Data/Bit/Mutable.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,19 @@ cloneToWords8M v = do
116116
-- rewriting the contents of the second argument.
117117
-- Cf. 'Data.Bit.zipBits'.
118118
--
119-
-- Note: If one input is larger than the other, the remaining bits will be ignored.
120-
--
121119
-- >>> :set -XOverloadedLists
122120
-- >>> import Data.Bits
123121
-- >>> Data.Vector.Unboxed.modify (zipInPlace (.&.) [1,1,0]) [0,1,1]
124122
-- [0,1,0]
123+
-- >>> Data.Vector.Unboxed.modify (zipInPlace (\x y -> x .&. complement y) [1,1,0]) [0,1,1]
124+
-- [1,0,0]
125125
--
126-
-- __Warning__: if the immutable vector is shorter than the mutable one,
127-
-- it is the caller's responsibility to trim the result:
126+
-- __Warning__:
127+
-- If the immutable vector is longer than the mutable one,
128+
-- trailing bits will be ignored.
129+
-- If it's a mutable vector who is longer,
130+
-- trailing bits will be kept unchanged;
131+
-- it is caller's responsibility to trim the result:
128132
--
129133
-- >>> :set -XOverloadedLists
130134
-- >>> import Data.Bits

0 commit comments

Comments
 (0)