Last active
February 16, 2020 13:27
-
-
Save serjKim/c2c2f6ceef90be8352f9da2a0a64a85e to your computer and use it in GitHub Desktop.
F#: SRTP + AP
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
let inline (|HasLength|) x = | |
fun () -> (^a: (member Length: int) fst x) | |
let inline (|HasMethod|) x = | |
fun () -> (^a: (member Method: int with get) snd x) | |
let inline length (HasLength f1 & HasMethod f2) = | |
let a = f1() | |
let b = f2() | |
a + b | |
type IMethod = | |
abstract member Method : int with get | |
let o = | |
{ new IMethod with member x.Method = 1 } | |
printfn "%A" (length ([1], o)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment