Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ Working version
- #12784: Fix computation of minor-heap allocation in Gc.counters()
and Gc.allocated_bytes(). (Nick Barnes, review by Gabriel Scherer)

- #12770: Add `Fun.compose`.
(Justin Frank, review by Nicolás Ojeda Bär, Daniel Bünzli and Jeremy Yallop)

### Other libraries:

- #12213: Dynlink library, improve legibility of error messages
Expand Down
1 change: 1 addition & 0 deletions stdlib/fun.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

external id : 'a -> 'a = "%identity"
let const c _ = c
let compose f g x = f (g x)
let flip f x y = f y x
let negate p v = not (p v)

Expand Down
6 changes: 6 additions & 0 deletions stdlib/fun.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ val const : 'a -> (_ -> 'a)
(** [const c] is a function that always returns the value [c]. For any
argument [x], [(const c) x] is [c]. *)

val compose : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c
(** [compose f g] is a function composition of applying [g] then [f].
For any arguments [f], [g], and [x], [compose f g x] is [f (g x)].

@since 5.2 *)

val flip : ('a -> 'b -> 'c) -> ('b -> 'a -> 'c)
(** [flip f] reverses the argument order of the binary function
[f]. For any arguments [x] and [y], [(flip f) x y] is [f y x]. *)
Expand Down
6 changes: 3 additions & 3 deletions testsuite/tests/backtrace/backtrace_dynlink.flambda.reference
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Called from Dynlink.Native.run in file "native/dynlink.ml", line 82, characters
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml", line 358, characters 11-54
Called from Stdlib__List.iter in file "list.ml" (inlined), line 112, characters 12-15
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml" (inlined), line 354, characters 6-372
Called from Stdlib__Fun.protect in file "fun.ml" (inlined), line 33, characters 8-15
Called from Stdlib__Fun.protect in file "fun.ml" (inlined), line 34, characters 8-15
Called from Dynlink_common.Make.load in file "dynlink_common.ml", line 347, characters 4-662
Called from Dynlink_common.Make.loadfile in file "dynlink_common.ml" (inlined), line 366, characters 26-45
Called from Backtrace_dynlink in file "backtrace_dynlink.ml", line 39, characters 4-52
Expand All @@ -17,9 +17,9 @@ Called from Dynlink.Native.run in file "native/dynlink.ml", line 82, characters
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml", line 358, characters 11-54
Called from Stdlib__List.iter in file "list.ml" (inlined), line 112, characters 12-15
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml" (inlined), line 354, characters 6-372
Called from Stdlib__Fun.protect in file "fun.ml" (inlined), line 33, characters 8-15
Called from Stdlib__Fun.protect in file "fun.ml" (inlined), line 34, characters 8-15
Called from Dynlink_common.Make.load in file "dynlink_common.ml", line 347, characters 4-662
Re-raised at Stdlib__Fun.protect in file "fun.ml" (inlined), line 38, characters 6-52
Re-raised at Stdlib__Fun.protect in file "fun.ml" (inlined), line 39, characters 6-52
Called from Dynlink_common.Make.load in file "dynlink_common.ml", line 347, characters 4-662
Called from Dynlink_common.Make.loadfile in file "dynlink_common.ml" (inlined), line 366, characters 26-45
Called from Backtrace_dynlink in file "backtrace_dynlink.ml", line 39, characters 4-52
6 changes: 3 additions & 3 deletions testsuite/tests/backtrace/backtrace_dynlink.reference
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Called from Dynlink.Native.run.(fun) in file "native/dynlink.ml", line 83, chara
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml", line 358, characters 11-54
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Called from Stdlib__Fun.protect in file "fun.ml", line 34, characters 8-15
Called from Dynlink_common.Make.loadfile in file "dynlink_common.ml" (inlined), line 366, characters 26-45
Called from Backtrace_dynlink in file "backtrace_dynlink.ml", line 39, characters 4-52
execution of module initializers in the shared library failed: Failure("SUCCESS")
Expand All @@ -12,7 +12,7 @@ Re-raised at Dynlink.Native.run.(fun) in file "native/dynlink.ml", line 85, char
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml", line 358, characters 11-54
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52
Called from Stdlib__Fun.protect in file "fun.ml", line 34, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 39, characters 6-52
Called from Dynlink_common.Make.loadfile in file "dynlink_common.ml" (inlined), line 366, characters 26-45
Called from Backtrace_dynlink in file "backtrace_dynlink.ml", line 39, characters 4-52
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Called from Dynlink.Bytecode.run in file "byte/dynlink.ml", line 152, characters
Re-raised at Dynlink.Bytecode.run in file "byte/dynlink.ml", line 154, characters 6-137
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml", line 358, characters 11-54
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52
Called from Stdlib__Fun.protect in file "fun.ml", line 34, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 39, characters 6-52
Called from Test10_main in file "test10_main.ml", line 51, characters 13-69
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Re-raised at Dynlink.Native.run.(fun) in file "native/dynlink.ml", line 85, char
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Dynlink_common.Make.load.(fun) in file "dynlink_common.ml", line 358, characters 11-54
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52
Called from Stdlib__Fun.protect in file "fun.ml", line 34, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 39, characters 6-52
Called from Dynlink_common.Make.loadfile in file "dynlink_common.ml" (inlined), line 366, characters 26-45
Called from Test10_main in file "test10_main.ml", line 49, characters 30-87