Functional Programming

ScalaFP: Firsthand With Scala-Cats Monads – #1

In the previous post, we had a look at the reasons behind the monads and how monads can help us design the programs in a functional style. Now we are going to explore some of the monads which are frequently used in the applications but not available within the Scala predefined libraries. We will be exploring the monads which are provided by the scala-cats functional Continue Reading

ScalaFP: Let’s Find The Reasons Behind Monads.

Monads in Functional Programming play an important role but they mostly confuse the beginners. One of the reasons for the confusion is that they mostly have a knowledge of imperative style programming, where they have no idea about function composition and its importance. In the terms of functional programming, the composition is the root where we have a set(Z) and we compose the elements of Continue Reading

Back2Basics: Exception Handling – #2

In our previous blog, we have seen how we can handle exceptions using try/catch and Try block.  In this blog, we will explore how we can handle exceptions using Either. Either, just like a Try, is also a container type which can have one value either Left or Right at a time. We can also use Option to handle exceptions but if an exception occurs returning Continue Reading

Back2Basics: Exception Handling – #1

While building an application, it is common that something might go wrong. What if there is an attempt to divide a number by 0 or fetching the data from the database which does not exist, or reading a file which can’t be located? We need to handle such situations to make sure our application does not go down. Every language provides ways to handle such Continue Reading

ScalaFP: Welcome To The World Of Functors

In functional programming, we have various pillars like Functors, Monads, Applicative and more. Today we will try to explore one of these pillars called Functors. Before moving to functors, first let’s explore function composition: Function Composition:  In this diagram, we have 3 sets called A, B, and C. Set A contains an element called x. Suppose, we need to convert our Set A elements into Set C. Continue Reading

Back2Basics: The Story of Trait – Part 4

In our previous blog The Story of Trait – Part 3, we have discussed the mixin, one of the charming feature of traits. Now we are going to explore chaining of traits. We have seen how can we mix more than one traits into classes. But what would happen if two traits have same method i.e same name and same signature? This is where Multiple Inheritance Continue Reading

Back2Basics: Demystifying Variance

In this blog, we will explore types of variances in Scala. In-variance Co-variance Contra-variance First, let’s talk about Types in Scala. scala> import java.util.ArrayList scala> var ref1: Any = “Hi” ref1: Any = Hi scala> var ref2: String = “Hi” ref2: String = Hi scala> ref1 = ref2 ref1: Any = Hi In the above example, ref1 is of type Any and ref2 is of Continue Reading

Exploring Java 10 using Docker

On March 20, 2018, Java 10 was released and everybody wants to explore Java 10 but not everyone wants to change their development environment. So in this blog, we will be discussing how can we use Java 10 using Docker.

Back2Basics: Limit which classes a Trait can be mixed into!

A Scala trait is just like a Java interface. A trait can be extended by different classes, just the way we do with Java interfaces and also a class can inherit multiple traits, called mixins. To know more about basics of the trait, refer to this blog. But what if we want to restrict mixing of traits to a limited number of classes? Do we have Continue Reading

Back2Basics : Existential types in Scala

In the first blog of the Scala Type System series, I  had put a lot of emphasis on the fact that “Type variables make a very powerful piece of type-level programming”. They appear in a variety of forms and variations. One of the important forms is “existential types”. In today’s blog, I would like to get you familiar with the existential types. Given below is a Continue Reading

ScalaFP: Understanding Monoids In Scala Pragmatically

As we discussed in our previous post, Monoids are semigroups meaning they have properties called closure and associative, along with identity element. So, now our question is, why do we require the identity element? Let’s add this one to our questions which were remaining from our previous post, : How can we use monoids with Scala? Where do we require Monoids? Now let’s answer these questions one Continue Reading

ScalaFP: Let’s Start with Implicit and Scala Cats

In our last blog, we have discussed the Type Class. You can find that blog Here: Type Class. Now we will discuss the Implicit in Scala. Implicit Implicit in Scala refers to either a value that can be passed “automatically”, so to speak or a conversion from one type to another that is made automatically. So we can create the implicit method with the help of Continue Reading

Back2Basics: The Story of Trait – Part 3

In our previous blog The Story of Trait – Part 2, we have discussed that traits can have implementation too and how they behave under the hood. In this blog, we will discuss mixins one of the most charming features of traits. Mixins are the wonderful concept of object-oriented programming. Sadly, some of the mainstream object-oriented programming languages like C++, Java, C#, have not provided Continue Reading

%d bloggers like this: