3 ms·
Can you explain a simpler way to do expression style programming in C++ without using monads and haskell as a way to understand and explain? You can make an arg
by Robin_Message 15y ago
Can you explain a simpler way to do expression style programming in C++ without using monads and haskell as a way to understand and explain? You can make an argument that you should have expressions like that in C++, but that is not the same as saying the monads made this code worse.
Also, it's a monad whether he mentions it or not. Can you reference a monad explanation that is not "cargo cult mathematics"?
- Miky 15y agoI don't even think the author should be using monads for expressions how he was doing in Haskell, which arguably does have suitable tools for using monads in this way. Doing it in C++ is ridiculous. One can have expressions like that in C++ using C++'s many other abstractions, such as classes and inheritance. This will result in code much shorter, cleaner, more general, more useful, and more readable code than what is found in this blog post. The author hasn't achieved the abstraction of a monad in C++ anyway; there's no way to write code that works on both this monad and others, which effectively makes modeling something as a monad as he has done completely without benefit. This would be quite accurately referred to as cargo cult programming. A monad explanation that is not cargo cult mathematics would be one that explains what a monad is in category theory (a functor with two associated natural transformations), explains it as one of many other patterns, and explains why simply including monads and these other patterns in your code does not automatically give them the Mathematical Seal of Approval™, especially when using a language with no support for abstracting over them.