back2basics

Pure vs. Impure values

Reading Time: 2 minutes In FP, we frequently talk about purity & impurity of values.In this brief post, we’ll brush up our concepts of the same, along with some examples. What could an impure value be? As we can see, a value is pure, if it conforms very strictly to its type. In case of pureFunctionValue the declared type said that it was a function which takes an Int Continue Reading

Introduction to Akka Streams – Part 1

Reading Time: 4 minutes Akka Streams is a library that is used to process and transform a stream of data. In this blog, I’ll be discussing the components of Akka Streams. Akka Streams is an implementation of Reactive Streams and uses bounded buffer space, and this property is known as boundedness. To use Akka Streams, add the below dependency in your build.sbt:

Extracting values using Regular Expressions

Reading Time: 2 minutes Regular expression is a sequence of characters that define a search pattern. Regular expressions are used to find particular sequences in a string or is used to extract value from a string. Fields of application range from validation to parsing/replacing strings, passing through translating data to other formats and web scraping.

monads

Back2Basics: Exception Handling – #4

Reading Time: 3 minutes In the previous series of blogs, we have seen how we can do error handling in Scala. In this blog, we will explore yet another way of handling exceptions using the functional style of programming. Scalactic is a library which provides an “Either with attitude” named Or, designed for functional error handling. Or gives you more convenient chaining of map and flatMap calls (and for Continue Reading

monads

Back2Basics: Understanding Partially Applied Functions

Reading Time: 3 minutes In this blog, we are going to talk about Partially applied functions and its use case. Before starting, first, we will emphasize that though Partial functions and Partially applied functions sound similar they are different from each other. To understand Partial Functions refer. What is function application? Applying a function is called calling a function. When we pass all arguments of the function, we can Continue Reading

Scala Extractors

Back2Basics: Scala Extractors in Detail

Reading Time: 5 minutes While working with the Case Classes closely, we have a very concise way to decompose an entity using pattern matching. The potent example is pattern matching on the Some(x) and None, as most of us know they are case class and case object respectively. The potential question that we have is do we have a provision to use similar patterns without having an associated case Continue Reading

monads

ScalaFP: Firsthand With Scala-Cats Monads – #1

Reading Time: 4 minutes 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

monads

ScalaFP: Let’s Find The Reasons Behind Monads.

Reading Time: 5 minutes 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

monads

Back2Basics: Exception Handling – #3

Reading Time: 2 minutes In our previous blog Exception Handling – #2, we talked about how we can handle exception using Either. In this blog, we will explore further about Either, how we can elegantly handle exceptions using Either while working with Collections. We use collections when we want to perform some operations on elements. But what if something goes wrong while performing the transformation, do you have any Continue Reading

monads

Back2Basics: Understanding Partial Function – #2

Reading Time: 3 minutes In previous blog Understanding Partial Functions – #1, we have talked about what is partial function and how they are different from regular functions. In this blog, we will explore more about the partial function. We have talked about how we can define partial functions having one argument. But what to do if we have to pass more than one argument. Let’s try defining divide Continue Reading

monads

Back2Basics: Exception Handling – #2

Reading Time: 3 minutes 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

monads

Back2Basics: Exception Handling – #1

Reading Time: 3 minutes 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

monads

Back2Basics: Catalogue #2

Reading Time: 2 minutes Knoldus Inc is pleased to announce the launch of “Back2Basics: Tutorials”. We at Knoldus firmly believe that quality of coding plays an important role in the success of any IT organization and here we are adding a few more steps to heighten out coding benchmarks. At Knoldus we are laying the foundation for adopting healthier scala coding environment through getting and setting our Basics right. In our Continue Reading