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 →

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 →

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 →

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 →