4 ms·
"Monads, applicatives, functors, and monoids are different algebras. OK. That's really helpful, actually. (At least, I suspect it's going to be really helpful a
by dllthomas 12y ago
"Monads, applicatives, functors, and monoids are different algebras. OK. That's really helpful, actually. (At least, I suspect it's going to be really helpful after I've thought about it for a few days.)"
I think it's not quite accurate. They're all algebraic structures, but an "algebra" is a more specific thing and I don't think they are algebras specifically (except maybe monoid?).
http://en.wikipedia.org/wiki/Algebraic_structure http://en.wikipedia.org/wiki/Algebraic_structure
http://en.wikipedia.org/wiki/Algebra_%28ring_theory%29 http://en.wikipedia.org/wiki/Algebra_%28ring_theory%29
"But monads are the way to do sequencing? Only if you insist on putting yourself in a functional straight-jacket that's so tight that you cannot escape."
"Chaining actions with bind is the only way to combine actions" in Haskell is more strongly motivated by keeping things sane in the face of non-strict semantics than by a "functional straight-jacket". In fact, it wasn't the way Haskell initially did IO.
"Then, yes, you do sequencing via monads because you don't have any other way to do it. But if you're a pragmatist rather than an ideologue, it seems more reasonable to just do sequence by doing things in sequence, rather than forcing yourself to do unnatural contortions."
"You have to do things my way, or you're not pragmatic!" seems to be your dogma.
Reifying actions in a way that lets you talk about them in the same way you talk about the rest of your data is sometimes a very useful thing.
- AnimalMuppet 12y ago> "Chaining actions with bind is the only way to combine actions" in Haskell is more strongly motivated by keeping things sane in the face of non-strict semantics than by a "functional straight-jacket". OK, if you have non-strict semantics (by which I presume you mean non-sequential), then you need some way to make things sequential when they have to be, and you have no ordinary (non-jumping-through-hoops) way to make them so. > "You have to do things my way, or you're not pragmatic!" seems to be your dogma. Shoe's on the other foot. Haskell's the one that insists that I have to do it Haskell's way. I complain, and you accuse me of being dogmatic. Doesn't work that way. But I suppose you'd say that I have the choice to not use Haskell, so stop complaining. And in fact, I take that choice, precisely because I consider the language's dogmatism to be less pragmatic (and therefore useful) than a multi-paradigm approach.
- dllthomas 12y ago"if you have non-strict semantics (by which I presume you mean non-sequential)" http://en.wikipedia.org/wiki/Strict_programming_language http://en.wikipedia.org/wiki/Strict_programming_language "Haskell's the one that insists that I have to do it Haskell's way." ... when you're writing Haskell. But I am the one who sometimes wishes I could manipulate actions in that way when I am writing C. "But I suppose you'd say that I have the choice to not use Haskell, so stop complaining." I'm saying that it obviously doesn't make pragmatic sense to require things in contexts where they don't make sense, but that 1) some things can make sense in more contexts than you might think, and 2) that you would do well (for pragmatic reasons) to actually learn about this stuff before deciding you don't need it.
- AnimalMuppet 12y ago> I'm saying that it obviously doesn't make pragmatic sense to require things in contexts where they don't make sense... Absolutely. > you would do well (for pragmatic reasons) to actually learn about this stuff before deciding you don't need it. I keep learning about it. I still haven't seen any need for it. But then, my whole career is in a context where it doesn't make sense...
- dllthomas 12y ago"But then, my whole career is in a context where it doesn't make sense..." Well, like I said, applicability can be occasionally surprising. What is your background like?
- AnimalMuppet 12y agoEmbedded systems. It's all about driving external hardware, and much of it has to be sequential.
- dllthomas 12y agoGotcha. I certainly agree (albeit with low confidence - never sure what someone somewhere has done) that would make no sense as a GHC target. But that doesn't mean the concepts necessarily have no applicability. As I said, I've found myself wishing for some of Haskell's capabilities while writing C. That said, when the usefulness is subtle it's probably not the place to start. I'd dig deeper into some of the other monads first and basically forget about IO until you actually want to code in Haskell. Incidentally, you can write Haskell to write your embedded C: https://hackage.haskell.org/package/atom https://hackage.haskell.org/package/atom I haven't actually played with it, but understand it's used in production.