3 ms·
I posted that because I think it's the best you're going to get. Monads can be two things: (1) a concept in category theory, (2) a rough implementation of that
by seagreen 10y ago
I posted that because I think it's the best you're going to get.
Monads can be two things: (1) a concept in category theory, (2) a rough implementation of that concept in a programming language.
If you want to learn about monads from the category theory perspective, great! This is really hard though, I wouldn't recommend it for most people (and haven't really even succeeded myself).
If you want to learn about a specific programming language's implementation of monads, you will naturally have to know how that language works. This road is far easier than category theory, but still requires knowing (for Haskell) what a typeclass is, what a higher-kinded type is, etc.
It sounds like you want an explanation without prereqs from either category theory or Haskell. If you google for monad tutorials you will find dozens of quick explanations, but I personally don't think this is a good way to actually understand them.
- jnordwick 10y agoDescribe monads to Lisp, Scheme, APL person. You can do that with the y-combinator but why not monads?
- tel 10y agoBecause these languages lack a way of discussing something at the right "higher order" as Monads. You can implement them, but there's no word for the kind of thing a monad is. There's not even a real word for a type. You need types. Then you need "higher order types" or parameterized types. Then you need a way to discuss a common set of operations which appear repeatedly for some of these parameterized types and it can't be OO-like. You can exemplify the operations in, e.g., Lisp, but you have a hard time "talking about" the thing. --- In Scheme, monads are the answer to the following question: The functions (define (pure a) (list a)) and (define (join ls) (foldl append (list) ls)) are related to lists in the same way that (define (pure a) (lambda (k) (k a))) and (define (join z) (lambda (k) ((z k) k))) is related to CPS-transformed programs. What is the commonality?
- deleted 10y ago[deleted]
- jnordwick 10y ago> is related to CPS-transformed programs. What is the commonality? ?? Even when I understand the code (Scheme at least this time), never ask a Haskell person to explain something. There is something genetic that causes them to drop into overly academic descriptions.
- vertex-four 10y agoThe issue is that Haskell is inherently a language in which you're not programming anything that maps particularly well to the machine you're actually running it on. As a result, Haskell developers never actually talk in terms of what a program does on the machine, they talk in terms of what it does in their abstract model of computation.
- tel 10y agoOn the other hand, what I'm talking about could apply to many different machine models.
- tel 10y agoThis is sort of what I'm getting at, though. Haskell gives you the language to talk fluently about everything I was writing. If you use it enough it becomes second nature and these kinds of higher order concepts are easy. Monads are easy. In languages which lack the tools to make it easy to talk about this stuff it's hard to say these things without sounding like a loon. The only reason I sound academic is that the simple language I'm used to using has been denied.
- gizmo686 10y agoHere is monads in JavaScript https://curiosity-driven.org/monads-in-javascript https://curiosity-driven.org/monads-in-javascript
- kazinator 10y agoHere you go, monad explanation in CLOS: http://www.kylheku.com/cgit/lisp-snippets/tree/monads.lisp http://www.kylheku.com/cgit/lisp-snippets/tree/monads.lisp Apologies for there not being a use example for the state transformer monad/comprehension. I can whip one up if needed.