public interface IFunctor<TSelf, T> where TSelf : IFunctor<TSelf, T>
{
IFunctor<USelf, U> Map<USelf, U>(Func<T, U> f) where USelf : IFunctor<USelf, U>;
}
public readonly struct Maybe<T> : IFunctor<Maybe<T>, T>
{
// ...
IFunctor<USelf, U> IFunctor<Maybe<T>, T>.Map<USelf, U>(Func<T, U> f)
{
// Should actually apply the func, but just for demonstration rn
return new Maybe<U>();
}
}
public interface IFunctor<TSelf, T> where TSelf : IFunctor<TSelf, T>
{
IFunctor<USelf, U> Map<USelf, U>(Func<T, U> f) where USelf : IFunctor<USelf, U>;
}
public readonly struct Maybe<T> : IFunctor<Maybe<T>, T>
{
// ...
IFunctor<USelf, U> IFunctor<Maybe<T>, T>.Map<USelf, U>(Func<T, U> f)
{
// Should actually apply the func, but just for demonstration rn
return new Maybe<U>();
}
}