I'm fairly new to Rust, and as a project to make my hands more used to it, I decided to implement a library about category theory and functional programming in general. Long story short, there is a trait called Monad
:
pub trait Monad {
// Associated types and functions here
}
And in rust, Option
s are Monads, so I went like this:
impl<X> Monad for Option<X> {
// Implementation here
}
Everything's working properly so far. I decided to add a special Monad called Identity
Monad, which is a famous and handy one:
type Identity<A> = A;
impl<X> Monad for Identity<X> {
// Implementation here
}
And right there, I get this error: conflicting implementations for Option<_>
. Now I have read this SO post, and it makes sense for that use case, but about mine, as far as I can think through, since Identity
is a type (not a trait) it may never be the "Option
". Can anyone let me know about why's that happening and what I can do for it?