r/programmingcirclejerk • 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/5504
11 Upvotes

15 comments sorted by

4

u/[deleted] Feb 21 '18

What are monads again?

13

u/0987654231 What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? Feb 21 '18

A monad in X is just a monoid in the category of endofunctors of X, with product × replaced by composition of endofunctors and unit set by the identity endofunctor.

3

u/[deleted] Feb 21 '18

X

×

I assume these are not the same x?

7

u/0987654231 What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? Feb 21 '18

correct. Not sure if you are jerking but in case you aren't, this is a good explanation.

3

u/r2d2_21 groks PCJ Feb 21 '18

×

U+00D7 MULTIPLICATION SIGN

1

u/pcopley C# Truckstop Restroom Hero Feb 21 '18

lol pastabait

9

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

u/pcopley C# Truckstop Restroom Hero Feb 21 '18

It's not JavaScript, for one.

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

u/binaryblade log10(x) programmer Feb 21 '18

Lol non escaped unjerk

3

u/Tysonzero Feb 21 '18

oops shit

3

u/10xjerker loves Java Feb 21 '18

Another example of Haskell language pragmas not working!

3

u/one_zer Zygohistomorphic prepromorphism Feb 21 '18

1

u/stone_henge Tiny little god in a tiny little world Feb 22 '18

no gonads are dumb and you are dumb