can

Lib.can : ('a -> 'b) -> 'a -> bool

Tests for failure.

can f x evaluates to true if the application of f to x succeeds. It evaluates to false if the application fails.

Failure

Only fails if f x raises the Interrupt exception.

Example

> hd [];
Exception- The type of (it) contains a free type variable. Setting it to a unique
   monotype.
Empty raised

> can hd [];
val it = false: bool

> can (fn _ => raise Interrupt) 3;
Exception- Interrupt raised

See also

Lib.assert, Lib.trye, Lib.partial, Lib.total, Lib.assert_exn