Skip to content

Instantly share code, notes, and snippets.

@dmitry-a-morozov
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitry-a-morozov/afd85a24579163bc0464 to your computer and use it in GitHub Desktop.
Save dmitry-a-morozov/afd85a24579163bc0464 to your computer and use it in GitHub Desktop.
F# attach interface
open System
let getComparableUri uri = {
new Uri( uri)
interface IComparable<string> with
member this.CompareTo other =
compare (string this) other
}
let url = "http://news.google.com/"
let x = getComparableUri url
let x': IComparable<string> = x |> box |> unbox
printfn "Result: %i" (x'.CompareTo(url))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment