In context, I recently discovered functional programming and am trying to incorporate it into an existing Web API solution.
So far I have been reading Functional Programming in C # , and I was trying to create a new controller that could do basic CRUD using the language-ext library.
I run into obstacles because I'm not sure if I support the principles of FP when accessing the database.
Here is the code that I still have - note that I use the Entity Framework Code First, and that for reasons beyond my control I have to use surrogate keys with type Guid , so many operations related to the method:
The problem is that I'm not sure how to signal that GetWidgets and UpdateDatabase unclean. I came across the concept of an I / O monad, but I donโt think that such a thing exists in the language-ext API, and I donโt have enough knowledge about FP to work if there is an equivalent solution or name for it.
EDIT: I found some documentation on monads on a similar, but older project by the same author language-ext . It is interesting to note that this project actually includes an I / O monad, in which it recognizes that
Monk IO can be seen as unnecessary in C #, where everything has side effects ...
source share