diff --git a/src/FSharp.Core/option.fs b/src/FSharp.Core/option.fs index 720ac9d1c45..46da0ec13a8 100644 --- a/src/FSharp.Core/option.fs +++ b/src/FSharp.Core/option.fs @@ -26,55 +26,55 @@ module Option = | Some _ -> false [] - let defaultValue value option = + let inline defaultValue value option = match option with | None -> value | Some v -> v [] - let defaultWith defThunk option = + let inline defaultWith ([] defThunk) option = match option with | None -> defThunk () | Some v -> v [] - let orElse ifNone option = + let inline orElse ifNone option = match option with | None -> ifNone | Some _ -> option [] - let orElseWith ifNoneThunk option = + let inline orElseWith ([] ifNoneThunk) option = match option with | None -> ifNoneThunk () | Some _ -> option [] - let count option = + let inline count option = match option with | None -> 0 | Some _ -> 1 [] - let fold<'T, 'State> folder (state: 'State) (option: 'T option) = + let inline fold<'T, 'State> ([] folder) (state: 'State) (option: 'T option) = match option with | None -> state | Some x -> folder state x [] - let foldBack<'T, 'State> folder (option: option<'T>) (state: 'State) = + let inline foldBack<'T, 'State> ([] folder) (option: option<'T>) (state: 'State) = match option with | None -> state | Some x -> folder x state [] - let exists predicate option = + let inline exists ([] predicate) option = match option with | None -> false | Some x -> predicate x [] - let forall predicate option = + let inline forall ([] predicate) option = match option with | None -> true | Some x -> predicate x @@ -86,80 +86,80 @@ module Option = | Some v -> v = value [] - let iter action option = + let inline iter ([] action) option = match option with | None -> () | Some x -> action x [] - let map mapping option = + let inline map ([] mapping) option = match option with | None -> None | Some x -> Some(mapping x) [] - let map2 mapping option1 option2 = + let inline map2 ([] mapping) option1 option2 = match option1, option2 with | Some x, Some y -> Some(mapping x y) | _ -> None [] - let map3 mapping option1 option2 option3 = + let inline map3 ([] mapping) option1 option2 option3 = match option1, option2, option3 with | Some x, Some y, Some z -> Some(mapping x y z) | _ -> None [] - let bind binder option = + let inline bind ([] binder) option = match option with | None -> None | Some x -> binder x [] - let flatten option = + let inline flatten option = match option with | None -> None | Some x -> x [] - let filter predicate option = + let inline filter ([] predicate) option = match option with | None -> None | Some x -> if predicate x then Some x else None [] - let toArray option = + let inline toArray option = match option with | None -> [||] | Some x -> [| x |] [] - let toList option = + let inline toList option = match option with | None -> [] | Some x -> [ x ] [] - let toNullable option = + let inline toNullable option = match option with | None -> System.Nullable() | Some v -> System.Nullable(v) [] - let ofNullable (value: System.Nullable<'T>) = + let inline ofNullable (value: System.Nullable<'T>) = if value.HasValue then Some value.Value else None [] - let ofObj value = + let inline ofObj value = match value with | null -> None | _ -> Some value [] - let toObj value = + let inline toObj value = match value with | None -> null | Some x -> x diff --git a/src/FSharp.Core/option.fsi b/src/FSharp.Core/option.fsi index 57d9807e11c..ba65f231932 100644 --- a/src/FSharp.Core/option.fsi +++ b/src/FSharp.Core/option.fsi @@ -56,7 +56,7 @@ module Option = /// /// [] - val defaultValue: value: 'T -> option: 'T option -> 'T + val inline defaultValue: value: 'T -> option: 'T option -> 'T /// Gets the value of the option if the option is Some, otherwise evaluates and returns the result. /// @@ -73,7 +73,7 @@ module Option = /// /// [] - val defaultWith: defThunk: (unit -> 'T) -> option: 'T option -> 'T + val inline defaultWith: defThunk: (unit -> 'T) -> option: 'T option -> 'T /// Returns if it is Some, otherwise returns . /// @@ -91,7 +91,7 @@ module Option = /// /// [] - val orElse: ifNone: 'T option -> option: 'T option -> 'T option + val inline orElse: ifNone: 'T option -> option: 'T option -> 'T option /// Returns if it is Some, otherwise evaluates and returns the result. /// @@ -110,7 +110,7 @@ module Option = /// /// [] - val orElseWith: ifNoneThunk: (unit -> 'T option) -> option: 'T option -> 'T option + val inline orElseWith: ifNoneThunk: (unit -> 'T option) -> option: 'T option -> 'T option /// Gets the value associated with the option. /// @@ -142,7 +142,7 @@ module Option = /// /// [] - val count: option: 'T option -> int + val inline count: option: 'T option -> int /// fold f s inp evaluates to match inp with None -> s | Some x -> f s x. /// @@ -161,7 +161,7 @@ module Option = /// /// [] - val fold<'T, 'State> : folder: ('State -> 'T -> 'State) -> state: 'State -> option: 'T option -> 'State + val inline fold<'T, 'State> : folder: ('State -> 'T -> 'State) -> state: 'State -> option: 'T option -> 'State /// fold f inp s evaluates to match inp with None -> s | Some x -> f x s. /// @@ -180,7 +180,7 @@ module Option = /// /// [] - val foldBack<'T, 'State> : folder: ('T -> 'State -> 'State) -> option: 'T option -> state: 'State -> 'State + val inline foldBack<'T, 'State> : folder: ('T -> 'State -> 'State) -> option: 'T option -> state: 'State -> 'State /// exists p inp evaluates to match inp with None -> false | Some x -> p x. /// @@ -198,7 +198,7 @@ module Option = /// /// [] - val exists: predicate: ('T -> bool) -> option: 'T option -> bool + val inline exists: predicate: ('T -> bool) -> option: 'T option -> bool /// forall p inp evaluates to match inp with None -> true | Some x -> p x. /// @@ -216,7 +216,7 @@ module Option = /// /// [] - val forall: predicate: ('T -> bool) -> option: 'T option -> bool + val inline forall: predicate: ('T -> bool) -> option: 'T option -> bool /// Evaluates to true if is Some and its value is equal to . /// @@ -247,7 +247,7 @@ module Option = /// /// [] - val iter: action: ('T -> unit) -> option: 'T option -> unit + val inline iter: action: ('T -> unit) -> option: 'T option -> unit /// map f inp evaluates to match inp with None -> None | Some x -> Some (f x). /// @@ -263,7 +263,7 @@ module Option = /// /// [] - val map: mapping: ('T -> 'U) -> option: 'T option -> 'U option + val inline map: mapping: ('T -> 'U) -> option: 'T option -> 'U option /// map f option1 option2 evaluates to match option1, option2 with Some x, Some y -> Some (f x y) | _ -> None. /// @@ -282,7 +282,7 @@ module Option = /// /// [] - val map2: mapping: ('T1 -> 'T2 -> 'U) -> option1: 'T1 option -> option2: 'T2 option -> 'U option + val inline map2: mapping: ('T1 -> 'T2 -> 'U) -> option1: 'T1 option -> option2: 'T2 option -> 'U option /// map f option1 option2 option3 evaluates to match option1, option2, option3 with Some x, Some y, Some z -> Some (f x y z) | _ -> None. /// @@ -303,7 +303,7 @@ module Option = /// /// [] - val map3: + val inline map3: mapping: ('T1 -> 'T2 -> 'T3 -> 'U) -> option1: 'T1 option -> option2: 'T2 option -> @@ -330,7 +330,7 @@ module Option = /// /// [] - val bind: binder: ('T -> 'U option) -> option: 'T option -> 'U option + val inline bind: binder: ('T -> 'U option) -> option: 'T option -> 'U option /// flatten inp evaluates to match inp with None -> None | Some x -> x /// @@ -348,7 +348,7 @@ module Option = /// /// [] - val flatten: option: 'T option option -> 'T option + val inline flatten: option: 'T option option -> 'T option /// filter f inp evaluates to match inp with None -> None | Some x -> if f x then Some x else None. /// @@ -365,7 +365,7 @@ module Option = /// /// [] - val filter: predicate: ('T -> bool) -> option: 'T option -> 'T option + val inline filter: predicate: ('T -> bool) -> option: 'T option -> 'T option /// Convert the option to an array of length 0 or 1. /// @@ -380,7 +380,7 @@ module Option = /// /// [] - val toArray: option: 'T option -> 'T[] + val inline toArray: option: 'T option -> 'T[] /// Convert the option to a list of length 0 or 1. /// @@ -395,7 +395,7 @@ module Option = /// /// [] - val toList: option: 'T option -> 'T list + val inline toList: option: 'T option -> 'T list /// Convert the option to a Nullable value. /// @@ -410,7 +410,7 @@ module Option = /// /// [] - val toNullable: option: 'T option -> Nullable<'T> + val inline toNullable: option: 'T option -> Nullable<'T> /// Convert a Nullable value to an option. /// @@ -425,7 +425,7 @@ module Option = /// /// [] - val ofNullable: value: Nullable<'T> -> 'T option + val inline ofNullable: value: Nullable<'T> -> 'T option /// Convert a potentially null value to an option. /// @@ -440,7 +440,7 @@ module Option = /// /// [] - val ofObj: value: 'T -> 'T option when 'T: null + val inline ofObj: value: 'T -> 'T option when 'T: null /// Convert an option to a potentially null value. /// @@ -455,7 +455,7 @@ module Option = /// /// [] - val toObj: value: 'T option -> 'T when 'T: null + val inline toObj: value: 'T option -> 'T when 'T: null /// Contains operations for working with value options. /// diff --git a/tests/projects/SelfContained_Trimming_Test/check.ps1 b/tests/projects/SelfContained_Trimming_Test/check.ps1 index c396f360565..2f1bb61b162 100644 --- a/tests/projects/SelfContained_Trimming_Test/check.ps1 +++ b/tests/projects/SelfContained_Trimming_Test/check.ps1 @@ -14,7 +14,7 @@ if (-not ($output -eq $expected)) } # Checking that FSharp.Core binary is of expected size (needs adjustments if test is updated). -$expected_len = 249856 # In bytes +$expected_len = 249344 # In bytes $file = Get-Item .\bin\Release\net7.0\win-x64\publish\FSharp.Core.dll $file_len = $file.Length if (-not ($file_len -eq $expected_len))