Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Transducer s a b = Transducer {}
- etc :: MonadConc m => s -> Transducer s a b -> Cont m (Box (STM m) b a) -> m s
- etcM :: (MonadConc m, MonadBase m m) => s -> Transducer s a b -> Cont m (Box m b a) -> m s
- asPipe :: Monad m => Pipe a b (StateT s m) () -> Stream (Of a) (StateT s m) () -> Stream (Of b) (StateT s m) ()
Documentation
newtype Transducer s a b Source #
transduction wiki says: "A transducer is a device that converts energy from one form to another." Translated to context, this Transducer converts a stream of type a to a stream of a different type.
Instances
Category (Transducer s :: Type -> Type -> Type) Source # | |
Defined in Box.Transducer id :: Transducer s a a # (.) :: Transducer s b c -> Transducer s a b -> Transducer s a c # |
etc :: MonadConc m => s -> Transducer s a b -> Cont m (Box (STM m) b a) -> m s Source #
emit - transduce - commit
with etc, you're in the box, and inside the box, there are no effects: just a stream of a
s, pure functions and state tracking. It's a nice way to code, and very friendly for the compiler. When the committing and emitting is done, the box collapses to state.
The combination of an input tape, an output tape, and a state-based stream computation lends itself to the etc computation as a finite-state transducer or mealy machine.