Parsing from scratch - Part 4

scalaparserseries

Until now, we implemented a few relatively simple parsers; for parsing dates and hex colors. In this post, we are going to build a parser for parsing configuration key value pairs. This is a bit more …

Read more →

Parsing from scratch - Part 2

scalaparserseries

Having learnt how to write a simple parsing library from scratch, it is time to put it to the test by writing simple parsers. In this post, we will write a few high-level parsers - dates of the format …

Read more →

Parsing from scratch - Part 1

scalaparserseries

Parsing from scratch is a powerful technique that allows you to build custom parsers for your specific needs. In this series, we will explore the basics of parsing and how to implement a simple parser …

Read more →

The Builder Macro

scalabuildermacro

Some astute readers of the previous post on builder pattern highlighted the verbosity of the pattern. The builder pattern is a powerful pattern but comes with the baggage of boilerplate code. One even …

Read more →

The Sanitizer

scalaloggingpiisanitization

Bahul and I gave a talk about a PII logging library solution in the Bay Area Scala meetup.

Read more →

Type Gymnastics with Builder Pattern

scalabuildertypesseries

The Builder pattern provides a way to construct complex objects step by step with a fluent API, where each method call returns the builder itself, allowing for method chaining. Let us play some type …

Read more →

Understanding Contramap

scalacontramapfunctorfp

A contramap is defined as the converse of the map. I have never been satisfied with the definition. In this post, I will explain the concept in a way that is easy to internalize.

Read more →

Scala 2 Symbols

scalasymbols

This post provides a concise overview of key symbols used in Scala 2, such as symbols for function types, function literals, import renaming, and more. It serves as a quick reference for Scala …

Read more →

A Rogue JSON Parser

jsonparserscalaquiz

Recently, someone quizzed me to write a JSON parser. Time was limited. So, I told them I might not be able to write a disciplined parser that builds an AST and creates JSON objects out of it. In the …

Read more →

Top K Frequent Items

javascalaproblem

This post explores a functional style implementation in Scala and Java to a famous interview question to find the top k frequent items in an array. Beware the functional implementation may not be …

Read more →

If you know Scala, you know Kotlin

scalakotlin

This post explores the similarities between Kotlin and Scala, two modern programming languages. The post highlights key programming constructs, demonstrating how both languages handle basic syntax, …

Read more →

A world without types - Part 3

scalaseriesseries-typestypes

Guest post by Bahul Jain. In this post, he talks about algebraic data types (ADTs) and its benefits. He discusses how ADTs can be used to model complex data and boost developer productivity.

Read more →

scala-cli's JVM Install Location

scalascala-clicoursier

scala-cli, one of the superpowers in the Scala ecosystem, is a versatile tool for running Scala scripts. It has a ton of options to play with. One of the arguments you can pass to scala-cli is to …

Read more →

Why Functional Programming Matters

scalafp

This post takes a more relatable and realistic yet complex problem to demonstrate how it is straightforward and concise to implement it in functional programming. It makes the case why functional …

Read more →

A world without types - Part 2

scalaseriesseries-typestypes

Guest post by Bahul Jain. In this post, he talks about addressing the performance implications of creating types everywhere. He explores AnyVal and a light-weight library called Supertagged to …

Read more →

A world without types - Part 1

scalaseriesseries-typestypes

Guest post by Bahul Jain. In this post, he explains why types are essential for modeling data and operations in a meaningful way. He goes into detail about how types help clarify the purpose of data, …

Read more →

Phantom types - Part 2

scala

A friend raised a great question after reading the last post: If I am reading a list of books (List[Book]) from the database, wouldn’t I lose the type information augmented by phantom type? If …

Read more →

How I SBT - VII

scalasbtseries

This post is the final part of the series on SBT. I hope I covered everything needed to break the ice and change the perspective on SBT. I have touched on most ingredients you need to write a decent …

Read more →

How I SBT - VI

scalasbtseries

I had planned to finish the series with this post. But Plugin s wouldn’t let me. I am going to show you how to write/publish a SBT project that is a Plugin, and I will show a nifty trick. It is …

Read more →

How I SBT - V

scalasbtseries

So far, we have everything we need to write the build definition for a single project. Today, we’ll see another powerful feature of SBT: Multi-module builds.

Read more →

How I SBT - IV

scalasbtseries

Previously, we discussed Plugin s. Today, let us see how to better organize build code. How I SBT - build.sbt How I SBT - Settings & Tasks How I SBT - Plugins How I SBT - Build Code Organization …

Read more →

How I SBT - III

scalasbtseries

Previously, we discussed how to quickly write a simple build.sbt without fuss. We briefly understood how it is processed by SBT along with Settings and Tasks. We did that without having to know about …

Read more →

How I SBT - II

scalasbtseries

Previously, I showed you how to write a SBT build definition without knowing much at all. Neither did I talk about simple things like directory structure nor about advanced things like scope or axis, …

Read more →

Interpreter Basics

scalafp

Interpreter is a language (or program) to evaluate expressions and execute code. The intent is to keep the evaluation lazy and pure. There are 3 different kinds of methods in the interpreter pattern / …

Read more →

Scala

scalawiki

Collection of nifty Scala things Monad Laws Interpreter Basics … and more

Read more →

How I SBT - I

scalasbtseries

Contrary to the unpopular opinions that it is hard and clumsy, SBT, the de facto build tool for Scala, is one of the best. Ease comes with familiarity. Unfortunately, there aren’t many …

Read more →

Tagged Types & Implicit Resolution

scalasbttagged-typesimplicit

Last time, I wrote about different ways of declaring implicits, which is a prelude to this post. Knowledge of different ways of declaring implicits is good for general understanding on the subject, …

Read more →

Cross-JDK Compilation in SBT

scalasbt

Recently, I had to cross-compile a bunch of Scala library repositories for JDK 11 and JDK 17. I was hoping SBT would natively support specifying the related configuration in build.sbt similar to …

Read more →

Declaring Implicits

scalaimplicits

While implicits are easy to use, declaring them properly requires careful consideration. Because there are a few different ways you can declare implicits viz. extension methods, parameter values, type …

Read more →

Monad Laws

scalafp

Monad typeclass trait Monad[F[_]]: def pure[A](a: A): F[A] def flatMap[A, B](fa: F[A])(f: A → F[B]): F[B] Monad Laws pure(a).flatMap(f) = f(a) m.flatMap(pure) = m m.flatMap(g).flatMap(h) = m.flatMap(b …

Read more →

My Scala Story

scalajourney

I have been reading the My Scala Story series by Software Mill - a short interview of renowned experts about their Scala journey. I have not done anything substantial in the OSS space to be on …

Read more →

Optional Parameters

javaoptionalscala

The billion dollar mistake has been committed already. No going back. But it is not necessary to keep repeating it. Oh, I am talking about the infamous null. Would Java’s Optional come to the …

Read more →