Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ocamlformat to 0.27.0 #52

Merged
merged 5 commits into from
Jan 7, 2025

Conversation

mbarbin
Copy link
Contributor

@mbarbin mbarbin commented Jan 5, 2025

Upgrade ocamlformat to current latest version available 0.27.0.

Notable changes with this version:

  • Build on OCaml 5.3.0
  • Enable parsing of doc string by default

Regarding parsing doc-strings, if you don't like this it is possible to disable (use the option parse-docstrings = false to restore the previous behavior). Please let me know if you prefer a PR that would explore doing that instead.

Interestingly, formatting the code examples in the doc string revealed a little bug in one of the examples due to mismatch parsing priorities, for the expression in this list:

        let with_timeout ~give sec fn =
          Miou.await_first
            [ Miou.async @@ fun () -> Miou_unix.sleep sec; raise Timeout
            ; Miou.async ~give fn ] ;;

was actually parsed as:

              ( Miou.async @@ fun () ->
                Miou_unix.sleep sec; raise Timeout; Miou.async ~give fn )

I manually fixed this after applying the fmt by adding parenthesis.

All in, I don't feel strongly about whether the formatting is better or worse (looking at the PR I see instances of slight improvements, and instances of slightly worse formatting). I weakly feel in favor of enabling an automatic formatting to all code in the project, which would now include the code embedded in the doc. I'm imagining it is also nice to have machine assistance to make sure to respect the margin and other considerations while editing the doc comments in the project (although I personally don't have much experience with this option as of yet, so this is just an intuition at this time).

@dinosaure
Copy link
Contributor

From what I've seen of the diff, I don't find it shocking and I appreciate certain aspects of it (particularly the formatting of comments and especially when it comes to defining a raised exception).

I don't look too closely at the diff in relation to ocamlformat in general. It saves me time when it comes to reading PRs globally, so I tend to accept these kinds of changes easily.

Once the PR is ready, I'm ready to merge it 👍.

@mbarbin mbarbin force-pushed the upgrade-ocamlformat branch from 1cdfd5b to fbb38c5 Compare January 6, 2025 19:30
@mbarbin
Copy link
Contributor Author

mbarbin commented Jan 6, 2025

I've tried it a bit yesterday, I found auto-fmt to be nice indeed while editing doc comments (similar experience as with code). I've looked into enabling parse-docstrings in some of my projects too while I was at it.

Enabled for review.

@mbarbin mbarbin marked this pull request as ready for review January 6, 2025 19:39
@dinosaure
Copy link
Contributor

Thanks!

@dinosaure dinosaure merged commit a8a7f39 into robur-coop:main Jan 7, 2025
1 check passed
@mbarbin mbarbin deleted the upgrade-ocamlformat branch January 7, 2025 19:52
dinosaure added a commit to dinosaure/opam-repository that referenced this pull request Jan 13, 2025
CHANGES:

- Notice the domain if it needs to look into the shared heap if a task is ready
  to be transfered (@dinosaure, robur-coop/miou#41)
- Don't use `Option.value` but `match .. with` to calculate the optional length
  for `Miou_unix.{read,write}` (@kit-ty-kate, robur-coop/miou#44)
- Use `List.iter` instead of `Hashtbl.iter` for internal kept file-descriptors
  of `Miou_unix` (@dinosaure, robur-coop/miou#45)
- Improve the documentation of `Miou_unix` about suspended syscalls (@dinosaure,
  @kit-ty-kate, robur-coop/miou#43)
- Export `reraise` (@dinosaure, robur-coop/miou#46)
- Fix an issue on the `dom0` and observe if some tasks must be transfered to it
  (@dinosaure, robur-coop/miou#48)
- Fix documentation (@mbarbin, robur-coop/miou#47)
- Fix the formatter (@mbarbin, robur-coop/miou#51)
- Upgrade miou to `ocamlformat.0.27.0` (@mbarbin, robur-coop/miou#52)
- Add `x-maintenance-intent` (@hannesm, robur-coop/miou#56)
- Improve the documentation and some `odoc` warnings (@mbarbin, robur-coop/miou#53, robur-coop/miou#54)
davesnx pushed a commit to davesnx/opam-repository that referenced this pull request Mar 12, 2025
CHANGES:

- Don't try to abusively fill the pipe to interrupt a domain

  Interrupting a domain involves writing to a pipe to interrupt the `select(2)`
  if it is running. The pipe has a limited memory, depending on the system, and
  if you ask to interrupt a domain too much, you end up blocking the `write`.
  This patch prevents writing to the pipe if it has not yet been read.

  (@dinosaure, robur-coop/miou#46)

- Expose the Sequence module
  (@dinosaure, robur-coop/miou#47)
- Be able to add a hook (effect free) into the scheduler

  It is possible to add a hook to the scheduler. If the user wants to execute a
  function to a domain each time the domain is busy with a task, they can do so.
  However, the effects are not managed in the passed function.

  (@dinosaure, robur-coop/miou#48)

- Add `Miou.Lazy`, a domain-safe `Lazy` module like `Stdlib.Lazy`
  (@dinosaure, initially implemented by @polytypic, robur-coop/miou#49)
- Raise an exception if the user uses syscalls (from `Miou_unix`) and `Miou.run`
  instead of `Miou_unix.run`

  If a user uses a suspend function offered by `Miou_unix` but does not use
  `Miou_unix.run`, the programme may block indefinitely. This patch prevents
  such an error by raising an exception if we want to add a suspension point and
  we haven't specified how to handle it (if we use `Miou.run` instead of
  `Miou_unix.run`).

  (@dinosaure, reported by @kit-ty-kate, robur-coop/miou#51)

- Rename `Miou.set_signal` to `Miou.sys_signal`
  (@dinosaure, robur-coop/miou#50)

- Improve `Miou_unix.{read,write}`
  (@kit-ty-kate, @dinosaure, robur-coop/miou#52, 2f552a6, robur-coop/miou#54)
- Fix an issue related to the dom0 and pending tasks locked by mutexes

  Tasks may have been transmitted to dom0 while it was executing a task and
  before the `select(2)`. This patch resynchronises the pending tasks in dom0's
  TODO-list before making the `select(2)`: specifically to find out whether the
  `select(2)` can block indefinitely or not. This patch also cleans up the old
  states of the tables used by `Miou_unix` if it is used on an ongoing basis (as
  in the case of tests).

  (@dinosaure, robur-coop/miou#53)

- Add `Miou.Domain.available`
  (@dinosaure, robur-coop/miou#53)
- Fix a race condition (observed with TSan) when we wait the cancellation of a
  children

  This patch changes Miou's behaviour a little when waiting for a task to be
  cancelled and prevents invalid access to a value that does not belong to the
  current domain (and which can be modified by another domain). Thanks
  @OlivierNicole and @fabbing for their advice on using TSan.

  (@dinosaure, robur-coop/miou#56)

- Update the layout of Miou to avoid conflicts with other packages (like `backoff`)
  (@dinosaure, reported by @patricoferris, robur-coop/miou#57)
- OCaml 5.3 support
  (@kit-ty-kate, github#22)
- Rename `Miou.call_cc` to `Miou.async`
  (@dinosaure, @kit-ty-kate, @Armael, github#23)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants