Re:Microsoft takes .NET open source and cross-platform
by rjbwork on Thursday November 13, 2014 @01:35AM
(#8600233)
What would you have used for generic arguments? I think they work fine, and make use of Func<T> often.
Re:Microsoft takes .NET open source and cross-platform
by louthy on Thursday November 13, 2014 @09:50AM
(#8601746)
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.
Annoyingly F# brought them along for the ride too, although you rarely have to explicitly write them.