Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Deep Dive into Monads and Cats Lib

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Chargement dans…3
×

Consultez-les par la suite

1 sur 19 Publicité

Deep Dive into Monads and Cats Lib

Télécharger pour lire hors ligne

In this session, we'll demonstrate the Use case specific examples in Scala using Cats and Monads. The focus will be on simplifying the coding standards and adopting the best practices for providing abstractions for functional programming.

In this session, we'll demonstrate the Use case specific examples in Scala using Cats and Monads. The focus will be on simplifying the coding standards and adopting the best practices for providing abstractions for functional programming.

Publicité
Publicité

Plus De Contenu Connexe

Similaire à Deep Dive into Monads and Cats Lib (20)

Plus par Knoldus Inc. (20)

Publicité

Plus récents (20)

Deep Dive into Monads and Cats Lib

  1. 1. Presented By: Humera Ahmad Kuldeepak Gupta Software Consultant Knoldus Inc Deep Dive into Monads and Cats Lib
  2. 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time! Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call. Avoid Disturbance Avoid unwanted chit chat during the session.
  3. 3. Our Agenda Introduction to Scala Cats 01 Type Class Components 02 Semigroups 03 Monoids 04 05 Monads
  4. 4. Introduction to Scala Cats
  5. 5. LEARN NOW c Scala Cats ● A Library that provides the abstraction for functional programming in scala. ● Goal is to provide a foundation for an ecosystem of pure, typeful libraries to support functional programming in Scala applications. ● The name is a playful shortening of the term category, from “Category Theory”
  6. 6. LEARN NOW ● Fast - It provides lightweight fibers for asynchronous, highly concurrent applications ● Reliable - Keeps your application up and running under high resource contention. ● Ecosystem - Provides a thriving ecosystem of streaming frameworks, database layers, HTTP Servers and much more! ● Community - Cats Effect is OS software maintained by Typelevel community.
  7. 7. Type Class Components
  8. 8. Type Class Components Type Class Type Class Use Type Class Instance Interface Objects Interface Syntax
  9. 9. LEARN NOW c Type Class ● Type classes are a pattern in programming originating in HASKELL. ● The intent is to extend the existing libraries with new functionality. ● Also, don’t need to use traditional inheritance, and also without altering the original library source code. ● API represented by trait with atleast one type parameter.
  10. 10. LEARN NOW c Type Class Instances ● Used to provide an implementation of the type class for a specific type. ● Instances are defined by creating concrete implementations of the type class and tagging them with the implicit keywords. ● These instances are also known as implicit values.
  11. 11. LEARN NOW c Type Class Use ● Simplest way of creating an interface that uses a type class is to place in a singleton object. ○ To use the object, just import any type class instance. ● Alternative to Singleton objects, use extension methods to extend existing types with interface methods ○ To use syntax, import it alongside the instances for the types needed.
  12. 12. Semigroups
  13. 13. LEARN NOW c Semigroups ● In mathematics, It is an algebraic structure consisting of a set together with an associative binary operation ● A generic type with a binary operation and satisfying associativity. Example trait Semigroup[T] { def combine(x: T, y: T): T }
  14. 14. Monoids
  15. 15. LEARN NOW c Monoids ● An algebraic structure with a single associative binary operation and an identity element. ● Let’s make it easier: It allows us to add or combine values. Working with lists, adding values or concatenating strings. Example trait Monoid[T] extends Semigroup[T] { def empty: T }
  16. 16. Monads
  17. 17. LEARN NOW c Monad ● Common abstraction in Scala ● An abstraction that allows us to represent sequences of operations within the context such as a List, an Option, Future, etc. ● Definition of Monad: trait Monad[F[_]] { def unit[A](val: A): F[A] def flatMap[A, B](value: F[A])(func: A => F[B]): F[B] }
  18. 18. Demonstration
  19. 19. Thank You !

×