4 ms·
Implementing monads will be convoluted, using them is relatively easy. It wouldn’t change any of the existing code, but it would allow you to write a function l
by empath75 8y ago
Implementing monads will be convoluted, using them is relatively easy. It wouldn’t change any of the existing code, but it would allow you to write a function like this:
fn double_inner<M: Monad<u64>>(m: M) -> M {
m.bind(|x| M::unit(x * 2))
}
Which takes anything wrapping an integer and doubles it, whether it’s an option or result or iterator.