3 ms·
I'm sorry but almost every sentence in your comment is wrong: > the simple use of "Either" does not instantly qualify something as "monadic" The composition o
by Peaker 15y ago
I'm sorry but almost every sentence in your comment is wrong:
> the simple use of "Either" does not instantly qualify something as "monadic"
The composition of calls to functions that return Either as to implement exceptions is exactly Monadic.
> you know what else is monadic? NULL pointers. oh wait, you know what else is monadic? unix pipes. you know what else is monadic? CPP. really old shit.
Only if very loosely interpreted. NULL pointers are not monadic. Maybe types are monadic (and also considered an "Exception monad").
Unix pipes are not monadic in a meaningful way (they don't support the monadic operations), but approximations/implementations of them can be.
In what sense is the C preprocessor monadic?
> just because the word monad isn't everyday english doesn't make it a cool or even an interesting concept. it's just an awkward abstraction for something everyone already intuitively understands.
Cool and interesting are subjective concepts. I find them pretty cool, in the sense of capturing one of the most general patterns in code I've ever seen captured.
In what sense are monads an "awkward" abstraction?
> monads were invented for the sole purpose of giving haskell a programmable model for IO, that's it. it's just a concept that's only useful for haskell programming, everything else already has an intuitive programming model for IO.
That's completely false. Monads don't have anything to do with IO, it's just a particular instance of them. I can make a list of Bananas, does a list have anything to do with bananas?
Monads are immensely useful for many things. When using Haskell, I can use a very large set of combinators that work with any monad, to compose Parsers, functions, Maybe values, and various other types.
This means I can re-use a lot more code and vocabulary. When I learn an API, I don't have to read the documentation and types of 30 specific combinators. Instead, the library just says: "This type has a monad instance" -- and I can use my existing knowledge to work with it.
> it's like building up integers to be this crazy complicated concept and then saying Exceptions are integers. awesome, good job, you've just found an equivalence, here's a pat on the back
No -- the semantics of statement composition in the face of exceptions is the only valid instance of Monad for Either values that encode them. It's not like you have to go very far to find this equivalence. Integers are not usefully equivalent to exceptions.
> i guess i should expect these kinds of vacuous observations given all the BufferedManagerFactorySingleton crap code java slaves write.
This observation is actually one of the first uses of monads in the Haskell crowd, not in the Java crowd.
> you know what else is monadic? state machines. you know what else is monadic? imperative programming. wait wait wait! you know what else is monadic? JAVA ITSELF head explodes
I think you've completely missed the point of Monads.
Take a look at:
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html http://haskell.org/ghc/docs/latest/html/libraries/base/Contr...
I can use any of the combinators in there with any monad instance. The fact I can use them with Either values makes Either value composition behave exactly like exceptions.
This is not a "neat observation" -- it is something people routinely use, plentifully.
- rian 15y agolook dude, you're right. monads are freaking awesome. it's because a lot of things in CS can be shown to "be monads", it's called turing completeness. http://en.wikipedia.org/wiki/Turing_completeness http://en.wikipedia.org/wiki/Turing_completeness unix pipes as monads: http://okmij.org/ftp/Computation/monadic-shell.html http://okmij.org/ftp/Computation/monadic-shell.html cpp as a monad: http://conal.net/blog/posts/the-c-language-is-purely-functional/ http://conal.net/blog/posts/the-c-language-is-purely-functio... monads invented for IO / functional impurity: http://homepages.inf.ed.ac.uk/wadler/papers/monads/monads.ps.gz http://homepages.inf.ed.ac.uk/wadler/papers/monads/monads.ps... "This is not a "neat observation" -- it is something people routinely use, plentifully." ...in haskell and who are you to say that integers are not usefully equivalent to exceptions??? have you ever heard of errno? i don't have exceptions or monads in bf, just pointers. i need an equivalence so that i can feel smarter when i code bf. and if you dare say that bf isn't a useful programming language then you better stop coding in java...
- Peaker 15y agoMonads and Turing Completeness have very little to do with each other. Unix pipes as monads is trying to create an analogy (an imprecise one) between unix pipe operations and monadic operations. The monadic laws do not hold with unix pipes, so the analogy is pretty weak. You might want to re-read Conal's "the c language is purely functional" because it makes no claim about cpp being a monad, at all. Let's look at the monad instances/examples listed by the Wadler paper, in order: * The identity monad * The strictness monad * The state monad * Filters (MonadZero) * Monad Morphisms Under "More Monads": * Parsers * Exceptions * Input and Output Are you trying to use this paper to establish that monads were invented exclusively for I/O and now perverted to describe exceptions? Note how exceptions are listed as an example use of monads before I/O. > and who are you to say that integers are not usefully equivalent to exceptions??? have you ever heard of errno? errno is not an exception mechanism. You have to indicate, in-band, that there's an error result, then check for that result, and then use errno as well, to implement exceptions. Whereas the Either monad itself implements both the in-band encoding of errors, and the caller's error-check and propagation.