on master help sign in
Add some explanatory notes to Unfold/Fold types.
239cff3Harendra Kumar
src/Streamly/Internal/Data/Fold/Type.hs+4
@@ -350,6 +350,10 @@ mapMStep f res =
350-- The Fold type
350-- The Fold type
351------------------------------------------------------------------------------
351------------------------------------------------------------------------------
352
352
353+-- An fold is akin to a writer. It is the streaming equivalent of a writer.
354+-- The type @b@ is the accumulator of the writer. That's the reason the
355+-- default folds in various modules are called "write".
356+
353-- | The type @Fold m a b@ having constructor @Fold step initial extract@
357-- | The type @Fold m a b@ having constructor @Fold step initial extract@
354-- represents a fold over an input stream of values of type @a@ to a final
358-- represents a fold over an input stream of values of type @a@ to a final
355-- value of type @b@ in 'Monad' @m@.
359-- value of type @b@ in 'Monad' @m@.
src/Streamly/Internal/Data/Unfold/Type.hs+4
@@ -85,6 +85,10 @@ import Prelude hiding (map, concatMap, zipWith, takeWhile)
85-- The order of arguments allows 'Category' and 'Arrow' instances but precludes
85-- The order of arguments allows 'Category' and 'Arrow' instances but precludes
86-- contravariant and contra-applicative.
86-- contravariant and contra-applicative.
87--
87--
88+-- An unfold is akin to a reader. It is the streaming equivalent of a reader.
89+-- The argument @a@ is the environment of the reader. That's the reason the
90+-- default unfolds in various modules are called "read".
91+--
88-- | An @Unfold m a b@ is a generator of a stream of values of type @b@ from a
92-- | An @Unfold m a b@ is a generator of a stream of values of type @b@ from a
89-- seed of type 'a' in 'Monad' @m@.
93-- seed of type 'a' in 'Monad' @m@.
90--
94--