7
Functors and Monads
Moving from higher-order functions and delegates, we step into the world of functors, key players in functional programming. They allow us to work with wrapped values, such as lists or computational outcomes, in a structured way. This chapter explores the following:
- Functors
- Functor laws
- Applicative functors and laws
- Monads and monad laws
As always, the following are three self-check tasks to help you understand the existing knowledge of functors and monads.
Task 1 – Functor usage
Given a Result<List<Tower>, string> type that represents a list of towers, where Tower is a class containing properties such as Id, Name, and Damage, the task is to use the functor concept to apply a function to each tower that appends “(Upgraded)” ...
Get Functional Programming with C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.