Tag Archives: monad

Part 1: A Practical Monad in JavaScript


via A Practical Monad in JavaScript — Medium.

Recently I was reading this article by Josh Haberman describing monads as a design pattern. I’m one of the many who has rammed their head into the brick wall that is understanding what monads are, but I haven’t read an article about them in a while so I figured Maybe today would be the day.

Part 2: A Practical Monad in Javascript


via A Practical Monad in Javascript pt. 2 — Medium.

This is my second post in the series. If you haven’t read the first one, where I introduce our little Maybe monad, you can find it here.

Modelling Stochastically Independent Processes with F# Computation Expressions: Part 1


The idea for doing this is not new. There is an excellent series of posts closely tracing an article on applications of functional programming to probability. A colleague of mine has recently called my attention to his own post of two years ago, where he describes a monad that models stochastically independent events in Clojure. […]

http://viralfsharp.com/2014/12/05/modelling-stochastically-independent-processes-with-f-computation-expressions/

Modelling Stochastically Independent Processes with F# Computation Expressions: Part 2


Code for this entry: here. In this first part, we started shamelessly plagiarizing creatively reproducing a Clojure monad that does a great job describing stochastically independent processes. After a few trials I became convinced, that the approach in the blog post mentioned above was indeed optimal: a “natural” approach of modelling an event as a […]

http://viralfsharp.com/2014/12/11/modelling-stochastically-independent-processes-with-f-computation-expressions-part-2/

Functor and Monad in Swift


via Functor and Monad in Swift.

I have been trying to teach myself Functional Programming since late 2013. Many of the concepts are very daunting because of their somewhat academic nature.

Since I’m obviously not an expert, I intend this to be a very practical post. You will find many posts trying to explain what a Monad is, some of them trying a bit too hard to come up with similes, but hopefully the sample code here will illustrate some of the concepts better.

It wasn’t until recently that I finally could say that I got what Monad means. Let’s explore why this concept even exists, and how it can help you when writing Swift code.

A monad for reactive programming. Part 2


Click to Read

Some time has passed since I published the first part of this tutorial. The time has been spent in achieving a deeper understanding of events and event processing. In this second part I solve the problems of the simple approach depicted at the end of the part 1.

The motivating example to solve is the same, a console application with a basic event scheduler, a monadic computation that has some statements which wait for different kinds of events. You can run the two examples here in the tutorial.

This tutorial also can be considered as the description of an event sourcing mechanism without inversion of control. A event sourcing application is basically a set of event handlers for each type of event with a central state. A functional reactive mechanism is a single event handler with event preprocessing on top. while a monadic reactive mechanism like this is a monadic computation that automatically generates a cascade of event handlers.

Besides monadic reactive, I will demonstrate more classical functional reactive behaviours using applicative combinators, and how to mix monadic, reactive and alternative to mimic the creation of new signals, with thresholds.