Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,17 @@ Agents discover servers from [.mcp.json](../.mcp.json); these are only hints on
/// <param name="id">Item Id</param>
```

* Keep `<summary>` and `<remarks>` on one line each only when both are short – up to 60 characters of text each. When either is longer, write both over several lines, with each opening and closing tag on a line of its own:
* Write each of `<summary>` and `<remarks>` on one line when its own text is short – up to 60 characters – and over several lines, with each opening and closing tag on a line of its own, when it is longer. The two are independent: a short `<remarks>` takes one line under a long `<summary>`:

```fsharp
/// <summary>Returns the number of elements.</summary>
/// <remarks>This is an O(1) operation.</remarks>

/// <summary>
/// Returns the only element of the list, and throws when the list does not have exactly one element.
/// </summary>
/// <remarks>This is an O(1) operation.</remarks>

/// <summary>
/// The inputs of the set contracts as rows of <c>DynamicData</c>: none, one and several elements.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

* `FlatList` has every function of the FSharp.Core `Array` module that applies to an immutable array, with its semantics
and exceptions, plus `add`, `asMemory`, `asSpan`, `binarySearch`, `binarySearchRange`, `binarySearchRangeWithComparer`,
`binarySearchWithComparer`, `indexOf`, `indexOfRange`, `indexOfRangeWith`, `indexOfWith`, `lastIndexOf`,
`lastIndexOfRange`, `lastIndexOfRangeWith`, `lastIndexOfWith`, `ofReadOnlySpan`, `ofSpan`, `remove`, `removeMany`,
`removeManyWith`, `removeWith`, `replace`, `replaceWith`, `skipLast` and `takeLast`. `remove` and `removeMany` remove by
value in `EqualityComparer<'T>.Default`, and the `With` variants take an equality comparer. The functions that wrap a
member of `ImmutableArray<'T>` throw what the member throws.
and exceptions, plus `add`, `asMemory`, `asSpan`, `binarySearch`, `binarySearchRange`,
`binarySearchRangeWithComparer`, `binarySearchWithComparer`, `clear`, `indexOf`, `indexOfRange`, `indexOfRangeWith`,
`indexOfWith`, `lastIndexOf`, `lastIndexOfRange`, `lastIndexOfRangeWith`, `lastIndexOfWith`, `ofReadOnlySpan`,
`ofSpan`, `remove`, `removeMany`, `removeManyWith`, `removeWith`, `replace`, `replaceWith`, `skipLast` and `takeLast`.
`remove` and `removeMany` remove by value in `EqualityComparer<'T>.Default`, and the `With` variants take an equality
comparer. The functions that wrap a member of `ImmutableArray<'T>` throw what the member throws.
* The `FSharp.Collections.Immutable.Option.FlatList` and `FSharp.Collections.Immutable.Tuple.FlatList` modules repeat the
functions that use value options or struct tuples with options and reference tuples.
* The `FlatListBuilder` module works on the builder of a flat list: `add`, `addRange`, `blit`, `capacity`, `clear`,
Expand Down
5 changes: 2 additions & 3 deletions build/CheckOrder.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <summary>
/// Checks the order of the functions in the signature files of the library and in their implementation files
/// (ADR 0001, D4).
/// Checks the order of the functions in the signature files of the library and in their implementation files.
/// </summary>
/// <remarks>
/// <para>
Expand Down Expand Up @@ -30,7 +29,7 @@ open Fantomas.FCS.Text
[<Struct>]
type Violation = { Path : string; Line : int; Message : string }

/// The canonical category sequence of ADR 0001, D4.
/// The canonical category sequence.
let private categories = [|
"Creation"
"Builder"
Expand Down
2 changes: 1 addition & 1 deletion build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ let checkFormatCode ctx =
else
Trace.logf "Errors while formatting: %A" result.Errors

/// Checks the category banners and the alphabetical order of the functions in the signature files (ADR 0001, D4)
/// Checks the category banners and the alphabetical order of the functions in the signature files
let checkOrder _ =
let struct (fileCount, violations) = CheckOrder.check (rootDirectory </> "src")

Expand Down
4 changes: 1 addition & 3 deletions src/FSharp.Collections.Immutable/ComputationExpressions.fsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/// <summary>
/// The computation expressions of the collections (ADR 0001, D7).
/// </summary>
/// <summary>The computation expressions of the collections.</summary>
[<AutoOpen>]
module FSharp.Collections.Immutable.ComputationExpressions

Expand Down
33 changes: 19 additions & 14 deletions src/FSharp.Collections.Immutable/FlatList/FlatList.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open System.Collections.Immutable
open System.Runtime.InteropServices

// Most functions unwrap the underlying array without a copy, call the FSharp.Core Array function, and wrap its fresh
// result without a copy (ADR 0001, D5), so that they have the semantics and the exceptions of the Array module (D6).
// result without a copy, so that they have the semantics and the exceptions of the Array module.

// ---- Creation ----

Expand All @@ -26,7 +26,7 @@ let ofArray (array : 'T array) = Array.copy array |> wrapArray

[<CompiledName "OfList">]
let ofList (list : 'T list) =
// Array.ofList dereferences a null list without a check; a null input throws ArgumentNullException here (ADR 0001, D6)
// Array.ofList dereferences a null list without a check; a null input throws ArgumentNullException here
checkNotNull (nameof list) list
Array.ofList list |> wrapArray

Expand All @@ -36,7 +36,7 @@ let ofReadOnlySpan (span : ReadOnlySpan<'T>) = ImmutableArray.Create<'T> span
[<CompiledName "OfSeq">]
let ofSeq (source : seq<'T>) =
match source with
// An immutable array needs no copy; a default one is a default FlatList, which no function accepts (ADR 0001, D6)
// An immutable array needs no copy; a default one is a default FlatList, which no function accepts
| :? ImmutableArray<'T> as array ->
checkNotDefault (nameof source) array
array
Expand Down Expand Up @@ -585,7 +585,7 @@ let zip3 (array1 : FlatList<'T1>) (array2 : FlatList<'T2>) (array3 : FlatList<'T

// The inline functions can use public members only, so they check and unwrap the array themselves
[<CompiledName "Average">]
let inline average (array : FlatList< ^T >) : ^T =
let inline average (array : FlatList<'T>) : 'T =
if array.IsDefault then
nullArg (nameof array)

Expand All @@ -595,7 +595,7 @@ let inline average (array : FlatList< ^T >) : ^T =
)

[<CompiledName "AverageBy">]
let inline averageBy ([<InlineIfLambda>] projection : 'T -> ^U) (array : FlatList<'T>) : ^U =
let inline averageBy ([<InlineIfLambda>] projection : 'T -> 'U) (array : FlatList<'T>) : 'U =
if array.IsDefault then
nullArg (nameof array)

Expand Down Expand Up @@ -693,7 +693,7 @@ let scanBack (folder : 'T -> 'State -> 'State) (array : FlatList<'T>) (state : '
|> wrapArray

[<CompiledName "Sum">]
let inline sum (array : FlatList< ^T >) : ^T =
let inline sum (array : FlatList<'T>) : 'T =
if array.IsDefault then
nullArg (nameof array)

Expand All @@ -703,7 +703,7 @@ let inline sum (array : FlatList< ^T >) : ^T =
)

[<CompiledName "SumBy">]
let inline sumBy ([<InlineIfLambda>] projection : 'T -> ^U) (array : FlatList<'T>) : ^U =
let inline sumBy ([<InlineIfLambda>] projection : 'T -> 'U) (array : FlatList<'T>) : 'U =
if array.IsDefault then
nullArg (nameof array)

Expand Down Expand Up @@ -752,7 +752,7 @@ let partitionWith (partitioner : 'T -> Choice<'T1, 'T2>) (array : FlatList<'T>)
struct (wrapArray first, wrapArray second)

// The range functions repeat the checks of Array.skip, Array.take and Array.splitAt and then slice: a slice copies the
// selected elements, unless the range is empty or covers the whole array (ADR 0001, D5)
// selected elements, unless the range is empty or covers the whole array

[<CompiledName "Skip">]
let skip count (array : FlatList<'T>) =
Expand Down Expand Up @@ -990,7 +990,7 @@ let asSpan (array : FlatList<'T>) =
[<CompiledName "CopyTo">]
let blit (source : FlatList<'T>) sourceIndex (target : 'T array) targetIndex count =
let items = unwrapArray (nameof source) source
// Array.blit reports a null target under the name of the BCL, destinationArray; the name is the parameter's here (D6)
// Array.blit reports a null target under the name of the BCL, destinationArray; the name is the parameter's here
checkNotNull (nameof target) target
Array.blit items sourceIndex target targetIndex count

Expand All @@ -1007,14 +1007,19 @@ let toSeq (array : FlatList<'T>) =

// ---- Type-specific ----

[<CompiledName "Clear">]
let clear (array : FlatList<'T>) =
checkNotDefault (nameof array) array
array.Clear ()

[<CompiledName "IsDefault">]
let isDefault (array : FlatList<'T>) = array.IsDefault

[<CompiledName "IsDefaultOrEmpty">]
let isDefaultOrEmpty (array : FlatList<'T>) = array.IsDefaultOrEmpty

// Most functions unwrap the underlying array without a copy, call the Array.Parallel function, and wrap its fresh result
// without a copy (ADR 0001, D11), so that they have the semantics and the exceptions of Array.Parallel. Where the
// without a copy, so that they have the semantics and the exceptions of Array.Parallel. Where the
// Array.Parallel function takes or returns options or builds a tuple per element or per group (choose, tryFind,
// tryFindIndex, tryPick, zip, groupBy), an algorithm of ParallelArrays with value options and struct tuples runs instead.
// Array.Parallel sorts a copy of its input, so the shared array is never changed.
Expand Down Expand Up @@ -1101,7 +1106,7 @@ module Parallel =

// The inline functions can use public members only, so they check and unwrap the array themselves
[<CompiledName "Average">]
let inline average (array : FlatList< ^T >) : ^T =
let inline average (array : FlatList<'T>) : 'T =
if array.IsDefault then
nullArg (nameof array)

Expand All @@ -1111,7 +1116,7 @@ module Parallel =
)

[<CompiledName "AverageBy">]
let inline averageBy ([<InlineIfLambda>] projection : 'T -> ^U) (array : FlatList<'T>) : ^U =
let inline averageBy ([<InlineIfLambda>] projection : 'T -> 'U) (array : FlatList<'T>) : 'U =
if array.IsDefault then
nullArg (nameof array)

Expand Down Expand Up @@ -1148,7 +1153,7 @@ module Parallel =
// Array.Parallel.sum dereferences a null array without a check; a default flat list throws ArgumentNullException,
// which its documentation promises
[<CompiledName "Sum">]
let inline sum (array : FlatList< ^T >) : ^T =
let inline sum (array : FlatList<'T>) : 'T =
if array.IsDefault then
nullArg (nameof array)

Expand All @@ -1158,7 +1163,7 @@ module Parallel =
)

[<CompiledName "SumBy">]
let inline sumBy ([<InlineIfLambda>] projection : 'T -> ^U) (array : FlatList<'T>) : ^U =
let inline sumBy ([<InlineIfLambda>] projection : 'T -> 'U) (array : FlatList<'T>) : 'U =
if array.IsDefault then
nullArg (nameof array)

Expand Down
Loading
Loading