We refactor a standard node callback style workflow into a composed task-based workflow. Original Code: const app = () => { fs.readFile('config.json', 'utf-8', (err, content) => { if (err) throw err; /g, '); fs.writeFile('config1.json', newContents,…
ReaderT is a Monad Transformer that wraps a given Monad with a Reader. This allows the interface of a Reader that enables the composition of computations that depend on a shared environment (e -> a), but provides a way to abstract a means the Reader …
This post is similar to previous post. The difference is in this post, we are going to see how to handle both successfuly result and error result by using Pair functor. So, still we have our funs.js: which is the same as previous post. const fs = req…
Let's say we are going to read some files, return the first file which pass the prediction method, this prediction method can be just check whether the file content contains more than 50 chars. For reading the file, it has tow requirements, first we…
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…
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…
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…
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…
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…
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…
We examine the data structure Task, see some constructors, familiar methods, and finally how it captures side effects through laziness. We are going to check two libarays, one is 'data.task'. another is 'crocks/Async': Install: npm i -S data.task npm…
We would like the ability to group a series of actions to be dispatched with single dispatching functions used as handlers in various parts of our game. The only issue with that, is that animations and other design elements in our game require us to…
Posted by Shiv Kumar on 23rd February, 2011 The Asynchronous Programming Model (or APM) has been around since .NET 1.1 and is still (as of .NET 4.0) the best/recommended solution for asynchronous I/O. Many people go down the route of using a multi-th…
We will see a peculiar example of a pure function. This function contained a side-effect, but we dubbed it pure by wrapping its action in another function. Here's another example of this: // getFromStorage :: String -> (_ -> String) const getFromSto…
We refactor a standard node callback style workflow into a composed task-based workflow. For example we have the code as following: We want to wrap async functions (readFile and writeFile) into Task. Therefore it becomes composeable. const Task = req…
We only have a few dispatching functions that need to be known by our React Application. Each one actually has multiple actions that need to be dispatched. While we could just have many imperative calls to dispatch in our dispatching functions, but w…
With our Redux implementation lousy with State ADT based reducers, it is time to hook it all up to a React Shell. Having already built out some UI/UX in React that is connected to our store, we’ll spend the first part of this lesson with a quick tour…