Commit Graph

43 Commits (540996d21ee3793a1cecce252c81fb76a6b9fd61)

Author SHA1 Message Date
Nicolás Ojeda Bär 540996d21e Remove Spacetime 2020-10-08 20:28:12 +02:00
Xavier Leroy 1b48b5aa3c
Merge pull request #9872 from xavierleroy/seek-text-channels
Revised {in,out}_channel_length and seek_in for channels in text mode
2020-09-08 09:52:22 +02:00
Xavier Leroy 83c762974b Document the issue with pos_{in,out} and files opened in text mode
Add changes for 9872
2020-09-08 09:51:35 +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
Et7f3 c4851b0ff0
Consistently use @raise tags in Stdlib docs (#8644) 2020-06-30 14:06:45 +01: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
Nicolás Ojeda Bär 4a44bf1767 Expose %loc_FUNCTION as __FUNCTION__ 2020-05-13 20:57:21 +02:00
Christophe Troestler c920ea142b
Fix comment about NaN propagation (#9536)
Fix documentation comment about NaN propagation

Closes: #7891

Co-authored-by: David Allsopp <david.allsopp@metastack.com>
2020-05-12 15:35:04 +02:00
Gabriel Scherer b237282e97 Merge pull request #9270 from gadmm/doc_stack_overflow
Documentation: Stack_overflow is reliable, Out_of_memory is not.
(cherry picked from commit 84f62eee5d26efb936cde0e799b7aaa39e46c010)
2020-01-29 11:08:57 +01:00
Nicolás Ojeda Bär 74c94835b3 Add Unit to stdlib.ml{,i} 2019-03-19 12:29:20 +01:00
Daniel Bünzli f7cf156e19 stdlib.mli: add a stable doc link to the list of modules. 2019-02-19 11:40:57 +00: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
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
Florian Angeletti 9f01a08a2b
Merge pull request #2117 from Octachron/stdlib_precedence_table_3
documentation: precedence table for the standard library.
2018-11-06 22:18:48 +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
Florian Angeletti cbd4f71a39 documentation: move operator table to a new page 2018-11-04 17:49:22 +01:00
Florian Angeletti 5e056cf812 make precedence appendix an appendix 2018-10-26 12:59:47 +02:00
Florian Angeletti c19ba5cab3 review: typo + synchronisation comment 2018-10-26 11:26:07 +02:00
Florian Angeletti bb1c5cd1ae doc: replace ordinal precedence with links 2018-10-25 18:29:32 +02:00
Florian Angeletti a2ab9d0ef2 stdlib documentation: precedence table 2018-10-25 18:29:32 +02: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
octachron 075bf9bed6 doc: remove unprefix trick 2018-09-03 13:59:32 +01:00
Jeremie Dimino 7cf321a3cf Update the deprecation message for Stdlib.Pervasives
Make it point to stdlib-shims
2018-08-28 16:25:45 +01: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
Nicolás Ojeda Bär 4a2b27afd0
Merge pull request #1855 from mseri/pervasive-finally
Add "finally" function to Pervasives
2018-08-08 17:31:01 +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
Marcello Seri 129458bf0f stdlib: address @nojb review comments
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
2018-08-07 20:29:07 +02:00
Marcello Seri 5c0b6f71bd stdlib: rename try_finally to protect
As a result of the poll in #1855.
The votes at the time of commiting are:

- 18 for `protect ~finally`
- 12 for `try_finally ~finally`
- 1  for `finally ~cleanup`
- 0  for `try_finally ~always`
- 0  for `try_finally ~cleanup`

Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
2018-08-07 20:26:05 +02:00
Marcello Seri ecb27c8dab stdlib: simplify try_finally docstring
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
2018-08-07 20:24:53 +02:00
Marcello Seri cbb2ed7833 stdlib: simplify try_finally signature and implementation
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
2018-08-07 20:24:53 +02:00
Marcello Seri 3f2acd87a3 stdlib: use a version of @bobot try_finally
`try_finally work ~always ~exceptionally` is designed to run code
in `work` that may fail with an exception, and has two kind of
cleanup routines:

- `always`, that must be run after **any** execution of the function
  (typically, freeing system resources), and

- `exceptionally`, that should be run **only** if `work` or `always`
  failed with an exception (typically, undoing user-visible state
  changes that would only make sense if the function completes
  correctly).

I had to locally re-define `rab_backtrace`, `get_raw_backtrace`,
`raise_with_backtrace` because I could not refer to `Printexc`.

Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
2018-08-07 20:24:53 +02:00
Marcello Seri 6d4fd3ab5c stdlib: update docstring wording
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
2018-08-07 20:24:52 +02:00
Marcello Seri af9174ff52 stdlib: introduce try_finally in Pervasives
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
2018-08-07 20:24:52 +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
Martin Desharnais 0b31b88849 Uniformise documentation of _opt functions in Pervasive (#1475)
* Uniformise documentation of `_opt` functions in Pervasives

The `option`-returning versions now document the behaviour of the
functions and are refered to by the raising versions using the following
pattern:

> Same as {!Pervasives.f_opt}, but raise [x] instead of returning [None].

* Document function `read_float` raising an exception
2018-05-18 15:28:40 +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
Max Mouratov ae2af8920a stdlib: add a few references to Sys.int_size inside docstrings (#1572) 2018-03-01 18:54:24 +01:00
Jeremie Dimino 84304a3282 Core review work
- Apply the __ heuristic more systematically
- Update tests
- Fix Windows builds
2018-02-12 08:29:17 +00: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