The Push Monad: Introduction

Chapter 5 of Friendly F# has a great practical explanation of F# computation expressions often called "monads" from their use in computer science and Haskell. The material in Chapter 5 of the book does a lot to demystify the concept, theoretical coverage of which is done well in this Wikipedia article. Monads are an example … Continue reading The Push Monad: Introduction

Outperforming MathNet with Task Parallel Library

Math.NET is a great project that brings numerics to .NET the OS way. Perusing their blog, I found this post on the on-line algorithm for std calculation. A simple Wiki search revealed this article that describes a parallel algorithm due to Chan for calculating variance (std = sqrt(variance)). So, I set to figure out whether … Continue reading Outperforming MathNet with Task Parallel Library

Fun with F# Charting. Factoring out FSharpChart

FSharpChart wraps .NET 4.0 charting control. Here is Don's entry about it to get started and download the assembly with examples. However, FSharpChart is still a control that needs WinForms or WPF to work. What about some Matlab-esque type of functionality, where a simple function call would do the job without having to worry about … Continue reading Fun with F# Charting. Factoring out FSharpChart

Implementing a Stack in F#. Tail Recursion.

Since Push requires stacks to manipulate its data, we need an implementation of this data structure. There is of course a .NET implementation, however, it is not a "functional" data structure, in a sense that it is mutable. It is easy enough to implement our own, purely functional, immutable stack. F# list is a logical … Continue reading Implementing a Stack in F#. Tail Recursion.

Push Operation. A Few Words on Computation Expressions/Monads

As we have seen in the previous post, it is easy to implement Push types and operations: Here is an example of an implementation of FLOAT./ operation: a division of two integers on top of the stack. Since in Push an operation is denoted by "OP_TYPE.OP_NAME", it is convenient from the implementation standpoint to group … Continue reading Push Operation. A Few Words on Computation Expressions/Monads

FParsec: Creating a Parser Dynamically

In one of the previous posts the following definition for parsing simple Push types was discussed: The most noteworthy entry here is pushSimpleTypes. This parser is created dynamically from internally implemented Push types (INTEGER, FLOAT, etc) and may be dynamically extended if it becomes necessary to parse a new type. The dynamic parser is built … Continue reading FParsec: Creating a Parser Dynamically

FParsec: Parsing a List of Dynamic Keywords

In the previous post we mentioned code that parses Push types and Push operations: Tokens for Push types are a dynamic collection of keywords. "Dynamic" in a sense that a developer might add to it when extending the language. We therefore need to create a parser that would recognize tokens from a dynamic set. Since … Continue reading FParsec: Parsing a List of Dynamic Keywords