You can just include local state.
data Fold i o = forall st . Fold
{ merge :: st -> i -> st
, this :: st
, view :: st -> o
}
type (i ~> o) = forall r . Fold o r -> Fold i r
-- compare
type Trans i o = forall r . (r -> o -> r) -> (r -> i -> r)
Now each "step" has local pure state and no other step can break abstraction barriers and view it. This also gives you all of the effects of the indexed state passing Rich called untypeable.Fold is equivalent to an infinite state Moore machine, so a stack of composed transducers applied to a base Moore machine which produces whatever result you want can be compiled a really efficient form.
Early termination can be done by changing `merge` to `merge :: st -> i -> Either o st`.