by koolala · 3y ago · 0 comments
Couldn't this same idea be applied generically to all computer programs? Could its valuable situational properties ever be done in a way that is language neutral with arbitrary program monads?
There are some examples of attempted implementations the list monad in other languages on RosettaCode https://rosettacode.org/wiki/Monads/List_monad
Caveat emptor, though. A lot of that page is erroneous.
A few years ago I fixed up the definition for F#, which is perhaps the closest thing to a language for ordinary Joes in which true monadic style can be defined/achieved.
That is what I mean - it isn't a fair thing for me to say - but I feel like they would be so much more tangible if we could think about them as literal Things like this. Which is why my original example was composition of Programs instead of composition in a specific Programming Language.
From Wadler's paper "The Essence of Functional Programming":
"2.1 What is a monad?
For our purposes, a monad is a triple (M,unitM,bindM) consisting of a type constructor M and a pair of polymorphic functions.
unitM :: a-> M a
bindM :: M a-> (a-> M b)-> M b
These functions must satisfy three laws, which are discussed in Section 2.10."
So the monad is a functor plus a few operations and laws. It is an algebraic structure, not a type of object or function.
Another context question: How would you define a monad in Microsoft Excel? For context, that is my favorite programming language. It seems perfectly capable at doing strong monad composition better than a Linux shell.
I just want monads be real and tangible! Examples in reality instead of Math.
Also therefore it is not that "monads can be composed with monads". Only Functions can, bhe composed. Especially functions which are the unitM() or bindM of some monad.