Skip to content

Instantly share code, notes, and snippets.

View QueryByAttribute to QueryExpression
// This....
QueryByAttribute qba = new QueryByAttribute("entityName")
ColumnSet = new ColumnSet("fieldA", "fieldB")
// There may be several of these lines
qba.AddAttributeValue("fieldC", "fieldCValue");
TeaDrivenDev / NestedLets.fs
Created Mar 11, 2014
F# composition root with lots of single and with nested lets
View NestedLets.fs
// old
let ComposeSimple serviceProvider configuration =
let (context, organizationService, _, _) = DecomposeServiceProvider serviceProvider
let configurationXml = XElement.Parse configuration
let getRecordName = GetRecordName organizationService
let regardingLookups() = ConfiguredRegardingLookups configurationXml
let listFindingRegardingObject() = ListFindingRegardingObject regardingLookups (GetFullRecordImage(context))
let regardingObject = NameAddedRegardingObject getRecordName listFindingRegardingObject
TeaDrivenDev /
Last active Jan 4, 2016
Comparison of a small MSCRM plugin implemented in C# and F#

As requested by several people on Twitter after I mentioned that the C# implementation is 27 lines, and the F# version saves only two lines over this (which is mainly because there isn't much to save at all). In the mean time, I actually managed to shave off two more lines because the last method call incidentally returns void.

Please note that the plugin as such is not very useful; I'm mainly trying to get an F# plugin to run within MSCRM in the first place.


	using Microsoft.Xrm.Sdk;
	using System;
TeaDrivenDev / UpdateExercismProject.fsx
Created May 10, 2016
F# script to add the files for a new F# problem to an .fsproj file
View UpdateExercismProject.fsx
I am using Visual Studio to solve the F# problems on, and I found it tedious
to always add the same files (test file, new code file, readme, plus a folder for better
organization) after each `exercism fetch`, so I automated that.
As it is, this assumes that the .fsproj file is in `exercism\fsharp`. When run, it compares
the subdirectories present with the folders in the .fsproj file, and for any that are
missing in the project file, it adds the `*Test(s).fs` and `` files as well as
creating a new .fs file for the problem solution. It also adds a `module` line with the
respective file name (which is correct most of the time; only occasionally, the module the
TeaDrivenDev / Fsharp.ahk
Created Aug 3, 2016
AutoHotkey script for F# development
View Fsharp.ahk
; In case you think you may need Caps Lock again at some point,
; we'll move it over to Win+Caps Lock
SetCapsLockState, AlwaysOff
If GetKeyState("CapsLock", "T") = 1
SetCapsLockState, AlwaysOff
TeaDrivenDev / ArguInteropExample.fsx
Last active Sep 25, 2016
Simple example how to hide Argu command line parsing behind an interface for use from .NET languages other than F#
View ArguInteropExample.fsx
open Argu
type CliArguments =
| Yes
| Name of string
| Value of int
with interface IArgParserTemplate with
member s.Usage =
match s with
| Yes -> "specify"
TeaDrivenDev / Prelude.fsx
Created Nov 3, 2016
F# functions I use a lot, mostly in prototyping; functionally correct, not necessarily efficient.
View Prelude.fsx
open System
let asFst second first = first, second
let asSnd first second = first, second
let swap (a, b) = b, a
type FullJoinResult<'TLeft, 'TRight> =
| LeftOnly of 'TLeft
| RightOnly of 'TRight
View FsAdvent.fsx
#r @"..\packages\FSharp.Data\lib\net40\FSharp.Data.dll"
open FSharp.Data
let OverviewUrl = @""
type Page = HtmlProvider<OverviewUrl>
TeaDrivenDev /
Created May 10, 2017
Shell script that runs the given Git command and then `git status` except for certain cases where it's not useful
git "$@"
if [ $# -gt 0 ]
TeaDrivenDev /
Last active Dec 29, 2019
FsAdvent post for 2019

Paying It F#rward

This article is an entry in the 2019 F# Advent Calendar in English. Thanks to Sergey Tihon for organizing it, as always!

Note: This belongs on my blog, but some things are broken there right now, probably due to changes to GitHub Pages in recent years, so I'm publishing this here for now to at least get a reliable output.

The F# community, while small compared to those of many other languages, is known to be exceedingly open and helpful to beginners. I experienced this myself when I started learning the language nearly six years ago, and people (especially the F# MVPs) were always quick and eager to answer my newbie questions on Twitter, or wrote extensive answers on Stack Overflow or Code Review. Havi