Commit Graph

134 Commits (master)

Author SHA1 Message Date
Vincent Laviron a09a2a20f8 Update .depend 2020-11-21 12:19:18 +01:00
Nicolás Ojeda Bär 540996d21e Remove Spacetime 2020-10-08 20:28:12 +02:00
Florian Angeletti bc4d260de7
Merge pull request #9865 from raphael-proust/pp_print_seq
Stdlib.Format: add pp_print_seq
2020-09-14 16:52:11 +02:00
Jeremy Yallop 1a8aa5428e Add partition_map to ListLabels. 2020-09-03 22:23:00 +02:00
Gabriel Scherer ca6f3ee057 List.partition_map : (a -> (b, c) Either.t) -> a list -> b list * c list 2020-09-02 13:59:53 +02:00
Gabriel Scherer 25e59d63d8 Add `'a Either.t = Left of 'a | Right of 'b`
```ocaml
val left : 'a -> ('a, 'b) t
val right : 'b -> ('a, 'b) t
val is_left : ('a, 'b) t -> bool
val is_right : ('a, 'b) t -> bool
val find_left : ('a, 'b) t -> 'a option
val find_right : ('a, 'b) t -> 'b option
val map_left : ('a1 -> 'a2) -> ('a1, 'b) t -> ('a2, 'b) t
val map_right : ('b1 -> 'b2) -> ('a, 'b1) t -> ('a, 'b2) t
val map : left:('a1 -> 'a2) -> right:('b1 -> 'b2) -> ('a1, 'b1) t -> ('a2, 'b2) t
val fold : left:('a -> 'c) -> right:('b -> 'c) -> ('a, 'b) t -> 'c
val equal :
  left:('a -> 'a -> bool) -> right:('b -> 'b -> bool) ->
  ('a, 'b) t -> ('a, 'b) t -> bool
val compare :
  left:('a -> 'a -> int) -> right:('b -> 'b -> int) ->
  ('a, 'b) t -> ('a, 'b) t -> int
```

Unlike [result], no [either] type is made available in Stdlib,
one needs to access [Either.t] explicitly:

- This type is less common in typical OCaml codebases,
  which prefer domain-specific variant types whose constructors
  carry more meaning.
- Adding this to Stdlib would raise warnings in existing codebases
  that already use a constructor named Left or Right:
  + when opening a module that exports such a name,
    warning 45 is raised
  + adding a second constructor of the same name in scope kicks
    in the disambiguation mechanisms, and warning 41 may now
    be raised by existing code.

If the use becomes more common in the future we can always
revisit this choice.
2020-09-02 13:59:53 +02:00
Raphaël Proust bed23dfbbc Stdlib.Format: add pp_print_seq 2020-09-01 17:51:34 +02:00
Gabriel Scherer bdbf5c30fd
Update camlinternalMod and Obj.new_block for new closure representation (#9691)
* camlinternalMod: use closure metadata for copying a closure over another

This change is careful to avoid writing a value into what was
previously a raw field or conversely, clearing fields that change
category first.

We also clear the end of the block, to make it easier to reason about
lifetime of values that could have been referenced there. (We don't
expect this to make a different in practice.)

* Obj: new submodule Closure giving basic access to closure metadata

* Ensure that Obj.new_block returns a sensible uninitialized closure

* Changes
2020-06-19 17:41:08 +02:00
Guillaume Munch-Maccagnoni 3a1901d873 Fix dune build
Introduce CamlinternalAtomic since Stdlib cannot refer to
Stdlib__-prefixed modules without breaking the dune build.

No change entry needed.
2020-06-10 14:29:21 +02:00
Guillaume Munch-Maccagnoni abe982165b Fix data race in at_exit and Printexc.register_printer with systhreads 2020-05-16 22:57:34 +02:00
Gabriel Scherer 04d9c425f3 stdlib: provide a sequential interface of the Atomic module from OCaml Multicore
This module provides a purely sequential implementation of the
concurrent atomic references provided by the Multicore OCaml
standard library:

https://github.com/ocaml-multicore/ocaml-multicore/blob/parallel_minor_gc/stdlib/atomic.mli

This sequential implementation is provided in the interest of
compatibility: when people will start writing code to run on
Multicore, it would be nice if their use of Atomic was
backward-compatible with older versions of OCaml without having to
import additional compatibility layers. *)
2020-05-16 17:51:54 +02:00
Jacques-Henri Jourdan 7dbbfce890 New ephemeron-free API for Memprof.
The user can register several callbacks, which are called for various
events during the block's lifetime. We need to maintain a data
structure for tracked blocks in the runtime. When using threads,
callbacks can be called concurrently in a reentrant way, so the
functions manipulating this data structure need to be reentrant.
2019-12-21 10:21:48 +01:00
Leo White 74e1a85b72 Update depends 2019-07-10 19:23:21 +01:00
Jacques-Henri Jourdan 052a950dea Statistical memory profiling of blocks allocated in the major heap. 2019-05-09 16:40:45 +02:00
Stephen Dolan 501bd0bb36 Remove use of Obj.truncate from CamlinternalMod.
CamlinternalMod contains an optimisation for the initialisation
of recursive modules containing closures, where dummy closures
are updated in-place. This optimisation was buggy on bytecode,
since the bytecode interpreter relies on the lengths of blocks
containing closures (see #4008).

This commit disables the optimisation for bytecode (where it
had much less effect than on native code, and where performance
is of less concern anyway). The optimisation is still applied
on native-code, but without the use of Obj.truncate.

Also adds a test for #4008 (which introduced the truncate).
2019-04-01 14:10:12 +01:00
Mark Shinwell 2cc1ea26b9 Remove gprof support (#2314)
This commit removes support for gprof-based profiling (the -p option to ocamlopt).  It follows a discussion on the core developers' list, which indicated that removing gprof support was a reasonable thing to do. The rationale is that there are better easy-to-use profilers out there now, such as perf for Linux and Instruments on macOS; and the gprof support has always been patchy across targets. We save a whole build of the runtime and simplify some other parts of the codebase by removing it.
2019-03-16 19:56:53 +01:00
Guillaume Munch-Maccagnoni f68692ebc2 Improve protect
- Treat as an error the case where ~finally raises an exception

- Move to Fun module

- Describe the purpose in the documentation

- Remove boilerplate

https://github.com/ocaml/ocaml/pull/2118
2019-02-03 12:27:27 +01:00
Gabriel Scherer 295f71cb96 make alldepend (with new one-dep-per-file printing) 2018-12-12 09:38:49 +01:00
Thomas Refis f9b8935b2e
make alldepend (#2181) 2018-12-03 18:15:28 +01:00
Leo White fc1e6ad5a2 Update .depend 2018-11-21 03:39:34 -05:00
Stephen Dolan 122c5218e0 Fix a make -j bug, by ensuring Lazy depends on CamlinternalLazy.
Without this patch, make -j often fails to build the stdlib with
a message along the lines of:

    no cmx file was found in path for module CamlinternalLazy

The issue is that stdlib files that use `lazy` actually depend on
camlinternalLazy.cmi because matching.ml expands lazy pattern
matches to code that refers to CamlinternalLazy. However, since
this dependency does not appear in the source code, there is no
way for ocamldep to discover it. This means that when building
the stdlib, there is no constraint ensuring that CamlinternalLazy
is built before stdlib modules using Lazy.

This causes issues with parallel make, but the issue can be
reproduced using a sequential make invocation:

    cd stdlib
    make clean
    make stdlib_stream.cmo

This patch adds a dependency on CamlinternalLazy into lazy.mli.
Its presence makes ocamldep see that all files that use Lazy also
depend on camlinternalLazy.cmi.
2018-11-14 17:33:51 +00:00
Gabriel Scherer 8396c0b8bc make alldepend 2018-11-11 17:20:27 +01:00
yallop ee1c2a4d7e Add paths for built-in types (#1876)
* Add an Extension_constructor submodule to Obj.

Deprecate top-level functions extension_constructor / extension_name /
extension_id.

* Add 'true' and 'false' to the definition of Bool.t

* Add aliases for the built-in 'list' and 'array' types.

* Add an alias for 'exn' to Printexc.

* Changes entry: built-in type aliases

* Add a Unit module.

* Add paths for built-in exceptions.
2018-11-08 16:08:17 +01:00
Daniel Bünzli a7afd89003 s/string_of_int/Int.to_string/g 2018-11-07 13:52:02 +01:00
Daniel Bünzli 89e48a38e9 Stdlib: add Fun module. (#2129)
* Stdlib: add Fun module.

* Stdlib: rename Bool.negate to Fun.negate.
2018-11-06 10:36:07 +01:00
Daniel Bünzli fdba70136f Stdlib: add Bool module. 2018-10-23 11:35:08 +02:00
Daniel Bünzli 5846aecee6 Stdlib: add Int module. 2018-10-09 10:20:39 +02:00
Jérémie Dimino 9124ab82d1
Deprecate Pervasives (#1605)
- inline Pervasives in Stdlib and re-add Pervasives as a deprecated
module that aliases all elements of Stdlib except the stdlib modules.

- remove special case for Stdlib.Pervasives in printtyp.ml
2018-08-27 12:42:14 +01:00
Gabriel Scherer 87855ffcae make alldepend 2018-08-09 22:10:54 +02:00
Daniel Bünzli 1798999b65 Stdlib: add Option module. 2018-08-08 11:41:09 +02:00
Daniel Bünzli b7affbb9ef Stdlib: add Result module. 2018-08-08 10:34:03 +02:00
whitequark 1ebc9f5a4c Remove the Sort module. (PR7812)
It has been deprecated since 2000, shown a deprecation warning
since 4.02, and Sort.merge is documented to have undefined behavior
when the lists being merged are not sorted in the first place.
2018-07-13 16:04:49 +02:00
Jérémie Dimino 32da45a80a Move bigarray to the stdlib (#1685) 2018-04-09 13:14:05 +01:00
Hugo Heuzard 952fe49bac depend 2018-04-05 18:08:30 +01:00
Simon Cruanes df80f34a92 Stdlib functional iterators (#1002)
* add `Seq` module, expose iterator conversions in most containers

* small typo

* typo

* change order of arguments for `{Map,Set}.add_seq`

* watch for max string length in `Bytes.of_seq`

* wip: make it build again

* Fix dependency

Sys needs to be linked before Bytes in stdlib.

* Update threads/stdlib.ml

* Update stdlib_no_prefixed/.depend

* fix inconsistencies with label modules

* update testsuite to work with seq

* update change file

* small change in `Hashtbl.to_seq`, capturing only the underlying array

* add some documentation to seq.mli

* revert to good ol' module type names for hashtables

* fix test

* change style of comments in seq.mli

* follow some demands in review of GPR #1002

* some fixes for #1002

* add Seq-related functions to Ephemeron

* add some comments on `Hashtbl.of_seq`

* add more tests for `Hashtbl.{to,of}_seq`

* fix bug in `Ephemeron.to_seq`

* Update Changes
2018-03-16 18:25:10 +01:00
Nicolás Ojeda Bär 242b6f20a1 make depend 2018-03-15 18:26:51 +01:00
Jeremie Dimino 225d1c65b9 Prefix the compilation unit names of all modules in the stdlib
Except for the Camlinternal* modules and the new Stdlib module, all
modules in the stdlib now compile to Stdlib__<module>.

Pervasives is renamed to Stdlib and now contains a list of aliases
from the long names to the short ones, so that from inside and outside
the stdlib we can refer to the standard modules as just List or
Stdlib.List rather than Stdlib__list.

In order to avoid printing the long names in error messages and in the
toplevel, the following heuristic is added to Printtyp: given a path
Foo__bar, if Foo.Bar exists and is a direct or indirect alias to
Foo__bar, then prefer Foo.Bar.

A bootstrap step was required to replace Pervasives by Stdlib as the
module opened by default.
2018-02-12 08:29:16 +00:00
Sébastien Hinderer 40fcbb5f0a Move configuration header files from the config to the byterun/caml directory
This commit moves:
  - config/m.h to byterun/caml/m.h
  - config/s.h to byterun/caml/s.h

Consequently, m.h and s.h now get installed alongside other
OCaml header files.

This commit also updates the .depend files, introducing updates in the
dependencies which are not consequences of this commit itself.
2017-04-26 19:28:17 +02:00
Daniel Bünzli e0751d932e Add Buffer.add_utf_{8,16be,16le}_uchar and Uchar.{bom,rep} (#1091) 2017-03-16 08:28:11 +00:00
Daniel Bünzli 991ffbe7f7 MPR#7500: remove Uchar.dump (#1081)
and make the Uchar independent from the Format and Printf
modules. Previously this made it impossible to use the type in the
natural habitat that the String, Bytes and Buffer modules could be.
2017-03-07 13:19:04 +01:00
Jérémie Dimino 5ed72007f8 Deprecate Bigarray.*.map_file and add Unix.map_file (#997)
To break the circular dependency between Bigarray and Unix, a CamlinternalBigarray module was added to the stdlib. This module defines all the types used by the compiler to produce optimized code for bigarrays.

Thanks to David Allsopp for fixing Windows tests.
2017-01-10 10:03:24 +00:00
David Allsopp d168db2c78 make alldepend 2016-12-14 13:14:21 +00:00
Mark Shinwell cd0bd8aa73 Spacetime: a new memory profiler (#585) 2016-07-29 15:07:10 +01:00
Damien Doligez 9166e7003e update .depend and bootstrap compilers before release 2016-02-29 14:07:07 +01:00
François Bobot 03ed6a0f51 [Stdlib] Ephemeron: add the module in the stdlib 2016-01-25 08:33:54 +01:00
Mark Shinwell 89cb79b18c fix testsuite 2016-01-12 18:01:45 +01:00
Alain Frisch 4b59df83e0 Merge pull request #80 from dbuenzli/uchar
Add Uchar module to the standard library.
2016-01-06 16:21:04 +01:00
Mark Shinwell 852efd270e Merge with trunk; remake dependencies 2015-12-22 16:28:35 +00:00
Damien Doligez c9003ac48f fix huge pages vs renaming of caml_stat_heap_size 2015-12-21 14:27:46 +01:00
Daniel Bünzli 940144f304 Add Uchar module to the standard library. 2015-12-02 14:39:32 +00:00