Skip to content

Commit 85f2d95

Browse files
committed
Canonicalise Applicative/Monad instance definition
This avoids potential performance issues and makes code a bit more future proof
1 parent 07a6885 commit 85f2d95

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Codec/Compression/Zlib/Stream.hsc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,15 @@ instance Functor Stream where
362362
fmap = liftM
363363

364364
instance Applicative Stream where
365-
pure = return
365+
pure = returnZ
366366
(<*>) = ap
367+
(*>) = thenZ_
367368

368369
instance Monad Stream where
369370
(>>=) = thenZ
370371
-- m >>= f = (m `thenZ` \a -> consistencyCheck `thenZ_` returnZ a) `thenZ` f
371-
(>>) = thenZ_
372-
return = returnZ
372+
(>>) = (*>)
373+
return = pure
373374
fail = (finalise >>) . failZ
374375

375376
returnZ :: a -> Stream a

0 commit comments

Comments
 (0)