package stdcompat

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file stdcompat__fun.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

include Fun


let compose f g x = f (g x)

(*
external id : 'a -> 'a = "%identity"
(** @since 4.08.0: external id : 'a -> 'a = "%identity" *)

let const c _ = c

let flip f x y = f y x

let negate f x = not (f x)

exception Finally_raised of exn

let protect ~finally f =
  let value =
    try
      Stdcompat__pervasives.Ok (f ())
    with exn ->
      let bt = Stdcompat__printexc.get_raw_backtrace () in
      Stdcompat__pervasives.Error (exn, bt) in
  begin
    try
      finally ()
    with exn ->
      let bt = Stdcompat__printexc.get_raw_backtrace () in
      Stdcompat__printexc.raise_with_backtrace (Finally_raised exn) bt
  end;
  match value with
  | Stdcompat__pervasives.Ok result -> result
  | Stdcompat__pervasives.Error (exn, bt) -> Stdcompat__printexc.raise_with_backtrace exn bt
*)
OCaml

Innovation. Community. Security.