Commit Graph

32 Commits (master)

Author SHA1 Message Date
Nicolás Ojeda Bär 540996d21e Remove Spacetime 2020-10-08 20:28:12 +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
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 a469b4d0af Implement at_exit with Atomics
Atomic becomes a dependency of Stdlib
2020-05-16 22:58:07 +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
Florian Angeletti c86a5d8d11
#9189: avoid one-letter make variables (#9281) 2020-05-11 12:21:59 +02:00
Nicolás Ojeda Bär dd30bd9786 Share list of modules in StdlibModules 2019-09-29 11:07:50 +02: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 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
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
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 7f6d059f08 Add Float module 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
Jeremie Dimino f15634f562 add Ephemeron to stdlib/StdlibModules 2017-01-13 14:32:03 +00:00
Mark Shinwell cd0bd8aa73 Spacetime: a new memory profiler (#585) 2016-07-29 15:07:10 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Daniel Bünzli 940144f304 Add Uchar module to the standard library. 2015-12-02 14:39:32 +00:00
Damien Doligez cbfe627f92 merge changes from branch 4.02 from branching (rev 14852) to 4.02.0+rc1 (rev 15121)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15125 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-22 13:45:02 +00:00
Damien Doligez 5b8df637d2 merge branch "safe-string"
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14705 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-29 11:56:17 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Damien Doligez 3b507dd1aa renaming of Objective Caml to OCaml and cleanup of copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Michel Mauny 666cb14adf Implement Lazy.force as a primitive, and optimize its calls.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8974 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-08-01 16:57:10 +00:00
Xavier Leroy 30d9dc3229 Ajout module CamlinternalMod (auxiliaires pour la compilation de 'module rec')
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6586 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-08-12 12:57:00 +00:00
Basile Starynkevitch 2020ef749f added cvs id
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5979 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-11-26 10:57:14 +00:00
Xavier Leroy 5e152f7945 - Revu en profondeur la verification des CRC d'interfaces.
Cela corrige le PR#1064.
- Les CRC des modules constituant un programme sont stockes dans
  l'executable bytecode, section CRCS.  Revu Dynlink pour utiliser ces
  CRC au lieu d'attendre de l'utilisateur qu'il les fournisse.
  MAJ du debugger en consequence.
- Introduction et utilisation du fichier stdlib/StdlibModules.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5272 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-11-17 16:42:12 +00:00