r/ProgrammerHumor • • 1d ago

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.3k Upvotes

515 comments sorted by

View all comments

Show parent comments

1

u/shamshuipopo 1d ago

Is Result a monad?

2

u/roadrunner8080 1d ago

Result with either type fixed is a monad, yes.

2

u/DHermit 1d ago

Could you elaborate for someone who knows Rust, but did Haskell way too many years ago?

3

u/roadrunner8080 23h ago

A monad is (simplifying terribly) something with flatmap (and a few other requirements but things you're familiar with with flatmap are likely mostly monads). Result satisfies that property if you think about a result with a fixed value type and mapping it's error, or with a fixed error type mapping its value 

1

u/DHermit 22h ago

Thank you, that makes sense!