3 ms·
I should have issued a warning against trying to educate me. But I also know that explaining monads is like irresistible crack for those in the know. I'm half
by recursive 2y ago
I should have issued a warning against trying to educate me. But I also know that explaining monads is like irresistible crack for those in the know. I'm half-convinced I have a learning disability that specifically affects my ability to comprehend monads. Years ago, I gave it a serious attempt. At this point, I think I'll be satisfied to never quite get it. I totally understand Option, (I think?) but I completely fail to understand what that has to do with side effects. I'm ok with this. Thanks for the effort anyway. I don't understand what ResultWriter is or could be. I don't understand what the white lie is.
- williamcotton 2y agoThe white lie is that in functional programming a function only takes a single argument and uses currying to mimic multiple arguments. Like this in JS: let f = (x) => (y) => x * y; let p = f(2)(3); Is this in F#: let f x y = x * y let p = f 2 3 A ResultWriter is just a wrapper type that takes a tuple of a Result and a list of log messages. The side effects are you can write imperative code that works with normal values but does exception handling and log messaging behind the scenes and without it cluttering the task at hand. So you write some functions that return either Success wrapping a value with some good news log message or an Error with some bad news log message. Then with a bind function or especially with a computation expression in F# you can use those functions without dealing with the exceptions and log messages until after you’ve completed all of the steps. Unless you’re using a language that supports this kind of monad design pattern it won’t really make any sense!
- ashton314 2y agoWell, actually, it's really just like a burrito…