Created
August 2, 2012 02:07
-
-
Save ashmind/3232454 to your computer and use it in GitHub Desktop.
F# first class generic function cheating
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
type Test() = | |
let f = fun x -> x | |
member this.F with get() = f | |
let t = Test() | |
ignore (t.F "5") // 1 | |
// ignore (t.F 5) // 2 | |
Console.WriteLine(t.F.GetType().BaseType) | |
// writes: | |
// 1: Microsoft.FSharp.Core.FSharpFunc`2[System.String,System.String] | |
// 2: Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,System.Int32] | |
// 1 and 2: error FS0001: This expression was expected to have type string but here has type int |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment