Successfully reported this slideshow.
Your SlideShare is downloading. ×

Getting started with FP IO

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Understanding concurrency
Understanding concurrency
Loading in …3
×

Check these out next

1 of 15 Ad

Getting started with FP IO

Download to read offline

In the course, I will discuss how the IO comes in the scenario and then will discuss the difference between IO (cats-effect, Monix, ZIO) and Future.

In the course, I will discuss how the IO comes in the scenario and then will discuss the difference between IO (cats-effect, Monix, ZIO) and Future.

Advertisement
Advertisement

More Related Content

Similar to Getting started with FP IO (20)

More from Knoldus Inc. (20)

Advertisement

Recently uploaded (20)

Getting started with FP IO

  1. 1. Presented By: Yash Gupta Getting started with FP IO
  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 01 03:35 PM Problem 02 03:45 PM Solution 03 03:55 PM Introduction to IO 04 04:00 PM Demo
  4. 4. Problem Statement Imagine you are developing an application that accesses the lists of flights from several flight providers. Now you need to log the best flight that has the lowest price and least stoppages, the cheapest flight, and the fastest flight from the lists of flights. You’d like to write tests to ensure this happens as expected. How would you implement this? Conditions: ● There should be no Side-effects ● It should be Referential transparent ● It should be asynchronous and scalable ● It should handles the exceptions
  5. 5. Problem Statement Imagine you are developing an application that accesses the lists of flights from several flight providers. Now you need to log the best flight that has the lowest price and least stoppages, the cheapest flight, and the fastest flight from the lists of flights. You’d like to write tests to ensure this happens as expected. How would you implement this? Conditions: ● There should be no Side-effects ● It should be Referential transparent ● It should be asynchronous and scalable ● It should handles the exceptions The Future
  6. 6. Problem Statement Imagine you are developing an application that accesses the lists of flights from several flight providers. Now you need to log the best flight that has the lowest price and least stoppages, the cheapest flight, and the fastest flight from the lists of flights. You’d like to write tests to ensure this happens as expected. How would you implement this? Conditions: ● There should be no Side-effects ● It should be Referential transparent ● It should be asynchronous and scalable ● It should handles the exceptions The Future
  7. 7. Effects/side-effects A function or expression that alters the status of something outside of its local context is known as a side-effect. Example: -> It can just be printing to the terminal, calling a database, or reading and writing files. Referential Transparency Purely functional languages have the feature that expressions are evaluated to the same result every time and that the expression can be substituted by its result without altering the way the programme behaves. Let me give you the examples of both.
  8. 8. Why not Future? Previous conditions: ● There should be no Side-effects ● It should be Referential transparent ● It should be asynchronous and scalable ● It should handles the exceptions
  9. 9. Why not Future? Previous conditions: ● There should be no Side-effects ● It should be Referential transparent ● It should be asynchronous and scalable ● It should handles the exceptions Letʼs see how
  10. 10. Why not Future? Previous conditions: ● There should be no Side-effects ● It should be Referential transparent ● It should be asynchronous and scalable ● It should handles the exceptions Because Your program eagerly evaluates Future value (i.e., it starts their execution as soon as it initialise them)
  11. 11. So, Why IO??
  12. 12. So, Why IO?? Because ● It has an alternative way to represent side effects lazily rather than eagerly ● You’ll create a description of your computation (full control on execution) ● Can run asynchronous ● Due to clear separation between description and execution it is referentially transparent
  13. 13. So, Why IO?? Because ● It has an alternative way to represent side effects lazily rather than eagerly ● You’ll create a description of your computation (full control on execution) ● Can run asynchronous ● Due to clear separation between description and execution it is referentially transparent So, An IO is a data structure that represents just a description of a side effectful computation. Since IO values are unaltered and pure, they maintain the transparency of references and can be used in functional programming.
  14. 14. Demo
  15. 15. Thank You ! Get in touch with us: Scala Studio

×