loading...

re: Don't Read This Monad Tutorial VIEW POST

FULL DISCUSSION
 

This looks really ugly to me, transducers allow me to write code like

$operations = compose(
  filter('is_odd'),
  map('+')
);

to_array([1, 2, 3], $operations); // [2, 4]

Transducers work with many data structures with one implementation of map filter etc, with many operations in one pass and can be short circuited

For someone who is familiar with both, am I missing anything important by not knowing monads?

 

Transducers use function composition to achieve the desired result which is great. The problem that I walk through solving in this example is that I not only want the final result, but also the functions that were called to create that result. It's a weird problem, but it's a problem that could corner someone into creating a monad by accident.

As far as missing anything important goes, you probably already use monads all the time and really don't need to know that they're categorized as Monads in order to use them effectively; Lists are monads. But there is a whole other way of looking at programs from the perspective of category theory, and Monads are a great entry point into seeing things from that perspective.

 

Monad is a much more general and therefore simpler abstraction than transducer.

You can read this post about how transducer is analyzed from a type theory perspective:
hypirion.com/musings/haskell-trans...

code of conduct - report abuse