HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulemachines-0.7.4Haskell2010

Data.Machine.Source

  • 2 types
  • 10 values
  • Packagemachines-0.7.4
  • Exports12
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSource.hs

Sources

12 declarations
valuesource :: Foldable f => f b -> Source b
#

Generate a Source from any Foldable container.

This can be constructed from a plan with source :: Foldable f => f b -> Source b source = construct (traverse_ yield xs)

Examples:

Example1 expression
run $ source [1,2][1,2]
valuerepeated :: o -> Source o
#

Repeat the same value, over and over.

This can be constructed from a plan with repeated :: o -> Source o repeated = repeatedly . yield

Examples:

Example1 expression
run $ taking 5 <~ repeated 1[1,1,1,1,1]
valuecycled :: Foldable f => f b -> Source b
#

Loop through a Foldable container over and over.

This can be constructed from a plan with cycled :: Foldable f => f b -> Source b cycled = repeatedly (traverse_ yield xs)

Examples:

Example1 expression
run $ taking 5 <~ cycled [1,2][1,2,1,2,1]
valueplug :: Monad m => MachineT m k o -> SourceT m o
#

You can transform any MachineT into a SourceT, blocking its input.

This is used by capT, and capWye, and allows an efficient way to plug together machines of different input languages.

valueiterated :: (a -> a) -> a -> Source a
#

iterated f x returns an infinite source of repeated applications of f to x

valueenumerateFromTo :: Enum a => a -> a -> Source a
#

Enumerate from a value to a final value, inclusive, via succ

Examples:

Example1 expression
run $ enumerateFromTo 1 3[1,2,3]
valueunfold :: (r -> Maybe (a, r)) -> r -> Source a
#

unfold k seed The function takes the element and returns Nothing if it is done producing values or returns Just (a,r), in which case, a is yielded and r is used as the next element in a recursive call.