Further proof for my personal conviction that C# is a very interesting, progressive language which masquerades as a Java clone.
I once copied the style of a maybe monad using LINQ - the WinRT apis lack a "FileExists?" method, so I used LINQ to search a directory's contents for a filename. An IEnumerable of size of zero represented None, and size one represented Some.
Unfortunately, a simple try/catch around an attempt to open the desired file was more efficient and clearer to understand.
You should use try/catch; branching would imply a race condition in a multithreaded environment (what if another process deletes the file between the check and the use of the file?).
I once copied the style of a maybe monad using LINQ - the WinRT apis lack a "FileExists?" method, so I used LINQ to search a directory's contents for a filename. An IEnumerable of size of zero represented None, and size one represented Some.
Unfortunately, a simple try/catch around an attempt to open the desired file was more efficient and clearer to understand.