|
|
|
|
|
by chrisseaton
2374 days ago
|
|
> Sort of like a monad, even! Yes that's it - they're monads! Either is also a monad, and you can store error information in the other side if you want, but a good thing about Maybe is it could transparently store the error information, and produce it when debugging, rather than baking it into the normal runtime semantics. > you basically have to trust that callers respect your contract with these types This is table-stakes for a dynamic language like Ruby, though. Yes people can do anything, but usually they follow the rules they're given. |
|
> Yes people can do anything, but usually they follow the rules they're given.
Sure, but the primary advantage remains in not having to trust that, not having to write tests for it, and communicating the contract itself inside the code it restricts. I’m just honestly not sure what purpose they serve here, and why you’d bother to call them monads when what you really seem to want is the stored debugging information.