3 ms·
Monads aren’t as special as macros though, all you need is functions and higher-kinded types. The rest is carefully crafting a lawful monadic API, which is some
by quchen 9y ago
Monads aren’t as special as macros though, all you need is functions and higher-kinded types. The rest is carefully crafting a lawful monadic API, which is something you could probably do in most languages (but none of the standard ones have kinds other than *, if even that). Monads are a fairly simple (to implement and use) but strange (to learn to appreciate) abstraction, nothing more.
You can leave away higher-kinded types if you leave away types altogether, but I don’t think anyone has had a practical benefit from a monadic effects system or transformer stack in e.g. Javascript. I’m not even sure the plain »monad« concept even exists as an abstraction instead of in docstrings.
- KirinDave 9y ago> Monads aren’t as special as macros though, all you need is functions and higher-kinded types. The rest is carefully crafting a lawful monadic API, which is something you could probably do in most languages (but none of the standard ones have kinds other than *, if even that). Monads are a fairly simple (to implement and use) but strange (to learn to appreciate) abstraction, nothing more. I don't really see what you're saying here. I didn't mean to equivocate the structures except in terms of their "alien-ness". But Monads are "special", in that literally everyone uses them but almost never sees them from the "outside" unless they're using a language that offers techniques to model them. Writing Javascript? You're in a monad with helper tools of a specific type. Writing C? Same deal, different shapes. Lisp Macros do something different (and I alluded to this with the "meta-syntactic" mention), but similarly change the thought process from "how do I write this logic" to "how do I describe this logic". > . I’m not even sure the plain »monad« concept even exists as an abstraction instead of in docstrings. Since they are annihilated in the Haskell runtime as well that shouldn't be terribly surprising. It's a modeling technique to build programs algebraically. It's like asking if Generics exist at runtime. They do inasmuch as they are relevant to the interpretation of the program.
- quchen 9y agoThe key insight is that all languages have monads, but very few have monad. It’s up to the programmer to see the pattern in e.g. Javascript. But other than having higher kinds there’s not much that keeps most languages from having them the same way e.g. Haskell has. The »plain monad« part was directed at Javascript, not Haskell. Haskell, like JS, can work perfectly fine without monads, but it still works perfectly fine with them ;-)
- KirinDave 9y agoHow did Haskell do IO effects before monadic computation? I ask because any such influence predates my exposure to the ecosystem.
- dietrichepp 9y agohttp://stackoverflow.com/questions/17002119/haskell-pre-monadic-i-o http://stackoverflow.com/questions/17002119/haskell-pre-mona... main :: [Response] -> [Request]
- quchen 9y agoEven without knowing about monads, you can simply implement »bindIO« and »pureIO«. That’s what most other languages do – they have bindMaybe, bindList, bindAsync, …