HORIZON HASKELLDocslts/ghc-9.14.x99ffbb82026-10-19Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 99ffbb8 · 2026-10-19

Modulemachines-0.7.4Haskell2010

Data.Machine.Source

Contents
  1. Sources
Synopsis
  • Packagemachines-0.7.4
  • Exports12
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSource.hs

Sources

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.

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.