Concise pattern match on single case discriminated union in F#

You’re almost there. Parentheses are required in order that the compiler interprets a let-bound as pattern matching:

let (OrderId id) = orderId

If orderId is a parameter of a function, you can also use pattern matching directly there:

let extractId (OrderId id) = id

Leave a Comment