This line made me laugh out loud: "... whenever something is even slightly ugly in Scala, you introduce an implicit to make it confusing instead."
Odersky wrote a simple implementation, and it looks a lot nicer. It also doesn't use any casts or implicit conversaions: https://gist.github.com/odersky/6b7c0eb4731058803dfd
Type-safe Transducers in Clojure, Scala, and Haskell
11–13 of 13 posts
Re: Type-safe Transducers in Clojure, Scala, and Haskell
#12This is interesting, but it's still missing some very important features of transducers. As you alluded, stateful operations [1] won't work at all in your Haskell model. Also, you've missed early termination [2], which Rich's talk [3] covered well. [1] https://github.com/clojure/clojure/blob/b01adb859c66322c5cff... [2] https://github.com/clojure/clojure/blob/b01adb859c66322c5cff... [3] https://www.youtube.com/watch?v…
There's more missing than that, but, in the spirit of early termination, I had to stop somewhere! Specifically to your points: 1. To preempt the faithful: Stateful transducers don't work (for a broad definition of work) in Clojure or Scala either. It's just that there's no tradition of acknowledging state via type in those languages. 2. Early termination is weird. In Clojure it's a property of the accumulated reducti…
Re: Type-safe Transducers in Clojure, Scala, and Haskell
#13Earlier quoted context omitted.
You can do that, but it's more elegant if you define a functional stateful transducer analogous to scanl for lists.
That's like saying "your program is more elegant if it has no monads". It's an incorrect statement. The monadic version is perfectly elegant. Even better: it's the right one.
(b -> IO a) -> [b] -> IO [a]
instead of (a -> b -> a) -> a -> [b] -> [a]
Just putting the whole thing in the IO/ST monad isn't the right solution when you need a very specific form of local state.