Concurrent Programming in Fsharp Using Hopac - Part 7

Hello there! Almost eight years back Tomas Petricek wrote a blog post introducing BlockingQueueAgent and followed it up with another blog post on how to apply it to solve an Image Processing problem using the pipeline concurrency pattern. In this blog post, we are going to learn how to port this example using Hopac’s BoundedMb abstraction, aka Bounded Mailbox. Image processing pipeline As defined by Tomas in his blog post, the image processing pipeline works as depicted in the below image.

Concurrent Programming in Fsharp Using Hopac - Part 6

Hi there! Welcome back to the sixth part of my blog series on concurrent programming in fsharp. In this part, we are going to learn how to deal with state changes while doing concurrent programming through a fun example. Time Bomb Simulator The example that we are going to see is a time bomb simulator. The time bomb transitions through different states as shown below during its lifecycle.

The associated fsharp type TimeBomb will have the following signature

Concurrent Programming in fsharp Using Hopac - Part 5

Hi, In the last blog post, we learned how Alt in Hopac works and its applications. In this blog post, we are going to apply what we learned so far by creating a Ticker. Using ticker we can do something repeatedly at regular intervals. To implement a Ticker in Hopac, we have to know one more abstraction in Hopac called IVar. So, in the first section, we are going to learn IVar and then we’ll use it to implement Ticker.

Concurrent Programming in fsharp using Hopac - Part 4

Hi, Welcome back to the fourth part of Concurrent Programming in fsharp blog post series. In part-2, we just learned that Alt<‘a> is a subclass of Job<‘a>. In this blog post, we are doing to dive deep into this abstraction and learn what it brings to the table. An Example Before diving into the definition of Alt<‘a>, let’s figure out why we need it in the first place. Assume that we have a function delayedPrintn which prints a given message after n milliseconds

Implementing API Gateway Pattern in fsharp using Hopac

Two years back, I wrote a blog post on how to implement the API Gateway pattern using Reactive Extensions(Rx). In this third part of concurrent programming in fsharp using Hopac blog series, we are going to revisit that blog post and port it to use Hopac instead of Reactive Extensions. Rx vs Hopac The critical difference between Rx and Hopac is their communication model. Rx is primarily a system for querying data in motion asynchronously, and systems built using Rx rely on asynchronous message-passing.

Concurrent Programming in Fsharp Using Hopac (Part-2)

In the last blog post, we learned the how to create jobs and run them parallelly using Hopac. In this second part of the blog post series, we are going to explore inter-job communication. Share Memory By Communicating In multi-threaded programming model, if two threads want to communicate, the typical approach is using a shared memory backed by locks, thread-safe data structures (or other synchronisation primitives). We have to follow specific best practices to avoid Deadlocks and Race Conditions while using the shared memory approach.

Concurrent Programming in fsharp using Hopac (Part-I)

Enabling developers to write concise code in solving complex problems is one of the significant characteristics of functional programming. The conciseness is mostly due to the abstractions provided by the functional programming language. Can we apply these abstractions and write concurrent programs with ease? We are going to find the answer to this question by writing concurrent programs in fsharp using the Hopac library. What is Hopac Hopac is a fsharp library that provides a programming model inspired by John Reppy’s Concurrent ML language.

Adding Meaning to Primitive Types in fsharp

One of the recommended guidelines in Domain Driven Design is modelling the domain ideas using the domain type (CustomerName, CustomerId) instead of using their corresponding primitive type (string, int). In fsharp, with the help of Single-Case Discriminated Union, we can follow this guideline with minimal effort. While following this practice in one of my recent project in fsharp, I came across a compelling use case, and I used a lesser-known approach to solve the problem.

Introducing FsConfig

I am delighted to introduce a new F# library, FsConfig. FsConfig is a F# library for reading configuration data from environment variables and AppSettings with type safety Why FsConfig? To understand FsConfig, let’s have a look at an use case from the FsTweet application. The FsTweet application follows The Twelve-Factor App guideline for managing the configuration data. During the application bootstrap, it retrieves its ten configuration parameters from their respective environment variables.

Generic Programming Made Easy

Generic programming is a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters1. Generic programming was part of .NET since .NET Version 2.0 and has a fascinating history as well! For most of the use cases which involves generics, implementing them in F# is a cake-walk. However, when the generic programming requires reflection, it becomes a bumpy ride.