4 ms·
I would say... Monads are a concept that are useful when you are programing with monoids. Do not bother trying to understand monads if you don't already have a
by Maybestring 9y ago
I would say... Monads are a concept that are useful when you are programing with monoids.
Do not bother trying to understand monads if you don't already have a good understanding of monoids.
Starting with monads is like trying to learn to divide before you learn to count.
- azinman2 9y agoThen can you explain a monoid please?
- Maybestring 9y agoWhile monoids are explicitly identified in some functional languages, they don't have to be. Monoids just exist whenever the axioms are satisfied. A monoid is a set, and an operation for combining elements from the set, that satisfy a few properties. Closed: For every combination of elements, the result of combination is in the set. Identity: There is an element of the set that when combined with any other element, results in that same other element. Associative: For any elements a,b,c a+(b+c) = (a+b)+c Examples are helpful here. I'll list a few as (set,operation,identity) (Integers,+,0) (Integers,*,1) (Strings,&,"") (Lists,&,[]) (functions t->t, function composition, identity function) (Bool,and,True) (Bool,or,False) (Bags of candy and the empty bag, dumping bag a into bag b, the empty bag)