生產者
Producer
是一些 monadic 動作,可以為下游消費提供價值:
type Producer b = Proxy X () () b
yield::Monad m => a -> Producer a m ()
例如:
naturals::Monad m => Producer Int m ()
naturals = each [1..] -- each is a utility function exported by Pipes
我們當然也可以使用其他值的函式:
naturalsUntil::Monad m => Int -> Producer Int m ()
naturalsUntil n = each [1..n]