Rash thoughts about .NET, C#, F# and Dynamics NAV.


"Every solution will only lead to new problems."

Wednesday, 27. March 2013


FSharpx 1.8 removes support for Freebase, CSV, JSON and XML document type providers

Filed under: F# — Steffen Forkmann at 18:25 Uhr

There was a lot of confusion about the document type providers in the last couple of months. The reason was Tomas Petricek and Co. worked on an improved version in the FSharp.Data project and most people lost track which feature was in which project.

In order to make things clearer I removed the Freebase, CSV, JSON and XML type providers from the fsharpx project. From now on they are only in the FSharp.Data project (on github and nuget).

I hope this doesn’t make things worse and I apologize for the confusion. On the bright side you now get a couple of new features and a really cool documentation.

You can read more about this on Tomas’s blog.

Tags: ,

Wednesday, 26. September 2012


FSharpx type providers are available as separate nuget packages

Filed under: F# — Steffen Forkmann at 20:20 Uhr

In order to simplify the access of the FSharpx type providers I separated them into their own nuget packages. From now on we have:

At the moment all type providers should work with .NET 4.0 and .NET 4.5 and F# 3.0.

Tags: , ,

Thursday, 13. September 2012


Graph type providers in FSharpx

Filed under: C#,F#,Informatik,Mathematik — Steffen Forkmann at 9:24 Uhr

After the official Visual Studio 2012 launch yesterday I think it’s a good idea to announce two new type providers which are based on the DGMLTypeProvider from the F# 3.0 Sample Pack.

Synchronous and asynchronous state machine

The first one is only a small extension to the DGMLTypeProvider by Tao. which allows to generate state machines from DGML files. The extension is simply that you can choose between the original async state machine and a synchronous version, which allows easier testing.

image

If you want the async version, which performs all state transitions asynchronously, you only have to write AsyncStateMachine instead of StateMachine.

State machine as a network of types

The generated state machine performs only valid state transitions, but we can go one step further and model the state transitions as compile time restrictions:

image

As you can see the compiler knows that we are in State2 and allows only the transitions to State3 and State4.

If you write labels on the edges of the graph the type provider will generate the method names based on the edge label. In the following sample I’ve created a small finite-state machine which allows to check a binary number if it has an even or odd number of zeros:

image

As you can see in this case the compiler has already calculated that 10100 has an odd number of zeros – no need to run the test Zwinkerndes Smiley.

This stuff is already part of the FSharpx.TypeProviders.Graph package on nuget so please check it out and give feedback.

Tags: , ,

Tuesday, 29. May 2012


Porting Clojure’s persistent data structures to .NET part 2 of n – TransientVector

Filed under: C#,F# — Steffen Forkmann at 18:15 Uhr

In the last post I wrote about the PersistentVector which I ported from Clojure to .NET. It’s implemented as an immutable hash array mapped trie which optimizes the constant factors so that we can assume O(1) for count, nth, conj, assocN, peek and pop.

But for some applications Rich Hickey shows us that we can optimize the constant factors even further. If we are sure that we are only holding exactly one reference to the vector than we can mutate the underlying representation instead of copying the arrays on every change. This idea is implemented in the TransientVector which I also ported from Clojure.Core to FSharpx.

Let’s look at a small example. Here we want to convert a collection to a PersistentVector:

As you can see we iterate over the collection and conj the items to the current PersistentVector. But in every step we forget the reference to the last version. This is exactly the point where can use TransientVector:

Here are the results:

Most higher-order functions on vectors like map are also implemented with this trick.

Tags: , , ,

Porting Clojure’s persistent data structures to .NET part 1 of n – PersistentVector

Filed under: C#,F# — Steffen Forkmann at 14:41 Uhr

Rich Hickey created a very nice set of persistent collections for Clojure. I started to port them to FSharpx and today I want to present the PersistentVector. The basic idea is that we want to have something like an array but immutable.

Vectors (IPersistentVector)

A Vector is a collection of values indexed by contiguous integers. Vectors support access to items by index in log32N hops. count is O(1). conj puts the item at the end of the vector.
     From http://clojure.org/data_structures

These vectors are very fast in practical applications since the depth of the underlying tree is not greater than 7. First performance tests show the following on my machine:

These results are not that far away from the Clojure/Java implementation (see below). The lookup seems to be a bit faster but assoc is slower. Maybe that has something to do with the internal array copy function of .NET:

After installing the FSharpx nuget package can use this Vector<T> from C# like this:

More samples can be found in the PersistentVectorTest.fs file.

Additional resources:

Tags: , , , , ,

Thursday, 22. March 2012


WPF Designer for F#

Filed under: C#,F#,WPF — Steffen Forkmann at 19:19 Uhr

F# 3.0 brings the new type providers feature which enables a lot of different applications. Today I’m happy to announce that the FSharpx project brings you a WPF designer for F# in the Visual Studio 11 beta.

image

A big kudos to Johann Deneux for writing the underlying XAML type provider.

  1. Create a new F# 3.0 Console application project
  2. Set the output type to “Windows Application” in the project settings
  3. Use nuget and install-package FSharpx.TypeProviders.Xaml
  4. Add references to WindowsBase.dll, PresentationFramework.dll, System.Xaml.dll and PresentationCore.dll
  5. Add a Xaml file to your project. Something like this:
  6. Now you can access the Xaml in a typed way:
  7. Start the project

Enjoy!

BTW: No code generation needed is for this. No more nasty *.xaml.cs files.
BTW2: Try to change the name of Button1 in the Xaml and press save. Zwinkerndes Smiley

Tags: , , , ,

Wednesday, 19. October 2011


Articles about FSharpx

Filed under: F# — Steffen Forkmann at 14:49 Uhr

My last posts described some special monads in F#. The code is now part of a new project called FSharpx. FSharpx is a library for the .NET platform implementing general functional constructs on top of the F# core library. The idea is that we start merging all these nice little F# open source projects we have and put them under one umbrella.

The project is in an early phase, but it’s really starting to accumulate so much interesting stuff and the number developers who are contributing is rising.

Unfortunately the documentation is not that good at the moment and therefore I want to present a collection of articles which cover some of the related topics:

I also recommend you to checkout the test projects. You will find there a lot of interesting samples.

If you find more articles about FSharpx or related topics, then feel free to contact me. I will include them here and in the documentation of the project.

Tags: ,