Skip to content

monads

These are the stories that have been posted to the monads category.

F# Discoveries This Week 10/04/2009


Published to Rick Minerich's Development Wonderland by Richard Minerich October 05, 2009 01:57

I’m back from my three week vacation and am just about buried in fascinating functional programming links.  I’ve managed to get through most of them and have selected the best of these for this very special welcome back edition of Discoveries This Week.

 

CUFP (Commercial Users of Functional Programming) 2009 Videos

“Functional languages have been under academic development for over 25 years, and remain fertile ground for programming language research. Recently, however, developers in industrial, governmental, and open-source projects have begun to use functional programming successfully in practical applications. In these settings, functional programming has often provided dramatic leverage, including whole new ways of thinking about the original problem.”

 

M<’a> Lib (F# and C# LINQ) Monads Library

“Unified collection of Monads (M, unit, *) implemented in the Microsoft F# Language.”

Implemented so far: Identity, Maybe, State and List with many more to come.  The project lead is actively looking for help. 

 

Flying Frog’s F# vs OCaml: Image Processing

“Fortunately, this inefficiency can be overcome by using Just-In-Time (JIT) compilation instead of static compilation and partially specializing polymorphism away before JIT compilation. This is the intended design for polymorphism in HLVM and the inspiration was drawn from Microsoft's excellent implementation of the CLR.

Consequently, the equivalent F# program is 100× faster than the OCaml.”

This JIT optimization speed enhancement is astounding by any measure.

 

HPC Development Using F#

“This white paper introduces the F# programming language in the context of technical computing, and demonstrates how F# can be used for both shared-memory parallel programming using the Task Parallel Library, and distributed parallel programming using a Windows HPC Server 2008-based cluster and the Message Passing Interface (MPI).”

 

Matthew Podwysocki’s Generically Constraining F# Pars One, Two and Three

“Generic constraints inside .NET has always been a fun enterprise, especially given how C# handles them  There has been some discussion on Jon Skeet’s blog about the fact that C# does not allow for generic constraints referring to a number of types. […] However, as Jon correctly points out, this is indeed supported by the CLR directly.  In fact, with our knowledge of F# constraints, we can write this exact function in F# without any such issue.”

F# Discoveries This Week 12/14/2009


Published to Rick Minerich's Development Wonderland by Richard Minerich December 14, 2009 16:06

An almost overwhelming number of posts this week with topics including the Skills Matter Programming Exchange, LAgent, data structures, service oriented architecture, monads, infinite sequences, timing F# functions, functional design, and much more.  Come in and check it out.

 

Don Syme on WebSharper: F#-based Rich Client/Server Web Applications

Intellifactory seem to have set about answering the question of "just how simple, clean and productive can you make developing rich web applications that target Javascript?" (my words, not theirs).  While still in beta, signs are that Intellifactory are putting together an impressive technology that makes really good use of F#'s unique facilities to simplify this class of applications.

 

Mike Hadlow on the Skills Matter Functional Programming Exchange

I had a great time today at the Functional Programming Exchange organised by Robert Pickering and Skills Matter. Robert managed to grab some really interesting speakers who gave a nice snapshot of the current art and use of FP.

 

Luca Bolognese on LAgent: an agent framework in F# – Part X – ActiveObject

So you start thinking if there is a way to enhance vanilla objects to make them agents. You want to reuse all the concepts that you are familiar with (i.e. inheritance, visibility rules, etc…) and you want your clients to call agents as if they were calling normal objects. Obviously, under the cover, the method calls won’t execute immediately, but they would be queued.

 

Ted Neward’s A New Kind of Service

Why study new and different programming languages? To change your programming mindset. Not sure what I mean by that? Check this out.

 

Anton Tayanovskyy on Generic Workflow Builders (Monads) in F#

This blog post is about a quick and dirty encoding of Haskell type classes in F#. With the ongoing work on the WebSharper™ project, we are currently very interested in coaxing the .NET type system to support writing code that is generalized over monads and applicative functors.

 

Anton Tayanovskyy on Foldr or FoldBack on Infinite F# Sequences

A noticeable omission in F# standard library is Seq.foldBack, or the famous Haskell foldr. The semantics of foldr is very simple to remember: it replaces the native cons and nil of a list with arbitrary computations.

 

Anton Tayanovskyy on The Execution Speed of Early vs Late Binding

This little post documents one of my little experiments with F#, as I am educating myself on the .NET Framework fundamentals.

This post is also interesting because it describes how to turn on timing in F# interactive.

 

Julien Ortin’s Purely Functional Data Structures in F#: Batched Queue, Binomal Heap and Red-black Set

This post describes the F# implementation of the <insert data structure here> from Chris Okasaki’s “Purely functional data structures”.

 

Justin Lee’s Infer.NET – Now with F# Support

Infer.NET is a framework for running Bayesian inference in graphical models. You can use it to solve many different kinds of machine learning problems, from standard problems like classification or clustering through to customised solutions to domain-specific problems.

 

Joh’s Inheritance Nightmares

At this point, readers interested in F# and functional programming languages might wonder what all this has got to do with F#. I think that the common mix of mutability and inheritance is not a very strong basis for good software design. I never really realized that until I took a look at functional programming and immutability.

 

Talbott Crowell’s Slides from Parallel and Concurrent Programming with F#

As promised, please find the slides and source code for the demos.

 

Ryan Riley Discusses F# on the HighOnCoding Podcast

Last week I had the pleasure of recording a podcast with Ryan Riley about F# programming language. Ryan discussed different features of the F# language and how it can be used to build applications.

 

Cameron Taggart’s F# on Mac using Cocoa

Laurent Etiemble created a Monobjc project/library that allows access to Objective-C frameworks and libraries like Cocoa.  I just ported the first tutorial to F#.  I’m able to build it on my PC and run it on my Mac.

 

Mark Needham’s Haskell vs F#: Function Composition

I'm reading through John Hughes' 'Why functional programming matters' paper and one thing I've come across which is a bit counter intuitive to me is the Haskell function composition operator.

 

Marius Bancila’s F# Operations on List

In this post I want to show how you can implement common list operations: union, intersection, difference and concatenation.

 

Viabhav Bhandari’s F# – Functional Approach

In this version of interesting programming concepts, I would like to highlight type system based pattern matching available in F#/OCAML, its very unique and extremely useful if you are parsing a structured list or working on a symbol table.

F# Discoveries This Week 12/21/2009


Published to Rick Minerich's Development Wonderland by Richard Minerich December 21, 2009 17:10

By far the most exciting news this week was the preview release of Microsoft Research Accelerator.  Posts on this topic by Satnam Signh and Tomas Petricek have left the F# world buzzing.  This, however, is just the tip of the F# iceberg.  News of the F# Survival Guide’s release and a number of other exciting posts follow.

 

-- F# --

Satnam Singh demonstrates GPGPU and x64 multicore programming with Accelerator

Microsoft recently released a preview of the Accelerator V2 GPU and x64 multicore programming system on Microsoft Connect. This system provides a civilized level of abstraction for writing data-parallel programs that execute on GPUs and multicore processors. An experimental FPGA target is under development.

 

Tomas Petricek explores Microsoft Research Accelerator

The project used Microsoft Research Accelerator, which is a C# library for developing array-based computations and executing them on a GPU. […] In this article, we'll look at the simplest way of using Accelerator from F#. Accelerator provides a managed interface that can be naturally used from both C# and F#.

 

The F# Survival Guide – a Free eBook

Welcome to the F# Survivial Guide by John Puopolo with Sandy Squires. We wrote this book to introduce mainstream developers to the world of functional programming through the lens of F#, Microsoft's first fully-supported multi-paradigm language.

 

Matthew Podwysocki builds a Shopping Cart in F#

Where functional programming has an immediate impact and probably the largest is programming in the small.  Here, we can focus on such things as immutable values, higher order functions, recursion, pattern matching and others come into play.  When we’re talking about mixing paradigms, object oriented programming has a larger effect on programming in the medium where we’re organizing our code and can some times offer a more elegant solution than a functional programming one.

 

Brian McNamara explores IObserver and IObservable

At core, IObservable is just about two new small interfaces, IObservable<T> and IObserver<T>, being added to .Net 4.0.  We’ll come to the details of those interfaces shortly.  What is exciting and useful about IObservable is that these interfaces admit very nice programming models, including LINQ (e.g. for C#) and the Observable module (for F#), that provide useful combinators for transforming and using event streams.

 

Steffen Forkmann maps the Reactive Framework operators to F#

The “Reactive Extensions for .NET (Rx)” comes with lot’s of operators for using IObservable<T>. This code mimics the signature of the default F# sequence combinators and allows to use observables like sequences. It is a similar approach like Matthews Podwysocki’s blog post about mapping the IParallelEnumerable.

 

Robert Pickering introduces FunctionalNHibernate

It’s already fairly well documented that F# doesn’t play too well with NHibernate and Fluent NHibernate, although you can make it play a littler nice with a bit of effort. However there are a few fundamental problems with this approach.

 

Bistro FSharp Extensions 0.9.5.0 is released

The new release drastically improves the project's interaction with the inference capabilities of F#. A majority of controllers can now be written without the need for discriminated union annotations, or let bindings for naming.

 

Julien Ortin continues his series on Purely Functional Data Structures with a Splay heap, a double-ended queue and a Pairing heap.

This post describes the F# implementation of the <insert data structure here> from Chris Okasaki’s “Purely functional data structures”.

 

Jared Parsons makes F# type inference friendly to C#

When working with the exposed core Vim engine API, I’ve found a number of generated F# constructs which are not easily accessible from C#.  The problem stems from the manner in which native F# types are exposed.  Many of them are generic and  lack type inference friendly helper methods that force awkward usage patterns in C#.

 

Alex Pedenko discusses code compression with F# and MVC

While the underlying concepts are the same, a recent stint with Django (which is a strong influence in the Bistro framework) reminded me of how little work you have to do in python to get going with a controller, and that bistro and the fs extensions still have some catching up to do on the brevity front.

 

Matt Davey muses over F# within a Single Dealer Platform

I’ve been thinking about F# for a while and its use within finance. A number of banks have been looked at F# from an analytical viewpoint – obvious, and hence boring.  What is more interesting it how F# possible elevates the building of a Single Dealer Platform (SDP).

 

Mark Needham does Word Count using a Dictionary

Having spent some time unsuccessfully trying to make my F# attempt at the word count problem work I decided to follow the lead of the other examples I've read and make use of a Dictionary to keep count of the words.

 

-- Misc Others --

Functional Programming eXchange – a Ning network for FP

Mark Dominus on why Monads are like burritos

Crash Monad Tutorial

Stuart Sierra on why Objects are not Abstract Data Types

Perlisms - “Epigrams in Programming” by Alan J. Perlis

F# Discoveries This Week 01/13/2010


Published to Rick Minerich's Development Wonderland by Richard Minerich January 13, 2010 16:59

Back again this week with a fresh batch of F# Posts, Videos and Events.  I’ve been enjoying Matthew Podwysocki’s “Much Ado About Monads” series quite a lot.  They are well worth checking out for beginner and advanced alike.

 

Events

If you would like to see your event here, send me an email via the link at the top of the page.

Rick Minerich - Charleston SC Technology Users Group on the 27th of January (check out the awesome flier)

Steffen Forkmann - Frankfurt .NET Usergroup on the 21st of January

 

Posts

Don Syme’s Async and Parallel Design Patterns in F#: Parallelizing CPU and I/O Computations

One simple way to write parallel and reactive programs is with F# async expressions. In this and future posts, I will cover some of the basic ways in which you can use F# async programming - roughly speaking, these are design patterns enabled by F# async programming.

 

Don Syme’s F# Interactive Tips and Tricks: Visualizing Data in a Grid

The demos in my F# talks use a number of coding snippets to acquire, generate and display data interactively. Some of these little snippets are not so well known, but they are useful :-)

 

Don Syme’s F# Interactive Tips and Tricks: Formatting Data using AddPrinter, AddPrintTransformer and %A in sprintf/printf/fprintf

Here are some tips and tricks for formatting data in F# Interactive. This is not meant to be a comprehensive guide, just enough to get you started. Please let me know if you need more examples.

 

Matthew Podwysocki’s Much Ado About Monads – Reader Edition

So, our ultimate goal would be instead to have our environment set once and then read from it implicitly.  We still want to keep what we have here in terms of our script, but change the underlying mechanism for how it happens.

 

Anton Schwaighofer’s SkillsMatter.com talk: F# and Units-of-measure for Technical Computing

I will start by giving an introduction to units-of-measure and their implementation in F#. I'll work through smaller and larger code examples that make use of units-of-measure.

 

Nancy Strickland’s MSDev.com Training Session on F#

Visual Studio 2010 includes a new programming language, F#. This session explains and provides a walk-through demonstration of basic programming in F#.

 

Julien Ortin continues his series on Purely Functional Data Structures with a Lazy Pairing Heap, a Real-time Queue and Bottom-up Merge Sort

This post describes the F# implementation of the <insert data structure here> from Chris Okasaki’s “Purely functional data structures”.

 

Mauricio Scheffer’s Translating Haskell to F# and other considerations

BUT, syntactic similarity does not imply that they're semantically the same. There's a fundamental difference from the original code: Haskell is a lazy language, while F#, coming from the ML-family, does eager evaluation.

 

Mark Needham’s F#: Refactoring to pattern matching

I was looking through some of the F# code I've written recently and I realised that I was very much writing C# in F# with respect to the number of if statements I've been using.

 

Mark Needham’s F# attempt at Roy Osherove’s TDD Kata

As I've mentioned in a few of my recent posts I've been having another go at Roy Osherove's TDD Kata but this time in F#.

 

Holoed’s Weak Subscribe to an IObservable Source

A code snippet describing how to subscribe to an event via a weak reference.

 

Erik Schulz’s Resource Pool in F#

I’ve been toying around with F# recently, it’s good to see an example that you can easily compare and contrast with the C# version.

 

Ade Miller’s Gotchas: Common Traps for the F# n00b

I spent a bunch of time over the holidays getting to know F# a bit better. I think I now consider myself to be truly dangerous with it.  A couple of things which repeatedly bit me as I stumbled through learning F# as a n00b.