Skip to content

Instantly share code, notes, and snippets.

@ilkerde
Created February 9, 2012 19:23
Show Gist options
  • Save ilkerde/1782233 to your computer and use it in GitHub Desktop.
Save ilkerde/1782233 to your computer and use it in GitHub Desktop.
Func<dynamic,bool> interplay between C# and F#
namespace FuncTest {
using System;
public class EmitBit {
public Func<dynamic,bool> Emitter { get; set; }
public void Emit() {
Console.WriteLine("emit was {0}", Emitter("test"));
}
}
}
/*
compiles to -> EmitBit.dll
*/
#r "EmitBit.dll"
open FuncTest
open System
let emitbit = new EmitBit()
let dynamicFunc = new Func<obj,bool>(fun o -> o.ToString() = "test")
let nullCheck = function
| null -> "is null"
| _ -> "has func"
emitbit.Emitter <- dynamicFunc
nullCheck emitbit.Emitter |> printfn "emitter %s"
emitbit.Emit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment