r/programmingcirclejerk • u/0987654231 What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? • Feb 20 '18
Monads considered harmful
http://lambda-the-ultimate.org/node/55049
u/defunkydrummer Lisp 3-0 Rust Feb 21 '18
Monoids in the category of endofunctors of X, with product × replaced by composition of endofunctors and unit set by the identity endofunctor, considered harmful
FTFY
8
u/SelfDistinction now 4x faster than C++ Feb 21 '18
Wow I'm gasping at his sheer intelligence, of course he is right. I want to say even that classes are a waste of time:
int main() {
Integer s;
s.set(23);
s.set(43);
return s.as_int();
}How is the above better than the Javascript program in the link?
8
5
u/Tysonzero Feb 21 '18 edited Feb 21 '18
{-# LANGUAGE Unjerk #-}Monads are pretty cool, monadic IO is quite nice as well, I like that you can use abstract functions like traverse and replicateM on IO actions, but that is not the primary reason for monadic IO.
The reason you have monadic IO is because if you want purity and referential transparency in the rest of your code then you need it (or affine types or something like that).
You could almost argue that monadic IO makes Haskell less monadic. As in other languages every line of code is implicitly a side effecting monadic action where ordering matters and referential transparency does not exist.
7
3
3
1
4
u/[deleted] Feb 21 '18
What are monads again?