Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Diving into Scala Cats – Functors

In this, we’ll take a look at Functors, which allow us to operate on values inside containers without having to know any of the implementation details of the containers themselves.

  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Diving into Scala Cats – Functors

  1. 1. Presented By: Mansi Babbar
  2. 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Respect Knolx session timings, you are requested not to join sessions after a 5 minutes threshold post the session start time. Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Mute Please keep your window on mute Avoid Disturbance Avoid leaving your window unmuted after asking a question
  3. 3. Agenda What are Functors? 03 Functor Laws 04 Functor Type Class and Instances Defining a Functor 02 01 05 Functor Syntax
  4. 4. ● Functor can be simply something that can be mapped over. ● Provides a base class for Mappable types. ● Allow us to operate on values inside containers without knowing implementation details of the containers themselves. What are Functors?
  5. 5. Scala has no native base type/trait to represent the following generically. However, using cats’ Functor type class we can write a generic method for every mappable type like List, Option, Future, etc. Why Functors?
  6. 6. Defining a Functor... A Functor is a type F[A] with a map operation (A => B) => F[B] :
  7. 7. Defining a Functor...
  8. 8. Functor Laws ● Identity: If we pass an identity function to the Functor map method, then the Functor must get back the original Functor ● Composition : Mapping with two functions f and g is the same as mapping with f and then mapping with g
  9. 9. Functors with Lists
  10. 10. Functors with Lists
  11. 11. Functors with Options
  12. 12. Functors with Options
  13. 13. Functors with Futures
  14. 14. Functors with Futures
  15. 15. Functors with Futures
  16. 16. Functor Syntax We could add a map method to our own types using the concept of syntax or extension methods. This concept is implemented using implicit classes and allows us to write…) instead of Functor[F].map(order)(…).
  17. 17. Earlier case - Defining a Functor
  18. 18. Functor Syntax
  19. 19. References ● ● ● -semigroups/ ● -monoids/ ● -functors/