Created
February 23, 2014 20:12
-
-
Save andybrackley/9176574 to your computer and use it in GitHub Desktop.
This file contains 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
(* Duck Typing *) | |
let inline flyAndWalk arg = | |
let flying = ( ^a : (member Fly : unit -> string) arg) | |
let walking = ( ^a : (member Walk : unit -> string) arg) | |
(flying, walking) | |
type Duck() = | |
member this.Swim() = "paddling" | |
member this.Fly() = "flapping" | |
member this.Walk() = "waddling" | |
type Eagle() = | |
member this.Fly() = "soaring" | |
member this.Walk() = "creeping" | |
let (eFly, eWalk) = flyAndWalk (new Eagle()) | |
let (dFly, dWalk) = flyAndWalk (new Duck()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment