Author: Prakhar

Composing and Chaining Effects together in ZIO

Reading Time: 3 minutes Introduction to ZIO ZIO is a library for asynchronous and concurrent programming that is based on pure functional programming. It combined with Scala help us to develop applications that are purely functional, asynchronous, type-safe, resilient, and testable. At the core of ZIO is ZIO data type which is defined as: ZIO is lazy! The difference between ZIO and procedural programming is quite straightforward. In the Continue Reading

Currying in Scala for complete Beginners

Reading Time: 2 minutes What is Currying? Currying simply means converting a function taking more than one parameter can be into a series of functions with each taking one parameter. Example: As we can see, a function that takes 3 parameters is converted into a series of function calls taking one parameter each. The type of add is (Int, Int, Int) => Int [<function3>] The type of curriedAdd is Continue Reading

Know About Partial Functions in Scala under 3 Minutes

Reading Time: 3 minutes Functions and methods are essential components of programming. They help us to process input and provide us with output. In this blog, we will learn about partial functions through examples in Scala. Note: Do not confuse it with partially defined functions. What are partial functions? In English, “partial” means something which is not complete. Similarly, a partial function is a function applicable only for a Continue Reading

Partially Applied Functions in Scala

Reading Time: 2 minutes What is “partially applied” Partially applied functions are an expression in which we do not supply all the arguments needed by the function. Instead, we supply some of the needed arguments only. In Scala, whenever we invoke a function by passing all the needed arguments, we say that we have “applied” that function onto the arguments. Now what we mean by the term partially applied Continue Reading

What is a Type Class And How To Create Them In Scala

Reading Time: 2 minutes What are Type Classes A type class is an interface that defines some behavior. Simply put, it is a programming technique that we often use to add new behaviors to existing user-defined data types without altering the source code. Need for Type Class While working on projects we often feel the need to add new behaviors to our user-defined types. A naive way to do it is Continue Reading

Implicit Classes in Scala- Their Uses and How to create them?

Reading Time: 2 minutes What is an implicit class An implicit class in Scala is a normal scala class but with an implicit keyword before it. They allow the user to add methods to exiting classes and use them as if they belong to those classes. The feature is available since Scala 2.10. This is how we declare an implicit class in Scala: In short, they allow us to Continue Reading

Scala Constructor Arguments and what difference does it make

Reading Time: 3 minutes Introduction to Scala constructors Scala constructors might feel a little unusual especially if we come from a more verbose language. Constructors in Scala are of 2 types: Primary Constructor Auxiliary Constructor This is how we declare a primary constructor in Scala: In this blog, we will see different ways to pass arguments in the primary constructor and how it affects their visibility. Passing arguments in Continue Reading