-
-
Save Neftedollar/cf226e56273e7a91efb9f6771b674e73 to your computer and use it in GitHub Desktop.
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
type Test = | |
{ EntityId: string } | |
type Test2 = | |
{ EntityId: string | |
Name: string | |
Length: int } | |
let inline (|HasEntityId|) x = | |
fun () -> (^a : (member EntityId: string) x) | |
let inline entityId (HasEntityId f) = f() | |
let inline (|HasName|) n = | |
fun () -> (^a : (member Name: string) n) | |
let inline name (HasName f) = f() | |
let inline test2f (HasName n & HasEntityId id) = sprintf "name %s id %s" (n()) (id()) | |
let test2 = {Test2.EntityId = "123"; Name = "123"; Length = 2} | |
let a = entityId { EntityId = "123" } | |
let b = entityId test2 | |
let c = name test2 | |
let d = test2f test2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment