Sometimes I am confused with 'liftA2' and 'converge' functions. Main difference between those is that: liftA2 takes applicative functor as second and third arguements, for example, array converge takes functions as second and third arguements // lift…
1. Functional programming treats computation as the evaluation of mathematical and avoids state and mutable data. Scala encourages an expression-oriented programming(EOP) 1) In expression-oriented programming every statement is an expression. A state…
Lifting Now, let's review map from another perspective. map :: (T -> R) -> [T] -> [R] accepts 2 parameters, a function f :: T -> R and a list list :: [T]. [T] is a generic type paramterized by T, it's not the same as T, but definitely shares s…
Functions in Java Prior to the introduction of Lambda Expressions feature in version 8, Java had long been known as a purely object-oriented programming language. "Everything is an Object" is the philosophy deep in the language design. Objects a…
background In pursuit of a real-world application, let’s say we need an e-commerce web applicationfor a mail-order coffee bean company. They sell several types of coffee and in differentquantities, both of which affect the price. Imperative methods F…
In computer science, functional programming is a programming paradigm, a style of building the structure and elements of computer programs, that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It is a…
A functional programming function is like a mathematical function, which produces an output that typically depends only on its arguments. Each time a functional programming function is called with the same arguments, the same result is achieved. Func…
In this blog post I will talk about the changes coming in Angular 2 that will improve its support for functional programming. Angular 2 is still in active development, so all the examples are WIP. Please focus on the capabilities and ideas, and not t…
It is really important to understand function signature in functional programming. The the code example below: const map = fn => anyFunctor => anyFunctor.map(fn); 'map' is pointfree version of any founctor's map, for example: Maybe.of('maybe').map(t…
In functional programming, a monad is a design pattern that defines how functions, actions, inputs, and outputs can be used together to build generic types,[1] with the following organization: Define a data type, and how values of that data type are…
When combining multiple State ADT instances that depend on the same input, using chain can become quite burdensome. We end up having to play leapfrog with values inside of nested chain statements. Very reminiscent of the old callback nastiness we had…
When building our stateful computations, there will come a time when we’ll need to combine two or more state transactions at the same time to come up with a new result. Usually this occurs when want to use plain ol’ JavaScript functions with two or m…
When using ADTs in our code base, it can be difficult to use common debugging tools like watches and breakpoints. This is mainly due to the common pattern of using compositions and other ways of manipulating how functions are called. This can cause u…
The typical Redux Reducer is function that takes in the previous state and an action and uses a switch case to determine how to transition the provided State. We can take advantage of the Action Names being Strings and replace the typical switch case…
By using the State ADT to define how our application state transitions over time, we clear up the need for a some of the boilerplate that we typically need for a solid Redux integration. We can keep our action names and creators in the same file as t…
We have the ability to select a single random card from a pile of twelve cards, but we would like to pull a total of nine. Not only that, we would like to match the same transition functions we have been writing all along. Lucky for use there are thr…
Functor composition is a powerful concept that arises when we have one Functor nested in another Functor. It becomes even more powerful when both of those are Chains, allowing us to apply each Functor’s special properties and effects for a given comp…
We want to be able to pick nine random cards from an array of twelve cards, but can run into problems of keeping both the cards already draw and the cards left to draw from. Tracking two bits of state like this can create some hard to maintain argume…
While sometimes outside input can have influence on how a given stateful transaction transitions, there are many times where the current state at the time of a transaction. We can see the power of this type of transaction by seeing what it would take…
Let's say we want to write a most simple implementation 'avg' function: const avg = list => { let sum = 0; for(let i = 0; i < list.length; i++) { sum += list[i] } return sum / list.length } Basiclly, the 'avg' function doing two things: Calculate su…