| |
| ▲ | metanonsense 4 days ago | parent | next [-] | | But isn’t that exactly what GP meant? There is an original, very precise but also very abstract definition (and what is more abstract than category theory). Then people come along who give a different definition that matches the original one in their specific context („three laws in Haskell“). After that people take these three laws and apply them (sometimes overly simplistic) to other contexts („just give it a flatMap in Scala to get a monad“). And at some point the original meaning got lost, and there are competing definitions out. | | |
| ▲ | frumplestlatz 4 days ago | parent | next [-] | | Those three laws are the mathematical definition. Yes, they’re encoded in Haskell, but they’re the same monad laws from category theory. | | |
| ▲ | charcircuit 4 days ago | parent [-] | | Haskell doesn't encode them. And other concepts can be given a mathematical definition if someone wanted to formalize them. | | |
| ▲ | frumplestlatz 4 days ago | parent | next [-] | | That is pedantry. As for the other concepts, formalizations of OO have been done — generally to support formal verification of OO languages. They are incredibly complicated, comprising papers of tens to hundreds of pages, and either extremely language specific, usually only formalizing a portion of the full language, or general but too limited to specify the behavior of real world languages. The two are not comparable. I’m also not aware of any general formalization of MVC or how one would even begin to approach a canonical definition, much less formalization. | | |
| ▲ | charcircuit 4 days ago | parent [-] | | >I’m also not aware of any general formalization of MVC or how one would even begin to approach a canonical definition You define it by defining Model, View, and Controller and how they interact with each other. For example take a look at the diagram from the article. | | |
| |
| ▲ | antonvs 4 days ago | parent | prev [-] | | > other concepts can be given a mathematical definition if someone wanted to formalize them. There's really no comparison. Monads have a very small and simple definition. That's not true of either OOP or MVC. Formalizations of OOP do exist - they're complex and messy and mainly serve to demonstrate how poorly motivated classic OOP is. | | |
| ▲ | charcircuit 4 days ago | parent [-] | | >they're complex and messy Ultimately they are expressed in code by either the compiler or a framework. If you just want a high level formalization I don't think it would be that complex or messy. |
|
|
| |
| ▲ | antonvs 4 days ago | parent | prev | next [-] | | > three laws in Haskell The laws are mathematical ones, that can't be expressed in the Haskell type system. > And at some point the original meaning got lost This is false. The original meaning is a mathematical one, and its use in Haskell conforms to that. That meaning is not "lost", it's the only valid and rigorous definition there is. People who think the meaning is lost are simply ignorant. All they would have to do to correct that ignorance is a minimal amount of research. | |
| ▲ | antonvs 4 days ago | parent | prev [-] | | Can you cite an example of a competing definition of monads? |
| |
| ▲ | whstl 4 days ago | parent | prev | next [-] | | In the parent comment I did qualify my statement, in it I am talking about monads "once it gets 'explained' and migrated to other languages", not about Monad in Haskell and definitely not about Monad laws. | | |
| ▲ | frumplestlatz 4 days ago | parent [-] | | Perhaps you can provide a concrete example. I’ve seen Haskell’s type class hierarchy successfully realized in all sorts of languages, from Scala to Swift. - https://github.com/scalaz/scalaz - https://bow-swift.io/ As for monads themselves, the concept emerges everywhere, with or without Haskell’s particular type classes. Case in point is Swift’s handling of Optional and Optional chaining. | | |
| ▲ | lmm 3 days ago | parent [-] | | People unaware of the laws invent things that are almost monads but break in edge cases. E.g. Scala's collections with flatMap where you can mix and match collection types are almost, but not quite, monadic. Javas Optionals as discussed in parallel threads are similarly almost, but not quite, monadic. And this kind of almost correct implementation is more dangerous than a blatantly incorrect one. |
|
| |
| ▲ | RossBencina 4 days ago | parent | prev | next [-] | | Mathematical rigor is only one type of rigor. I think you can make your point without framing attempts to tame real-world complexity as "broad and handwavy," or deriding people's struggle for understanding as "delusional ignorance." | | |
| ▲ | frumplestlatz 4 days ago | parent [-] | | Placing monads in the same category as MVC, OO, or design patterns is ignorance. Mathematical rigor is also not comparable to whatever sense of rigor might apply to those concepts. “Delusional” might be harsh; I’d go with “confused”. | | |
| ▲ | whstl 4 days ago | parent | next [-] | | Uncalled for. Try to follow the guidelines instead of calling people names. | | |
| ▲ | frumplestlatz 4 days ago | parent | next [-] | | Speaking authoritatively about subjects with which one is unfamiliar is likely to have one’s speech recognized as ignorant and confused. This is not uncalled for, particularly when coupled with a substantive explanation as to why. | |
| ▲ | antonvs 4 days ago | parent | prev [-] | | What about the guidelines for downvotes? If factual comments are downvoted without consequences, then the site becomes nothing but a place for reinforcement of social fads. |
| |
| ▲ | RossBencina 3 days ago | parent | prev [-] | | > Mathematical rigor is also not comparable to whatever sense of rigor might apply to those concepts. The two senses of rigor at hand are comparable at the level of frameworks of human knowledge. Comparable (not equivalent!), for example, in the sense of what these ways of knowing are seeking to know, and how they are seeking to know it. We are discussing software development practice here, so what is it exactly that these two ways of knowing are seeking to know? The way I see it, in the context of software development, the commonality between Monads and a specific design pattern, say MVC, is that they are both tools in the developer's toolkit. Specifically, tools for structuring software abstractions. A bonafide concrete Monad gives guaranteed well defined compositional behavior for a particular class of operations on a particular class of objects. The Monad definition gives an abstraction for composable software abstractions. A design pattern describes a configuration of abstract software elements and/or roles, and a schema for composing these elements and the communications (protocols) between them. A single design pattern often describes a family of potential realisations. A design pattern, when documented properly (as in the PLoPD books), and applied appropriately, can be reduced to a practical solution that is no less robust (in practice) than the employment or definition of an object with a monadic interface. From a practical software development perspective they are of the same kind. From a formal methods point of view the two are different. Monad has a settled mathematical definition, well understood properties, an exists within an established branch of mathematics. Application of the Monad definition to computer programming is supported by a body of established computer science that confers various mathematically proven properties. By contrast, a design pattern does not have a mathematical definition at all, and importantly for this conversation it does not claim to have a definition. A design pattern documents a way of doing things that is known to have worked for multiple past systems. It is literally an abstraction of a common pattern of practice, together with context, recommendations for use, contraindicated scenarios and so on (see my "context" comment elsewhere on this post). This is no more handwavy, and no less apposite, than the guidance given to an apprentice craftsman. Of course there is nothing to prevent someone from reducing a design pattern to a formal definition and attempting to verify properties of interest on it (I imagine this has been done). Most developers today are not equipped to formally define and verify a Monad, or to reduce a design pattern to a formal definition and prove properties on it. Most software systems do not automatically check and enforce the Monad laws. In software practice, there is little between them. They are both tools for organising abstract software structure. |
|
| |
| ▲ | frumplestlatz 4 days ago | parent | prev [-] | | I see that your comment is now downvoted into the negatives. When people are confused by something, they will often blame the target of their confusion instead of admitting to themselves that they don’t understand. | | |
| ▲ | hurril 4 days ago | parent [-] | | You both have good points. But there is monads the mathematical and programmatic concept, and there is also something a little bit handwavy in how these things are incorporated into an application architecture. The latter is what is being used on the one hand in comparison to MVC, etc, on the other. I.e.: a monadic architecture in Haskell is good, but one in Java is going to suck. A sort of half-way point is in The Elm Architecture, which is a sort of deconstructed IO monad. (Writing this as someone with decades of experience in writing monadic architectures.) | | |
| ▲ | yakshaving_jgt 4 days ago | parent | next [-] | | What does a “monadic architecture” look like? I’ve been writing web applications in Haskell for the past decade and all of them are MVC. | | |
| ▲ | hurril 3 days ago | parent [-] | | I am going to interpret your question as one asked in good spirit. I like this book:
https://www.manning.com/books/functional-design-and-architec... | | |
| ▲ | yakshaving_jgt 3 days ago | parent [-] | | > I am going to interpret your question as one asked in good spirit. Thanks. It was. > I like this book I have that book, but I haven't read it. Which part specifically should I look at to understand what you mean by "monadic architecture"? Or do I need to read the entire book first? I'm searching through that book right now, and as far as I can tell, it doesn't mention "monadic architecture" even once. | | |
| ▲ | hurril 3 days ago | parent [-] | | An architecture that consists of monads. | | |
| ▲ | yakshaving_jgt 3 days ago | parent [-] | | That doesn't really tell me anything though. I use monads, and applicatives, and functors, and monoids, semigroups, etc… When you use Hakyll to generate a static site, you use a bunch of monads. But is a Hakyll site a "monadic architecture"? I'm not quite sure how I'd describe it as an architecture — it's really just an imperative program. It's to some degree a bit like a Makefile. A Yesod application on the other hand I would readily describe as MVC, and yet it's all monads all over the place. What about something like The Elm Architecture? Elm provides a bunch of monads (not directly as an abstraction, but through a few specific instances) but its architecture I would describe as perhaps FRP, or unidirectional data flow state machine kinda thing. So that's three examples with clearly distinct architectures, and all three are architectures that "consist of monads". So, I don't really understand what "monadic architecture" means. |
|
|
|
| |
| ▲ | frumplestlatz 4 days ago | parent | prev [-] | | I don’t really understand what a “monadic architecture” is supposed to mean. Haskell’s `Monad` type class is hardly the only possible encoding of a monad. They’re just a simple mathematical construction with useful properties, and — like functors and applicative functors — they emerge everywhere. | | |
| ▲ | hurril 3 days ago | parent [-] | | See, I don't think you don't really understand my point. I said this elsewhere: I have been programming Scala and Haskell for more than 15 years, which I am sure you have as well. This is not ment as a proof of my point as that would be arguing form authority. This is not my intention. But there are more things at play here. What I think you are doing is: well quantum mechanics is just simple mathematical construction and some artithmetic. Is it really? Is it _just_ that? |
|
|
|
|