@@ -201,7 +201,8 @@ module Streamly.Internal.Data.Fold
201201
202202 -- ** Demultiplexing
203203 -- | Direct values in the input stream to different folds using an n-ary
204− -- fold selector.
204+ -- fold selector. 'demux' is a generalization of 'classify' where each key
205+ -- of the classifier can use a different fold.
205206 , demux -- XXX rename this to demux_
206207 , demuxWith
207208 , demuxDefault -- XXX rename this to demux
@@ -211,7 +212,9 @@ module Streamly.Internal.Data.Fold
211212
212213 -- ** Classifying
213214 -- | In an input stream of key value pairs fold values for different keys
214− -- in individual output buckets using the given fold.
215+ -- in individual output buckets using the given fold. 'classify' is a
216+ -- special case of 'demux' where all the branches of the demultiplexer use
217+ -- the same fold.
215218 --
216219 -- Different types of maps can be used with these combinators via the IsMap
217220 -- type class. Hashmap performs better when there are more collisions, trie
@@ -1476,7 +1479,7 @@ partition = partitionBy id
14761479--
14771480-- Any input that does not map to a fold in the input Map is silently ignored.
14781481--
1479−-- > demuxWith f kv = fmap fst $ demuxDefaultWith f kv drain
1482+-- >>> demuxWith f kv = fmap fst $ Fold.demuxDefaultWith f kv Fold.drain
14801483--
14811484-- /Pre-release/
14821485--
@@ -1497,7 +1500,7 @@ demuxWith f kv = fmap fst $ demuxDefaultWith f kv drain
14971500-- :}
14981501-- fromList [("PRODUCT",8),("SUM",4)]
14991502--
1500−-- > demux = demuxWith id
1503+-- >>> demux = Fold.demuxWith id
15011504--
15021505-- /Pre-release/
15031506{-# INLINE demux #-}
@@ -1630,7 +1633,7 @@ demuxDefaultWith f kv (Fold dstep dinitial dextract) =
16301633 return (doneMap, b)
16311634
16321635-- |
1633−-- > demuxDefault = demuxDefaultWith id
1636+-- >>> demuxDefault = Fold.demuxDefaultWith id
16341637--
16351638-- /Pre-release/
16361639{-# INLINE demuxDefault #-}
@@ -1813,12 +1816,12 @@ classifyMutWith f fld =
18131816--
18141817-- Same as:
18151818--
1816−-- > classify fld = Fold.classifyWith fst (lmap snd fld)
1819+-- >>> classify = Fold.classifyWith fst . Fold.lmap snd
18171820--
18181821-- /Pre-release/
18191822{-# INLINE classify #-}
18201823classify :: (Monad m, Ord k) => Fold m a b -> Fold m (k, a) (Map k b)
1821−classify fld = classifyWith fst (lmap snd fld)
1824+classify = classifyWith fst . lmap snd
18221825
18231826------------------------------------------------------------------------------
18241827-- Unzipping