3 ms·
So how do you generalize this idea to programs and functions? My framing is "incorrect" I think but it feels far easier to reason about. Couldn't this same ide
by koolala 3y ago
So how do you generalize this idea to programs and functions? My framing is "incorrect" I think but it feels far easier to reason about.
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?
- kfixjviv 3y agoThe main reason that monads are restricted to fancy languages like Haskell is that the type system has to support their definition. There are some examples of attempted implementations the list monad in other languages on RosettaCode https://rosettacode.org/wiki/Monads/List_monad 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.
- koolala 3y agoMonads are a concept in types and a specific theory but if you throw the rigid definition away can't they be done anywhere? For example, if I have three RaspberryPi's, isn't there a way I could compose them as monads? 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.
- kfixjviv 3y agoEach Raspberry Pi could perform a function that was notionally passed to the monadic bind operator, but really a monad is the rules under which the Raspberry Pis would be connected. 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.
- kfixjviv 3y agoBy the way, "throwing the rigid definition away" would be completely missing the point. The rigid definition is the essence of monads.
- epgui 3y agoPeople who think they hate maths will always try to get rid of the maths and tell themselves that that makes the maths way better.
- koolala 3y agoIt's important to me because if the pattern was actually useful then we should be able to use it anywhere and talk about it. It seems obvious that the pipe "workflow" pattern as they call it isn't the end-all for program composition - so how can we fix and expand it? It seems fixable. 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.
- kfixjviv 3y agoYou are going to be disappointed. What on earth makes you convinced that a monad can be implemented in Excel? You don't understand what a monad is, so you can't know whether Excel is "perfectly capable" of it or not. Read a bunch of monad tutorials, learn Haskell, hey, even develop some "mathematical maturity" if you can get over your disdain for math. That is the way to make progress. It's not helpful to want monads to be tangible objects. It doesn't matter how much you want it. The world doesn't work like that.
- koolala 3y agoMy conviction goes like this: 1. Excel doesn't use rigid types so we can throw away all the rigid math stuff (this is where our perspectives diverge into non-sense) 2. Each Cell is a Monad 3. Each monad can be composed and reflect eachother better than any other programming language (more than Pipes like my original 1 | 2 | 3 example)