3 ms·
I like the way that "Learn You a Haskell" puts it: "If we have a fancy value and a function that takes a normal value but returns a fancy value, how do we fe
by ModernMech 5y ago
I like the way that "Learn You a Haskell" puts it:
"If we have a fancy value and a function that takes a normal value but returns a fancy value, how do we feed that fancy value into the function?"
That's basically all a monad is. If you know what map() does (in Haskell terms, map is a "functor"), then you know what a monad is, as it's just a fancy map().
I'll put it in Rust terms:
let x: Option<u8> = Some(5);
fn foo(x: u8) -> Option<u8> {...}
How do we apply the function foo to x? That's what monads are for.