This PR adjusts the experimental module system to make `private` the default visibility modifier in `module`s, introducing `public` as a new modifier instead. `public section` can be used to revert the default for an entire section, though this is more intended to ease gradual adoption of the new semantics such as in `Init` (and soon `Std`) where they should be replaced by a future decl-by-decl re-review of visibilities.
33 lines
811 B
Text
33 lines
811 B
Text
/-
|
||
Copyright (c) 2025 Lean FRO. All rights reserved.
|
||
Released under Apache 2.0 license as described in the file LICENSE.
|
||
Authors: Sebastian Ullrich
|
||
|
||
Additional `Task` definitions.
|
||
-/
|
||
module
|
||
|
||
prelude
|
||
public import Init.Core
|
||
public import Init.Data.List.Basic
|
||
|
||
public section
|
||
|
||
namespace Task
|
||
|
||
/--
|
||
Creates a task that, when all `tasks` have finished, computes the result of `f` applied to their
|
||
results.
|
||
-/
|
||
def mapList (f : List α → β) (tasks : List (Task α)) (prio := Task.Priority.default)
|
||
(sync := false) : Task β :=
|
||
go tasks []
|
||
where
|
||
go
|
||
| [], as =>
|
||
if sync then
|
||
.pure <| f as.reverse
|
||
else
|
||
Task.spawn (prio := prio) fun _ => f as.reverse
|
||
| [t], as => t.map (fun a => f (a :: as).reverse) prio sync
|
||
| t::ts, as => t.bind (fun a => go ts (a :: as)) prio sync
|