1. 8
  1.  

  2. 2

    I at a later point began to formalize these as “state machine transformers” in such a way where things like take are able to be encoded even without using side effects.

    data Machine i o where
      Machine :: s -> (i -> s -> s) -> (s -> o) -> Machine i o
    
    newtype Transducer i o = 
      Transducer (forall r . Machine o r -> Machine i r)
    

    Another model which I would want to explore is including an effect in the transformation

    newtype Transducer m i o =
      Transducer (forall r . (o -> r -> r) -> m (i -> r -> r))
    
    1. [Comment removed by author]

      1. 2

        Not as useful as Haskell has pervasive laziness. There are also lots of other formulations of streaming data in typed languages which exceed the richness of transducers. If you see them as state machine transformers then they’re a reasonably general construction, but it can be easier to work with the state machines directly.