3 ms·
I haven't tried out many alternatives, but there's something about nested <> that seems to throw me off each time. I wrote a library of monads for C# [1], and
by louthy 12y ago
I haven't tried out many alternatives, but there's something about nested <> that seems to throw me off each time.
I wrote a library of monads for C# [1], and implementing the SelectMany method is a good example of how messy it can be:
public static RWS<R, W, S, V> SelectMany<R, W, S, T, U, V>( this RWS<R, W, S, T> self, Func<T, RWS<R, W, S, U>> bind, Func<T, U, V> project)
{
}
I quite like F#'s alternative syntax for single type generics:
Option<int>
Can be written:
int option
Obviously it's a personal thing, so I doubt I would be able to suggest anything that would change your mind; I just had a quick go at an alternative, and I quite like this:
public static SelectMany R W S T U V ( this self : RWS R W S T, bind : Func T (RWS R W S U), project : Func T U V) : RWS R W S V
{
}
class Thing int
{
}
class Thing T : BaseThing T
{
}
It's moot anyway really, it is what it is. I've just found it cognitively challenging over the years.
[1] https://github.com/louthy/csharp-monad https://github.com/louthy/csharp-monad