December 3rd, 2011Posted by Ramon Snir
One feature I’ve seen repeatedly people wishing is a macro system, so I went ahead and tweaked the compiler to add a text-based macro system. I’m warning here and now: this is only a prototype, it is imperfect and definitely incomplete. The current version uses in-place text replacement on compilation time, using precompiled macros (functions [...]
Read full article
|
August 7th, 2011Posted by Ramon Snir
There is lately quite a lot of fuss over C# 5.0, caused by the new async features. The C# async feature is based on (or was inspired by) the F#’s Async computation expression, which I will now discuss a bit (and then present my improvement). Usually, async code works in to ways – sequential (wait [...]
Read full article
|
April 2nd, 2011Posted by Ramon Snir
In this article, I will present an extension to the F# compiler (I used November 2010 CTP from the F# PowerPack site). I was inspired by two things. The first was an old attempt to create a computation builder for XML/HTML objects, which wasn’t very successful because of the lack of options in computation expressions [...]
Read full article
|
October 23rd, 2010Posted by Ramon Snir
Haskell got a nice system of classes. Though the name reminds us of the OOP term, these “classes” are very different in their use. Here is an example for people who are not familiar with Haskell classes: Ideally, our F# code would look like: Without editing the compiler (I am going to consider writing an [...]
Read full article
|
October 9th, 2010Posted by Ramon Snir
One very popular habit in F# is tail recursion. Tail recursion allows you to recurse without worrying about stack overflow. But there is a very dangerous problem – infinite recursion. Now, let’s say we have a function which doesn’t have a name which indicates it might fail (with StackOverflowException, InfiniteRecursionException, ArgumentOutOfRangeException etc.). An innocent reader [...]
Read full article
|
October 9th, 2010Posted by Ramon Snir
If you have any experience in Haskell, you know the IO monad. Some people think it just makes things ugly – but I think it is good, since we are functional programming and we should know when we are using an impure function. What we will do is to define an IO<’T> type and an [...]
Read full article
|
October 9th, 2010Posted by Ramon Snir
F# is a great language, but its support is a bit limited. For example, you can make a WPF project in F# but you cannot use XAML. In this post I will demonstrate how to create a simple calculator using F#, WPF and XAML. I did not compare the efficiency to the C# version, but I’m quite [...]
Read full article
|