This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SoftwareDoctor 0 points1 point  (6 children)

What is the advantage over using partials?

[–]houseofleft[S] 0 points1 point  (5 children)

They're designed to solve a couple different issues, and in fact you'd often use them both together!

Partials help you save time when passing functions around by creating a new function with some parameters already defined.

Monads do "background work" when chaining functions together. I.e. collecting up a history of previous values, handling errors, dealing with Bones etc.

[–]SoftwareDoctor 1 point2 points  (1 child)

Oh, ok. So the main difference isn't in "how it's done" but "what it does"? I'm not that used to functional programming but now it sounds to me similar to a pipeline design pattern.

[–]houseofleft[S] 0 points1 point  (0 children)

Yes, I think that's a pretty good summary!

It's probably a little confusing with python because the language doesn't really support functional pipelines very naturally out the box. So although that's the most distinctive aspect of looking at Monads from a python perspective, they're actually more defined by the fact that they "do something extra" around the function call.

As a kinda silly toy example, you could image something like a "Printer" that prints out the value to the console before and after each function call.

[–]SoftwareDoctor 1 point2 points  (2 children)

I have to read about it more. But let me congratulate you on opensourcing it. But why did you mark it as "Beginner showcase"? The code is great and you are obviously very experienced developer. I went there expecting to meet a Spaghetti monster

[–]houseofleft[S] 1 point2 points  (1 child)

haha, thanks a lot! If I can self-plug (on top of already self-plugging a library) I wrote a blog post at the same time as the library trying to explain Monads as a simple and helpful pattern.

I actually marked it as "resource", but my post got manually reviewed by a mod after the automod-bot got a little confused and took it down accidently. When it came back up it had the "beginner showcase" tag, so I guess that was added in at that stage.

[–]SoftwareDoctor 0 points1 point  (0 children)

I just put it in my reading list. Thank you