[dba-VS] C#, monads - must read - don't get mad with them while reading :)

Salakhetdinov Shamil mcp2004 at mail.ru
Wed Jul 8 10:48:12 CDT 2015


 Hi Gustav --

My pleasure! :)

I have almost finished it - reached the 'parsers' part but then I have lost. The author tells it took him more than an year to get through this subject.

For me the most important is the following feature of monads:

<<<
Monads give us a way of dealing with these ‘amplified types’ and allow us to remove the boiler plate. They can help us write declarative programs where what we are trying to achieve is not obscured by the apparatus we need to achieve it. They help with our core problem as programmers, getting complexity under control so that we can reason effectively about our code.
 
From < http://mikehadlow.blogspot.ru/2011/01/monads-in-c2-whats-point.html >  >>>

When applied this feature should allow to write (in C#) the following:

public string getEmployeeStreetName()
{
    return employee.getPerson().getAddress().getStreet().Name;
}

instead of the following:
public string getEmployeeStreetName()
{
    if (employee != null &&
        employee.getPerson() != null &&
        employee.getPerson().getAddress() != null) 
          return employee.getPerson().getAddress().getStreet().Name;
    return string.Empty;
} A very simple use case but you can check your C# to see how much cleaner it will become if you'll apply just one this "trick" provided by monads.

But I'm still to find out (in the articles I've referred) how to program this trick.

Thank you.

-- Shamil

>Wednesday, July  8, 2015 2:35 PM UTC from Gustav Brock <gustav at cactus.dk>:
>
>Hi Shamil
>
>I'm glad you included the last ("or first") link or I would have no idea of what a Monad is and is used.
>
>However, I must admit that this does not fill a whole for me - it soon gets messy or at least hard-to-read code, and I prefer clarity above brevity. But who knows? Suddenly you have a situation where Monads could be the optimum tool.
>
>Thanks! Learned something new today.
>
>/gustav
>
>-----Oprindelig meddelelse-----
>Fra: dba-VS [mailto:dba-vs-bounces at databaseadvisors.com] På vegne af Salakhetdinov Shamil
>Sendt: 8. juli 2015 13:04
>Til: Development in Visual Studio
>Emne: [dba-VS] C#, monads - must read - don't get mad with them while reading :)
>
>
>Hi All --
>
>Must read:   http://ericlippert.com/2013/02/21/monads-part-one/  - ... -   http://ericlippert.com/2013/04/03/monads-part-thirteen/  
>
>See also: http://blogs.msdn.com/b/pfxteam/archive/2013/04/03/tasks-monads-and-linq.aspx
>
>See also (or first):   http://mikehadlow.blogspot.ru/2011/01/monads-in-c1-introduction.html
>
>-- 
>Салахетдинов Шамиль 
>
>_______________________________________________
>dba-VS mailing list
>dba-VS at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-vs
>http://www.databaseadvisors.com


More information about the dba-VS mailing list