Most of the developers have dealt with calling SQL server stored procedures from their applications at least once or twice. In my last project, where intense data mining is done on the SQL side, this is basically all I am doing. There is always a desire to wrap and abstract the ever-repetitive code to get … Continue reading Exploring Monadic Landscape: Sql Command Computation Expression
Category: F#
Retry Monad: An Implementation
One application that seems quite intuitively to be a good case for "monadization" is that of retrying a function call upon an exception that is thrown while executing it. This may be needed for inherently unreliable operations, dependent on a network connection, for example. Discussions of this can be easily found. Here is one on … Continue reading Retry Monad: An Implementation
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.
C#/F# Interop and TDD
Since this development was supposed to conform to the best methodology available, I naturally chose Test Driven Development (TDD), which, as the name suggests, presumes writing tests for each piece of the code written. Actually it suggests writing tests first, but who wants to be so dogmatic! I was writing tests at least at the … Continue reading C#/F# Interop and TDD
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
Implementing a Push Type
From a developer's point of view, a Push type is implemented through a class, derived from PushTypeBase, as mentioned in the previous post. Once the type is implemented in any .NET language the system will hook it into the currently available types, will add a parser and a stack for it. All that needs to … Continue reading Implementing a Push Type
Defining a Base for Push Types
Let's take a look at how the base from which all Push types derive is defined. Push types are represented (in all .NET languages) by classes derived from PushTypeBase. This is an abstract class and the listing above shows its definition. Two properties are essential for all classes, deriving from PushTypeBase: • Value – an … Continue reading Defining a Base for Push Types