After my recent attempt to provide type annotations for transducers, several people pointed out that I wasn't accounting for state. The signature of a pure function transformation, whether in Clojure
(t/defalias Transducer (t/TFn [[a :variance :covariant] [b :variance :contravariant]] (t/All [r] [[r a -> r] -> [r b ->r]])))
type Transducer a b = forall r . (r -> a -> r) -> (r -> b -> r)
nowhere acknowledges that the transducer might need to maintain, for example, the previous value in the series, in order to remove duplicates.
The failure is most obvious to hardcore Haskell programmers, who, as a rule ...more ...