on master help sign in
Update doc of the demux combinator
commit98a920e36eebbbfc9d26e668e357371202e2545f authorHarendra Kumar <harendra@composewell.com> dateSun 23 Apr 2023, 16:05 (4 years ago) parent08aeb6e
1 file changed+8
core/src/Streamly/Internal/Data/Fold/Container.hs+8
core/src/Streamly/Internal/Data/Fold/Container.hs+8
@@ -326,6 +326,14 @@ demuxGeneric getKey getFold = fmap extract $ foldlM' step initial
326326-- This can be used to scan a stream and collect the results from the scan
327327-- output.
328328--
329+-- Since the fold generator function is monadic we can add folds dynamically.
330+-- For example, we can maintain a Map of keys to folds in an IORef and lookup
331+-- the fold from that corresponding to a key. This Map can be changed
332+-- dynamically, folds for new keys can be added or folds for old keys can be
333+-- deleted or modified.
334+--
335+-- Compare with 'classify', the fold in 'classify' is a static fold.
336+--
329337-- /Pre-release/
330338--
331339{-# INLINE demux #-}