Skip to content

Commit 5b6d9c0

Browse files
committed
Remove Obsoletes for v2
1 parent 3b0dc3d commit 5b6d9c0

File tree

8 files changed

+5
-77
lines changed

8 files changed

+5
-77
lines changed

src/FSharpPlus/Data/NonEmptyList.fs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ type NonEmptyList<'t> = {Head: 't; Tail: 't list} with
1515
interface IReadOnlyList<'t> with member s.Item with get index = s.Item index
1616
interface NonEmptySeq<'t> with member s.First = s.Head
1717

18-
[<System.Obsolete("Use Head instead.")>]
19-
member this.head = let {Head = a; Tail = _} = this in a
20-
21-
[<System.Obsolete("Use Tail instead.")>]
22-
member this.tail = let {Tail = a} = this in a
23-
2418
member this.Item = function 0 -> this.Head | n -> this.Tail.[n-1]
2519
member this.GetSlice = function
2620
| None , None
@@ -334,9 +328,6 @@ module NonEmptyListBuilder =
334328
member _.Yield x = x
335329
member _.Delay expr = expr ()
336330
member _.Run (x: NonEmptyList<_>) = x
337-
338-
[<System.Obsolete("Use nelist instead.")>]
339-
let nel = NelBuilder ()
340331

341332
let nelist = NelBuilder ()
342333

src/FSharpPlus/Data/Validation.fs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,6 @@ module Validation =
128128
| Success a -> g a state
129129
| Failure e -> f e state
130130

131-
[<System.Obsolete("Use Validation.bifoldBack instead.")>]
132-
let biFoldBack f g state x =
133-
match state with
134-
| Success a -> g a x
135-
| Failure e -> f e x
136-
137131
/// Like traverse but taking an additional function to traverse the Failure part as well.
138132
let inline bitraverse (f: 'TError -> '``Functor<'UError>``) (g: 'T -> '``Functor<'U>``) (source: Validation<'TError, 'T>) : '``Functor<Validation<'UError, 'U>>`` =
139133
match source with
@@ -156,18 +150,12 @@ module Validation =
156150
| Failure e -> Failure e
157151
| Success a -> f a
158152

159-
[<System.Obsolete("Use Validation.defaultValue instead.")>]
160-
let orElse v (a: 'a) = match v with | Failure _ -> a | Success x -> x
161-
162153
/// Extracts the Success value or use the supplied default value when it's a Failure.
163154
let defaultValue (value: 'T) (source: Validation<'Error,'T>) : 'T = match source with Success v -> v | _ -> value
164155

165156
/// Extracts the Success value or applies the compensation function over the Failure.
166157
let defaultWith (compensation: 'Error->'T) (source: Validation<'Error,'T>) : 'T = match source with | Success x -> x | Failure e -> compensation e
167158

168-
[<System.Obsolete("Use Validation.defaultWith instead.")>]
169-
let valueOr ea (v: Validation<'e,'a>) = match v with | Failure e -> ea e | Success a -> a
170-
171159
/// Converts a 'Result' to a 'Validation'
172160
/// when the 'Error' of the 'Result' needs to be lifted into a 'Semigroup'.
173161
let liftResult f : (Result<'T,'Error> -> Validation<'Semigroup,'T>) = function Error e -> Failure (f e) | Ok a -> Success a
@@ -216,21 +204,13 @@ module Validation =
216204
/// <returns>The result of applying either functions.</returns>
217205
let either (failureMapper: 'TError -> 'U) (successMapper: 'T -> 'U) source = match source with Success v -> successMapper v | Failure e -> failureMapper e
218206

219-
[<System.Obsolete("This function will not be supported in future versions.")>]
220-
let validate (e: 'e) (p: 'a -> bool) (a: 'a) : Validation<'e,'a> = if p a then Success a else Failure e
221-
222207
#if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4
223208
/// validationNel : Result<'a,'e> -> Validation (NonEmptyList<'e>) a
224209
/// This is 'liftError' specialized to 'NonEmptyList', since
225210
/// they are a common semigroup to use.
226211
let validationNel (x: Result<'T, 'TError>) : (Validation<NonEmptyList<'TError>, 'T>) = (liftResult result) x
227212
#endif
228213

229-
[<System.Obsolete("This function will not be supported in future versions.")>]
230-
let ensure (e: 'e) (p: 'a-> bool) = function
231-
| Failure x -> Failure x
232-
| Success a -> validate e p a
233-
234214
/// Creates a safe version of the supplied function, which returns a Validation<exn, 'U> instead of throwing exceptions.
235215
let protect (unsafeFunction: 'T -> 'U) x =
236216
try

src/FSharpPlus/Extensions/Choice.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ module Choice =
6161
/// <returns>A result of the output type of the binder.</returns>
6262
let bind (binder: 'T->Choice<'U,'T2>) (source: Choice<'T,'T2>) = match source with Choice1Of2 v -> binder v | Choice2Of2 e -> Choice2Of2 e
6363

64-
[<System.Obsolete("Use Choice.bindChoice2Of2")>]
65-
let inline catch (f: 't -> _) = function Choice1Of2 v -> Choice1Of2 v | Choice2Of2 e -> f e : Choice<'v,'e>
64+
/// Like Choice.bindChoice2Of2 but with flipped arguments.
65+
let inline catch x f = x |> function Choice1Of2 v -> Choice1Of2 v | Choice2Of2 e -> f e : Choice<'v,'e>
6666

6767
/// <summary>If the input value is a Choice1Of2 leaves it unchanged, otherwise maps the value on the Choice2Of2 and flattens the resulting nested Choice.</summary>
6868
/// <param name="binder">A function that takes the value of type T and transforms it into a Choice containing (potentially) a value of type U.</param>

src/FSharpPlus/Extensions/Extensions.fs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ module Extensions =
198198
static member SequentialLazy (t: seq<Async<'T>>) : Async<seq<_>> = async {
199199
let! ct = Async.CancellationToken
200200
return Seq.map (fun t -> Async.AsTask(t, ct).Result) t }
201-
[<Obsolete("Renamed to Async.Sequential or Async.SequentialLazy")>]static member Sequence (t: seq<Async<_>>) = Async.SequentialLazy t
201+
202202
#endif
203203

204204
/// Combine all asyncs in one, chaining them in sequence order.
@@ -216,8 +216,6 @@ module Extensions =
216216
coll.Add v
217217
return coll.Close () }
218218
#endif
219-
[<Obsolete("Renamed to Async.Sequential")>]static member Sequence (t: list<Async<'T>>) = Async<_>.Sequential t
220-
221219

222220
/// Combine all asyncs in one, chaining them in sequence order.
223221
static member Sequential (t: array<Async<_>>) : Async<array<_>> = async {
@@ -227,39 +225,30 @@ module Extensions =
227225
let! v = t.[i]
228226
arr.[i] <- v
229227
return arr }
230-
[<Obsolete("Renamed to Async.Sequential")>]static member Sequence (t: array<Async<_>>) = Async<_>.Sequential t
231-
232228

233229
/// Creates an async Result from a Result where the Ok case is async.
234230
static member Sequential (t: Result<Async<'T>, 'Error>) : Async<Result<'T,'Error>> =
235231
match t with
236232
| Ok a -> Async.Map Ok a
237233
| Error e -> async.Return (Error e)
238-
[<Obsolete("Renamed to Async.Sequential")>]static member Sequence (t: Result<Async<'T>, 'Error>) = Async<_>.Sequential t
239-
240234

241235
/// Creates an async Choice from a Choice where the Choice1Of2 case is async.
242236
static member Sequential (t: Choice<Async<'T>, 'Choice2Of2>) : Async<Choice<'T,'Choice2Of2>> =
243237
match t with
244238
| Choice1Of2 a -> Async.Map Choice1Of2 a
245239
| Choice2Of2 e -> async.Return (Choice2Of2 e)
246-
[<Obsolete("Renamed to Async.Sequential")>]static member Sequence (t: Choice<Async<'T>, 'Choice2Of2>) = Async<_>.Sequential t
247-
248240

249241
/// Creates an async Result from a Result where both cases are async.
250242
static member Bisequential (t: Result<Async<'T>, Async<'Error>>) : Async<Result<'T,'Error>> =
251243
match t with
252244
| Ok a -> Async.Map Ok a
253245
| Error e -> Async.Map Error e
254-
[<Obsolete("Renamed to Async.Bisequential")>]static member Bisequence (t: Result<Async<'T>, Async<'Error>>) = Async.Bisequential t
255-
256246

257247
/// Creates an async Choice from a Choice where both cases are async.
258248
static member Bisequential (t: Choice<Async<'T>, Async<'Choice2Of2>>) : Async<Choice<'T,'Choice2Of2>> =
259249
match t with
260250
| Choice1Of2 a -> Async.Map Choice1Of2 a
261251
| Choice2Of2 e -> Async.Map Choice2Of2 e
262-
[<Obsolete("Renamed to Async.Bisequential")>]static member Bisequence (t: Choice<Async<'T>, Async<'Choice2Of2>>) = Async.Bisequential t
263252

264253

265254
type Option<'t> with
@@ -288,7 +277,6 @@ module Extensions =
288277
then None
289278
else accumulator.Close () |> Array.toSeq |> Some
290279
#endif
291-
[<Obsolete("Renamed to Option.Sequential")>]static member Sequence (t: seq<option<'t>>) = Option.Sequential t
292280

293281

294282
type ValueOption<'t> with
@@ -317,7 +305,6 @@ module Extensions =
317305
then ValueNone
318306
else accumulator.Close () |> Array.toSeq |> ValueSome
319307
#endif
320-
[<Obsolete("Renamed to ValueOption.Sequential")>]static member Sequence (t: seq<voption<'t>>) = ValueOption.Sequential t
321308

322309

323310
type Choice<'T1, 'T2> with
@@ -348,7 +335,6 @@ module Extensions =
348335
| ValueNone -> Choice1Of2 (accumulator.Close () |> Array.toSeq)
349336
| ValueSome x -> Choice2Of2 x
350337
#endif
351-
[<Obsolete("Renamed to Choice.Sequential")>]static member Sequence (t: seq<Choice<_, _>>) = Choice<_, _>.Sequential t
352338

353339

354340
/// Returns all Choice2Of2's combined, otherwise a sequence of all Choice1Of2 elements.
@@ -396,7 +382,6 @@ module Extensions =
396382
| ValueNone -> Ok (accumulator.Close () |> Array.toSeq)
397383
| ValueSome x -> Error x
398384
#endif
399-
[<Obsolete("Renamed to Result.Sequential")>]static member Sequence (t: seq<Result<_, _>>) = Result.Sequential t
400385

401386
/// Returns all Errors combined, otherwise a sequence of all elements.
402387
static member Parallel (errorCombiner, t: seq<Result<'T, 'Error>>) =

src/FSharpPlus/Extensions/IReadOnlyDictionary.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ module IReadOnlyDictionary =
6060
dct.Add (k, mapper v)
6161
dct :> IReadOnlyDictionary<'Key, 'U>
6262

63-
[<System.Obsolete("Name is a bit ambiguous, use mapValues if the intention is to map only over the values or mapi to map over both keys and values.")>]
64-
let map f (x: IReadOnlyDictionary<'Key, 'T>) = mapValues f x // F#+ 2: if following F# core naming, it should point to mapi instead.
65-
6663
/// <summary>Creates a read-only dictionary value from a pair of read-only dictionaries,
6764
/// using a function to combine them.</summary>
6865
/// <remarks>Keys that are not present on both read-only dictionaries are dropped.</remarks>

src/FSharpPlus/Extensions/List.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,6 @@ module List =
449449
lst.[0..i-1] @ lst.[i+1..]
450450
else lst
451451

452-
[<Obsolete("This function was included in FSharp.Core but throwing. Use deletaAt instead or if you want to throw exceptions use the full path to removeAt in FSharp.Core until this function is removed from this library")>]
453-
let removeAt i lst = deleteAt i lst
454-
455452
/// <summary>Updates the value of an item in a list</summary>
456453
/// <param name="i">The index of the item to update</param>
457454
/// <param name="x">The new value of the item</param>

src/FSharpPlus/Extensions/Result.fs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ module Result =
66
open FSharp.Core.CompilerServices
77
open System
88

9-
/// Creates an Ok with the supplied value.
10-
[<Obsolete("Prefer Result.Ok")>]
11-
let result value : Result<'T,'Error> = Ok value
12-
13-
/// Creates an Error With the supplied value.
14-
[<Obsolete("Prefer Result.Error")>]
15-
let throw value : Result<'T,'Error> = Error value
16-
179
/// Applies the wrapped value to the wrapped function when both are Ok and returns a wrapped result or the first Error.
1810
/// <param name="f">The function wrapped in an Ok or an Error.</param>
1911
/// <param name="x">The value wrapped in an Ok or an Error.</param>
@@ -78,9 +70,8 @@ module Result =
7870
/// <remarks><c>flatten</c> is equivalent to <c>bind id</c>.</remarks>
7971
let flatten source : Result<'T,'Error> = match source with Ok (Ok v) -> Ok v | Ok (Error e) | Error e -> Error e
8072

81-
// Note: To be fixed in F#+ 2. Arguments should be flipped in order to match the generic catch.
82-
[<System.Obsolete("Use Result.bindError instead.")>]
83-
let inline catch f = function Ok v -> Ok v | Error e -> (f: 't->_) e : Result<'v,'e>
73+
/// Like Result.bindError but with flipped arguments.
74+
let inline catch x f = x |> function Ok v -> Ok v | Error e -> (f: 't->_) e : Result<'v,'e>
8475

8576
/// <summary>If the input value is an Ok leaves it unchanged, otherwise maps the Error value and flattens the resulting nested Result.</summary>
8677
/// <param name="binder">A function that takes the error and transforms it into a result.</param>

src/FSharpPlus/Operators.fs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,6 @@ module Operators =
203203
/// <category index="2">Applicative</category>
204204
let inline lift2 (f: 'T->'U->'V) (x: '``Applicative<'T>``) (y: '``Applicative<'U>``) : '``Applicative<'V>`` = Lift2.Invoke f x y
205205

206-
[<System.Obsolete("Use lift2 instead.")>]
207-
let inline liftA2 (f: 'T->'U->'V) (x: '``Applicative<'T>``) (y: '``Applicative<'U>``) : '``Applicative<'V>`` = lift2 f x y
208-
209206
/// <summary>
210207
/// Applies 3 lifted arguments to a non-lifted function. Equivalent to map3 in non list-like types.
211208
/// </summary>
@@ -224,12 +221,6 @@ module Operators =
224221
/// <category index="2">Applicative</category>
225222
let inline (<* ) (x: '``Applicative<'U>``) (y: '``Applicative<'T>``) : '``Applicative<'U>`` = ((fun (k: 'U) (_: 'T) -> k ) <!> x : '``Applicative<'T->'U>``) <*> y
226223

227-
[<System.Obsolete("Use flip (<*>) instead.")>]
228-
let inline (<**>) (x: '``Applicative<'T>``) : '``Applicative<'T -> 'U>``->'``Applicative<'U>`` = flip (<*>) x
229-
230-
[<System.Obsolete("Use opt instead.")>]
231-
let inline optional v = Some <!> v </Append.Invoke/> result None
232-
233224
/// <summary>
234225
/// Transforms an alternative value (which has the notion of success/failure) to an alternative
235226
/// that always succeed, wrapping the original value into an option to signify success/failure of the original alternative.
@@ -1623,10 +1614,6 @@ module Operators =
16231614
let inline implicit (x: ^T) = ((^R or ^T) : (static member op_Implicit : ^T -> ^R) x) : ^R
16241615

16251616

1626-
[<System.Obsolete("Use Parsed instead.")>]
1627-
/// <category index="23">Additional Functions</category>
1628-
let inline (|Parse|_|) str : 'T option = tryParse str
1629-
16301617
/// <summary>
16311618
/// An active recognizer for a generic value parser.
16321619
/// </summary>

0 commit comments

Comments
 (0)