It all works for me. This is your matching syntax, which you will most often find with matching operators, but this is on lhs jobs. Perhaps this makes sense, initially, for tuples, but you can use it with any structure.
let (a,b) = (1,2)
let (x,_) = (4,5)
:
let (head::tail) = [1;2;3;4]
FSI FS0025: . , "[]" , (-).
" , - ." ". (. , , --warnaserror +: 25). . . , -.
+ l.h.s. . . , .
let f (Composite(x,y)) = sprintf "Composite(%i,%s)" x y
f (Composite(1,"one"))
> val it : string = "Composite(1,one)"
:
type Address = Address of string
let unwrapAddress (Address a) = a
let addr = Address "sdf"
let str = unwrapAddress addr
type Composite = Composite of integer:int * someStr:string
let unwrap (Composite(c,_)) = c
let cval = Composite(1,"blah")
unwrap cval
:
let xy = Composite(1,"abc") |> function (Composite(x,y))->(x,y)
... , DU...
let (|Composite|) = function | Composite(x,y)->(x,y)
let unwrap (Composite(x)) = x
let unwrap2 (Composite(x,y)) = (x,y)
... DU, - Active Pattern
, Composite...
module Composite =
let unwrap = function | Composite(x,y)->(x,y)
-
, , : , () int ()
- val : → int