IntroI’ve been programming in Clojure for a long time, but I haven’t been using transducers much. I learned to mechanically transform (into [] (map f coll)) to (into [] (map f) coll) for a slight performance gain, but not much beyond that. Recently, however, I’ve found myself refactoring transducers-based code at work, which prompted me to get back to speed. I found Eero Helenius’ article “Grokkin
Reflecting on Transducers On 2023-01-04 by ThatGeoGuy So over the holidays I have had something of a little bug in my brain: transducers. It started when I was thinking of working on an unrelated side-project, but I more or less got frustrated and asked myself “why doesn’t Scheme have a library that is as good as Rust’s Iterator trait?” I am a strong proponent of Rust both at work and outside of w
Clojure’s transducers are an intellectual curiosity. Not only are they interesting from a usage perspective, people (perhaps mostly Haskellers?) also try to understand what their types are. Trying to derive some sort of type for transducers is not as easy as one would think, partly because of state, mutability and IO. Franklin Chen wrote a great blog post about this, unfortunately, I feel it doesn
By Beerend Lauwers I encountered the notion of transducers about a year ago, but didn’t really look into it. Recently, I encountered it again in a presentation about functional programming in C++ (slide 37). The article on the Clojure website didn’t really help, and a Google search for “Haskell transducers” gave me discussions such as “Clojure’s Transducers are perverse lenses” (What?) and transdu
It turns out that finite state machines are useful for things other than expressing computation. Finite state machines can also be used to compactly represent ordered sets or maps of strings that can be searched very quickly. In this article, I will teach you about finite state machines as a data structure for representing ordered sets and maps. This includes introducing an implementation written
In hindsite1, what I was trying to say in my last post was this: Folds in the foldl library are Moore machines and what I often need is a Mealy machine. data Fold a b = forall x . Fold (x -> a -> x) x (x -> b) ^ ^ ^ ^ ^ ^ input output state step begin done A user of the Fold type (scan in the pipes library is an example) has access to the computational results via done which is only hooked up to t
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]]))) or Haskell type Transducer a b = forall r . (r -> a -> r) -> (r -> b -> r)
TL;DR As noted earlier, transducers can be properly annotated in Clojure using core.typed and they probably should be. But... there are a few tricks necessary to make it work. Transducers in Scala require tricks too, but different ones. Oh, but they're so lovely in Haskell. Update 2015-01-12 Were you led here by Clojure Gazette? Eric Normand is usually more discriminating, but don't worry, this wi
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く