fst

Lib.fst : ('a * 'b) -> 'a

Extracts the first component of a pair.

fst (x,y) returns x.

Failure

Never fails. However, notice that fst (x,y,z) fails to typecheck, since (x,y,z) is not a pair.

Example

> fst (1, "foo");
val it = 1: int

> fst (1, "foo", []);
Exception- Type error in function application.
   Function: fst : 'a * 'b -> 'a
   Argument: (1, "foo", []) : int * string * 'a list
   Reason:
      Can't unify 'a * 'b to int * string * 'a list
         (Different number of fields)
Fail "Static Errors" raised

> fst (1, ("foo", []));
val it = 1: int

See also

Lib.snd