Welcome to MSDN Blogs Sign in | Join | Help

Shameless plug - FsTest

Matthew Podwysocki finished putting together a DSL for unit testing. I imagine this only scratches the surface of what you can do with DSLs in F#.

 

The same approach also works for scripting too, check out this piece of Zen:

#light

open System.IO

// Returns all the files under a given folder
let rec filesUnder rootPath =
    seq {
        for file in Directory.GetFiles(rootPath) do
            yield file
        for dir in Directory.GetDirectories(rootPath) do
            yield! filesUnder dir }
            
            
// Deletes all files
let deleteAll files = Seq.iter File.Delete files

// Notice just how flippin sweet type inference is...
// File.Delete : string -> unit
// Seq.iter    : ('a -> unit) -> #seq<'a> -> unit
// deleteAll   : #seq<string> -> unit

// The pipe-backwards operator allows you to get this to
// execute in the right order without parens around 'filesUnder'
deleteAll <| filesUnder @"C:\Logs"
Published Sunday, June 22, 2008 1:00 PM by ChrSmith

Comments

Sunday, June 22, 2008 5:01 PM by Pregnant Man &raquo; Shameless plug - FsTest

# Pregnant Man &raquo; Shameless plug - FsTest

Wednesday, June 25, 2008 4:28 PM by Kirill Osenkov

# re: Shameless plug - FsTest

SWEET!!!

I'm particularly envious of yield! - it's a shame we don't have that in C#:

http://kirillosenkov.blogspot.com/2007/10/yield-foreach.html

New Comments to this post are disabled
 
Page view tracker