From ac46e9bf5c71bb92cd56eb1b401b1da95d517307 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sat, 25 Nov 2023 12:35:32 +0100 Subject: [PATCH 01/12] + Failing test --- tests/FSharpPlus.Tests/General.fs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/FSharpPlus.Tests/General.fs b/tests/FSharpPlus.Tests/General.fs index ee15954da..f6f9b0a3e 100644 --- a/tests/FSharpPlus.Tests/General.fs +++ b/tests/FSharpPlus.Tests/General.fs @@ -220,6 +220,13 @@ type WrappedSeqE<'s> = WrappedSeqE of 's seq with static member Reduce (WrappedSeqE x, reduction) = SideEffects.add "Using WrappedSeqE's Reduce"; Seq.reduce reduction x static member ToSeq (WrappedSeqE x) = SideEffects.add "Using WrappedSeqE's ToSeq"; x +type WrappedSeqF<'s> = WrappedSeqF of 's seq with + interface Collections.Generic.IEnumerable<'s> with member x.GetEnumerator () = (let (WrappedSeqF x) = x in x).GetEnumerator () + interface Collections.IEnumerable with member x.GetEnumerator () = (let (WrappedSeqF x) = x in x).GetEnumerator () :> Collections.IEnumerator + static member Return x = SideEffects.add "Using WrappedSeqF's Return"; WrappedSeqF (Seq.singleton x) + static member (<*>) (WrappedSeqF f, WrappedSeqF x) = SideEffects.add "Using WrappedSeqF's Apply"; WrappedSeqF (f <*> x) + static member ToList (WrappedSeqF x) = Seq.toList x + type TestNonEmptyCollection<'a> = private { Singleton: 'a } with interface NonEmptySeq<'a> with member this.First = @@ -1205,6 +1212,18 @@ module Applicative = Assert.AreEqual ([4;5;6], res456) Assert.AreEqual (toList (run res9n5), toList (run' res9n5')) + // WrappedSeqC is Monad. Monads are Applicatives => (<*>) should work + let (res3: WrappedSeqC<_>) = WrappedSeqC [(+) 1] <*> WrappedSeqC [2] + CollectionAssert.AreEqual (WrappedSeqC [3], res3) + + // Check user defined types implementing IEnumerable don't default to seq<_> + let res4 = WrappedSeqF [(+) 1] <*> WrappedSeqF [3] + Assert.IsInstanceOf>> (Some res4) + CollectionAssert.AreEqual (WrappedSeqF [4], res4) + let res5 = WrappedSeqF [(+)] <*> WrappedSeqF [3] <*> WrappedSeqF [2] + Assert.IsInstanceOf>> (Some res5) + CollectionAssert.AreEqual (WrappedSeqF [5], res5) + let testLift2 () = let expectedEffects = ["Using WrappedSeqD's Return"; "Using WrappedSeqD's Apply"; "Using WrappedSeqD's Apply"] SideEffects.reset () From ee0f250ccfb798b77054b1c9877481c9ceffb54a Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Wed, 22 Nov 2023 09:11:43 +0100 Subject: [PATCH 02/12] Use strict types for applicatives --- src/FSharpPlus/Control/Applicative.fs | 59 ++++++++++++++------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index a14764b9c..cfdfd80d0 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -16,38 +16,35 @@ type Apply = #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 - static member inline ``<*>`` (f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` , []_output: '``Monad<'U>`` , []_mthd:Default2) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) - static member inline ``<*>`` (f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``, []_output: '``Applicative<'U>``, []_mthd:Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x) - - static member ``<*>`` (f: Lazy<'T->'U> , x: Lazy<'T> , []_output: Lazy<'U> , []_mthd: Apply) = Lazy.apply f x : Lazy<'U> - static member ``<*>`` (f: seq<_> , x: seq<'T> , []_output: seq<'U> , []_mthd: Apply) = Seq.apply f x : seq<'U> - static member ``<*>`` (f: NonEmptySeq<_> , x: NonEmptySeq<'T> , []_output: NonEmptySeq<'U> , []_mthd: Apply) = NonEmptySeq.apply f x : NonEmptySeq<'U> - static member ``<*>`` (f: IEnumerator<_> , x: IEnumerator<'T> , []_output: IEnumerator<'U> , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> - static member ``<*>`` (f: list<_> , x: list<'T> , []_output: list<'U> , []_mthd: Apply) = List.apply f x : list<'U> - static member ``<*>`` (f: _ [] , x: 'T [] , []_output: 'U [] , []_mthd: Apply) = Array.apply f x : 'U [] - static member ``<*>`` (f: 'r -> _ , g: _ -> 'T , []_output: 'r -> 'U , []_mthd: Apply) = fun x -> let f' = f x in f' (g x) : 'U - static member inline ``<*>`` ((a: 'Monoid, f) , (b: 'Monoid, x: 'T) , []_output: 'Monoid * 'U , []_mthd: Apply) = (Plus.Invoke a b, f x) : 'Monoid *'U - static member inline ``<*>`` (struct (a: 'Monoid, f), struct (b: 'Monoid, x: 'T), []_output: struct ('Monoid * 'U), []_mthd: Apply) = struct (Plus.Invoke a b, f x) : struct ('Monoid * 'U) + static member ``<*>`` ((f: Lazy<'T->'U> , x: Lazy<'T> , _output: Lazy<'U> ) , []_mthd: Apply) = Lazy.apply f x : Lazy<'U> + static member ``<*>`` ((f: seq<_> , x: seq<'T> , _output: seq<'U> ) , []_mthd: Apply) = Seq.apply f x : seq<'U> + static member ``<*>`` ((f: NonEmptySeq<_> , x: NonEmptySeq<'T> , _output: NonEmptySeq<'U> ) , []_mthd: Apply) = NonEmptySeq.apply f x : NonEmptySeq<'U> + static member ``<*>`` ((f: IEnumerator<_> , x: IEnumerator<'T> , _output: IEnumerator<'U> ) , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> + static member ``<*>`` ((f: list<_> , x: list<'T> , _output: list<'U> ) , []_mthd: Apply) = List.apply f x : list<'U> + static member ``<*>`` ((f: _ [] , x: 'T [] , _output: 'U [] ) , []_mthd: Apply) = Array.apply f x : 'U [] + static member ``<*>`` ((f: 'r -> _ , g: _ -> 'T , _output: 'r -> 'U ) , []_mthd: Apply) = fun x -> let f' = f x in f' (g x) : 'U + static member inline ``<*>`` (((a: 'Monoid, f) , (b: 'Monoid, x: 'T) , _output: 'Monoid * 'U ) , []_mthd: Apply) = (Plus.Invoke a b, f x) : 'Monoid *'U + static member inline ``<*>`` ((struct (a: 'Monoid, f), struct (b: 'Monoid, x: 'T), _output: struct ('Monoid * 'U)), []_mthd: Apply) = struct (Plus.Invoke a b, f x) : struct ('Monoid * 'U) #if !FABLE_COMPILER - static member ``<*>`` (f: Task<_> , x: Task<'T> , []_output: Task<'U> , []_mthd: Apply) = Task.apply f x : Task<'U> + static member ``<*>`` ((f: Task<_> , x: Task<'T> , _output: Task<'U> ) , []_mthd: Apply) = Task.apply f x : Task<'U> #endif #if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER - static member ``<*>`` (f: ValueTask<_> , x: ValueTask<'T> , []_output: ValueTask<'U> , []_mthd: Apply) = ValueTask.apply f x : ValueTask<'U> + static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> , _output: ValueTask<'U> ) , []_mthd: Apply) = ValueTask.apply f x : ValueTask<'U> #endif - static member ``<*>`` (f: Async<_> , x: Async<'T> , []_output: Async<'U> , []_mthd: Apply) = Async.apply f x : Async<'U> - static member ``<*>`` (f: option<_> , x: option<'T> , []_output: option<'U> , []_mthd: Apply) = Option.apply f x : option<'U> - static member ``<*>`` (f: voption<_> , x: voption<'T> , []_output: voption<'U> , []_mthd: Apply) = ValueOption.apply f x : voption<'U> - static member ``<*>`` (f: Result<_,'E> , x: Result<'T,'E> , []_output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> - static member ``<*>`` (f: Choice<_,'E> , x: Choice<'T,'E> , []_output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> - static member inline ``<*>`` (KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T), []_output: KeyValuePair<'Key,'U>, []_mthd: Apply) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - - static member ``<*>`` (f: Map<'Key,_> , x: Map<'Key,'T> , []_output: Map<'Key,'U> , []_mthd: Apply) : Map<'Key,'U> = Map (seq { + static member ``<*>`` ((f: Async<_> , x: Async<'T> , _output: Async<'U> ) , []_mthd: Apply) = Async.apply f x : Async<'U> + static member ``<*>`` ((f: option<_> , x: option<'T> , _output: option<'U> ) , []_mthd: Apply) = Option.apply f x : option<'U> + static member ``<*>`` ((f: voption<_> , x: voption<'T> , _output: voption<'U> ) , []_mthd: Apply) = ValueOption.apply f x : voption<'U> + static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> , _output: Result<'b,'E> ) , []_mthd: Apply) = Result.apply f x : Result<'U,'E> + static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> , _output: Choice<'b,'E> ) , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> + static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T), _output: KeyValuePair<'Key,'U>), []_mthd: Apply) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) + + static member ``<*>`` ((f: Map<'Key,_> , x: Map<'Key,'T> , _output: Map<'Key,'U> ) , []_mthd: Apply) : Map<'Key,'U> = Map (seq { for KeyValue(k, vf) in f do match Map.tryFind k x with | Some vx -> yield k, vf vx | _ -> () }) - static member ``<*>`` (f: Dictionary<'Key,_>, x: Dictionary<'Key,'T> , []_output: Dictionary<'Key,'U> , []_mthd: Apply) : Dictionary<'Key,'U> = + static member ``<*>`` ((f: Dictionary<'Key,_>, x: Dictionary<'Key,'T> , _output: Dictionary<'Key,'U> ) , []_mthd: Apply) : Dictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -55,7 +52,7 @@ type Apply = | _ -> () dct - static member ``<*>`` (f: IDictionary<'Key,_>, x: IDictionary<'Key,'T> , []_output: IDictionary<'Key,'U> , []_mthd: Apply) : IDictionary<'Key,'U> = + static member ``<*>`` ((f: IDictionary<'Key,_>, x: IDictionary<'Key,'T> , _output: IDictionary<'Key,'U> ) , []_mthd: Apply) : IDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -63,7 +60,7 @@ type Apply = | _ -> () dct :> IDictionary<'Key,'U> - static member ``<*>`` (f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T> , []_output: IReadOnlyDictionary<'Key,'U> , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = + static member ``<*>`` ((f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T> , _output: IReadOnlyDictionary<'Key,'U> ) , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -72,13 +69,13 @@ type Apply = dct :> IReadOnlyDictionary<'Key,'U> #if !FABLE_COMPILER - static member ``<*>`` (f: Expr<'T->'U>, x: Expr<'T>, []_output: Expr<'U>, []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) + static member ``<*>`` ((f: Expr<'T->'U>, x: Expr<'T>, _output: Expr<'U>), []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) #endif - static member ``<*>`` (f: ('T->'U) ResizeArray, x: 'T ResizeArray, []_output: 'U ResizeArray, []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray + static member ``<*>`` ((f: ('T->'U) ResizeArray, x: 'T ResizeArray, _output: 'U ResizeArray), []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray static member inline Invoke (f: '``Applicative<'T -> 'U>``) (x: '``Applicative<'T>``) : '``Applicative<'U>`` = let inline call (mthd : ^M, input1: ^I1, input2: ^I2, output: ^R) = - ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : _*_*_*_ -> _) input1, input2, output, mthd) + ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : (_*_*_)*_ -> _) (input1, input2, output), mthd) call(Unchecked.defaultof, f, x, Unchecked.defaultof<'``Applicative<'U>``>) @@ -89,6 +86,12 @@ type Apply = #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 +type Apply with + static member inline ``<*>`` ((f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` , _output: '``Monad<'U>`` ), []_mthd:Default2) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) + static member inline ``<*>`` ((_: ^t when ^t : null and ^t: struct, _: ^u when ^u : null and ^u: struct, _output: ^r when ^r : null and ^r: struct), _mthd: Default1) = id + static member inline ``<*>`` ((f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``, _output: '``Applicative<'U>``), []_mthd:Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x) + + type Lift2 = inherit Default1 From 25baab4099406023a5ab9436361f09813925ab2c Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Wed, 22 Nov 2023 10:36:22 +0100 Subject: [PATCH 03/12] Ambiguate keyValuePair --- src/FSharpPlus/Control/Applicative.fs | 6 ++++++ src/FSharpPlus/Internals.fs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index cfdfd80d0..d8f63e23b 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -37,6 +37,12 @@ type Apply = static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> , _output: Result<'b,'E> ) , []_mthd: Apply) = Result.apply f x : Result<'U,'E> static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> , _output: Choice<'b,'E> ) , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T), _output: KeyValuePair<'Key,'U>), []_mthd: Apply) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) + static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>, _output: KeyValuePair2<'Key,'U>), []_mthd: Apply) : KeyValuePair2<'Key,'U> = + let a = f.Key + let b = x.Key + let f = f.Value + let x = x.Value + KeyValuePair2 (Plus.Invoke a b, f x) static member ``<*>`` ((f: Map<'Key,_> , x: Map<'Key,'T> , _output: Map<'Key,'U> ) , []_mthd: Apply) : Map<'Key,'U> = Map (seq { for KeyValue(k, vf) in f do diff --git a/src/FSharpPlus/Internals.fs b/src/FSharpPlus/Internals.fs index 2329828ff..b9b008bdb 100644 --- a/src/FSharpPlus/Internals.fs +++ b/src/FSharpPlus/Internals.fs @@ -125,6 +125,12 @@ type Either<'t,'u> = type DmStruct = struct end +type KeyValuePair2<'TKey, 'TValue> = struct + val Key : 'TKey + val Value : 'TValue + new (key, value) = { Key = key; Value = value } +end + [] type Set2<'T when 'T: comparison >() = class end From 029ed98686b2d76ea5be24e71d33a3758d9ab05c Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Wed, 22 Nov 2023 22:10:07 +0100 Subject: [PATCH 04/12] Tuple only input arguments --- src/FSharpPlus/Control/Applicative.fs | 59 ++++++++++++++------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index d8f63e23b..620353c2d 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -13,44 +13,44 @@ open FSharpPlus.Data type Apply = inherit Default1 - + #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 - static member ``<*>`` ((f: Lazy<'T->'U> , x: Lazy<'T> , _output: Lazy<'U> ) , []_mthd: Apply) = Lazy.apply f x : Lazy<'U> - static member ``<*>`` ((f: seq<_> , x: seq<'T> , _output: seq<'U> ) , []_mthd: Apply) = Seq.apply f x : seq<'U> - static member ``<*>`` ((f: NonEmptySeq<_> , x: NonEmptySeq<'T> , _output: NonEmptySeq<'U> ) , []_mthd: Apply) = NonEmptySeq.apply f x : NonEmptySeq<'U> - static member ``<*>`` ((f: IEnumerator<_> , x: IEnumerator<'T> , _output: IEnumerator<'U> ) , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> - static member ``<*>`` ((f: list<_> , x: list<'T> , _output: list<'U> ) , []_mthd: Apply) = List.apply f x : list<'U> - static member ``<*>`` ((f: _ [] , x: 'T [] , _output: 'U [] ) , []_mthd: Apply) = Array.apply f x : 'U [] - static member ``<*>`` ((f: 'r -> _ , g: _ -> 'T , _output: 'r -> 'U ) , []_mthd: Apply) = fun x -> let f' = f x in f' (g x) : 'U - static member inline ``<*>`` (((a: 'Monoid, f) , (b: 'Monoid, x: 'T) , _output: 'Monoid * 'U ) , []_mthd: Apply) = (Plus.Invoke a b, f x) : 'Monoid *'U - static member inline ``<*>`` ((struct (a: 'Monoid, f), struct (b: 'Monoid, x: 'T), _output: struct ('Monoid * 'U)), []_mthd: Apply) = struct (Plus.Invoke a b, f x) : struct ('Monoid * 'U) + static member ``<*>`` ((f: Lazy<'T->'U> , x: Lazy<'T> ) , _output: Lazy<'U> , []_mthd: Apply) = Lazy.apply f x : Lazy<'U> + static member ``<*>`` ((f: seq<_> , x: seq<'T> ) , _output: seq<'U> , []_mthd: Apply) = Seq.apply f x : seq<'U> + static member ``<*>`` ((f: NonEmptySeq<_> , x: NonEmptySeq<'T> ) , _output: NonEmptySeq<'U> , []_mthd: Apply) = NonEmptySeq.apply f x : NonEmptySeq<'U> + static member ``<*>`` ((f: IEnumerator<_> , x: IEnumerator<'T> ) , _output: IEnumerator<'U> , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> + static member ``<*>`` ((f: list<_> , x: list<'T> ) , _output: list<'U> , []_mthd: Apply) = List.apply f x : list<'U> + static member ``<*>`` ((f: _ [] , x: 'T [] ) , _output: 'U [] , []_mthd: Apply) = Array.apply f x : 'U [] + static member ``<*>`` ((f: 'r -> _ , g: _ -> 'T ) , _output: 'r -> 'U , []_mthd: Apply) = fun x -> let f' = f x in f' (g x) : 'U + static member inline ``<*>`` (((a: 'Monoid, f) , (b: 'Monoid, x: 'T) ) , _output: 'Monoid * 'U , []_mthd: Apply) = (Plus.Invoke a b, f x) : 'Monoid *'U + static member inline ``<*>`` ((struct (a: 'Monoid, f), struct (b: 'Monoid, x: 'T)), _output: struct ('Monoid * 'U), []_mthd: Apply) = struct (Plus.Invoke a b, f x) : struct ('Monoid * 'U) #if !FABLE_COMPILER - static member ``<*>`` ((f: Task<_> , x: Task<'T> , _output: Task<'U> ) , []_mthd: Apply) = Task.apply f x : Task<'U> + static member ``<*>`` ((f: Task<_> , x: Task<'T> ), _output: Task<'U> , []_mthd: Apply) = Task.apply f x : Task<'U> #endif #if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER - static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> , _output: ValueTask<'U> ) , []_mthd: Apply) = ValueTask.apply f x : ValueTask<'U> + static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Apply) = ValueTask.apply f x : ValueTask<'U> #endif - static member ``<*>`` ((f: Async<_> , x: Async<'T> , _output: Async<'U> ) , []_mthd: Apply) = Async.apply f x : Async<'U> - static member ``<*>`` ((f: option<_> , x: option<'T> , _output: option<'U> ) , []_mthd: Apply) = Option.apply f x : option<'U> - static member ``<*>`` ((f: voption<_> , x: voption<'T> , _output: voption<'U> ) , []_mthd: Apply) = ValueOption.apply f x : voption<'U> - static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> , _output: Result<'b,'E> ) , []_mthd: Apply) = Result.apply f x : Result<'U,'E> - static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> , _output: Choice<'b,'E> ) , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> - static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T), _output: KeyValuePair<'Key,'U>), []_mthd: Apply) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>, _output: KeyValuePair2<'Key,'U>), []_mthd: Apply) : KeyValuePair2<'Key,'U> = + static member ``<*>`` ((f: Async<_> , x: Async<'T> ), _output: Async<'U> , []_mthd: Apply) = Async.apply f x : Async<'U> + static member ``<*>`` ((f: option<_> , x: option<'T> ), _output: option<'U> , []_mthd: Apply) = Option.apply f x : option<'U> + static member ``<*>`` ((f: voption<_> , x: voption<'T> ), _output: voption<'U> , []_mthd: Apply) = ValueOption.apply f x : voption<'U> + static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> + static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> + static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Apply) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) + static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Apply) : KeyValuePair2<'Key,'U> = let a = f.Key let b = x.Key let f = f.Value let x = x.Value KeyValuePair2 (Plus.Invoke a b, f x) - static member ``<*>`` ((f: Map<'Key,_> , x: Map<'Key,'T> , _output: Map<'Key,'U> ) , []_mthd: Apply) : Map<'Key,'U> = Map (seq { + static member ``<*>`` ((f: Map<'Key,_> , x: Map<'Key,'T> ) , _output: Map<'Key,'U> , []_mthd: Apply) : Map<'Key,'U> = Map (seq { for KeyValue(k, vf) in f do match Map.tryFind k x with | Some vx -> yield k, vf vx | _ -> () }) - static member ``<*>`` ((f: Dictionary<'Key,_>, x: Dictionary<'Key,'T> , _output: Dictionary<'Key,'U> ) , []_mthd: Apply) : Dictionary<'Key,'U> = + static member ``<*>`` ((f: Dictionary<'Key,_>, x: Dictionary<'Key,'T>) , _output: Dictionary<'Key,'U> , []_mthd: Apply) : Dictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -58,7 +58,7 @@ type Apply = | _ -> () dct - static member ``<*>`` ((f: IDictionary<'Key,_>, x: IDictionary<'Key,'T> , _output: IDictionary<'Key,'U> ) , []_mthd: Apply) : IDictionary<'Key,'U> = + static member ``<*>`` ((f: IDictionary<'Key,_>, x: IDictionary<'Key,'T>) , _output: IDictionary<'Key,'U> , []_mthd: Apply) : IDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -66,7 +66,7 @@ type Apply = | _ -> () dct :> IDictionary<'Key,'U> - static member ``<*>`` ((f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T> , _output: IReadOnlyDictionary<'Key,'U> ) , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = + static member ``<*>`` ((f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T>) , _output: IReadOnlyDictionary<'Key,'U> , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -75,13 +75,13 @@ type Apply = dct :> IReadOnlyDictionary<'Key,'U> #if !FABLE_COMPILER - static member ``<*>`` ((f: Expr<'T->'U>, x: Expr<'T>, _output: Expr<'U>), []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) + static member ``<*>`` ((f: Expr<'T->'U>, x: Expr<'T>), _output: Expr<'U>, []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) #endif - static member ``<*>`` ((f: ('T->'U) ResizeArray, x: 'T ResizeArray, _output: 'U ResizeArray), []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray + static member ``<*>`` ((f: ('T->'U) ResizeArray, x: 'T ResizeArray), _output: 'U ResizeArray, []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray static member inline Invoke (f: '``Applicative<'T -> 'U>``) (x: '``Applicative<'T>``) : '``Applicative<'U>`` = let inline call (mthd : ^M, input1: ^I1, input2: ^I2, output: ^R) = - ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : (_*_*_)*_ -> _) (input1, input2, output), mthd) + ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : (_*_)*_*_ -> _) (input1, input2), output, mthd) call(Unchecked.defaultof, f, x, Unchecked.defaultof<'``Applicative<'U>``>) @@ -93,9 +93,10 @@ type Apply = #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 type Apply with - static member inline ``<*>`` ((f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` , _output: '``Monad<'U>`` ), []_mthd:Default2) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) - static member inline ``<*>`` ((_: ^t when ^t : null and ^t: struct, _: ^u when ^u : null and ^u: struct, _output: ^r when ^r : null and ^r: struct), _mthd: Default1) = id - static member inline ``<*>`` ((f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``, _output: '``Applicative<'U>``), []_mthd:Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x) + static member inline ``<*>`` ((f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` ) , _output: '``Monad<'U>`` , []_mthd:Default2) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) + static member inline ``<*>`` ((_: ^t when ^t : null and ^t: struct, _: ^u when ^u : null and ^u: struct), _output: ^r when ^r : null and ^r: struct, _mthd: Default1) = id + + static member inline ``<*>`` ((f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``), _output: '``Applicative<'U>``, []_mthd: Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x) type Lift2 = From d71abc6cb07b6844cf972969108014b4525ad36a Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Wed, 22 Nov 2023 23:37:31 +0100 Subject: [PATCH 05/12] Lower priority of problematic overloads --- src/FSharpPlus/Control/Applicative.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index 620353c2d..ebd1030c2 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -29,15 +29,15 @@ type Apply = static member ``<*>`` ((f: Task<_> , x: Task<'T> ), _output: Task<'U> , []_mthd: Apply) = Task.apply f x : Task<'U> #endif #if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER - static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Apply) = ValueTask.apply f x : ValueTask<'U> + static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Default1) = ValueTask.apply f x : ValueTask<'U> #endif static member ``<*>`` ((f: Async<_> , x: Async<'T> ), _output: Async<'U> , []_mthd: Apply) = Async.apply f x : Async<'U> static member ``<*>`` ((f: option<_> , x: option<'T> ), _output: option<'U> , []_mthd: Apply) = Option.apply f x : option<'U> static member ``<*>`` ((f: voption<_> , x: voption<'T> ), _output: voption<'U> , []_mthd: Apply) = ValueOption.apply f x : voption<'U> static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> - static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Apply) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Apply) : KeyValuePair2<'Key,'U> = + static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default1) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) + static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default1) : KeyValuePair2<'Key,'U> = let a = f.Key let b = x.Key let f = f.Value From bbb72b4a45838fd6524474bc7d08bb376568f9bf Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Wed, 22 Nov 2023 23:59:45 +0100 Subject: [PATCH 06/12] Lower them more --- src/FSharpPlus/Control/Applicative.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index ebd1030c2..b67f8bcff 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -29,15 +29,15 @@ type Apply = static member ``<*>`` ((f: Task<_> , x: Task<'T> ), _output: Task<'U> , []_mthd: Apply) = Task.apply f x : Task<'U> #endif #if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER - static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Default1) = ValueTask.apply f x : ValueTask<'U> + static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Default3) = ValueTask.apply f x : ValueTask<'U> #endif static member ``<*>`` ((f: Async<_> , x: Async<'T> ), _output: Async<'U> , []_mthd: Apply) = Async.apply f x : Async<'U> static member ``<*>`` ((f: option<_> , x: option<'T> ), _output: option<'U> , []_mthd: Apply) = Option.apply f x : option<'U> static member ``<*>`` ((f: voption<_> , x: voption<'T> ), _output: voption<'U> , []_mthd: Apply) = ValueOption.apply f x : voption<'U> static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> - static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default1) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default1) : KeyValuePair2<'Key,'U> = + static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default3) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) + static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default3) : KeyValuePair2<'Key,'U> = let a = f.Key let b = x.Key let f = f.Value @@ -93,7 +93,7 @@ type Apply = #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 type Apply with - static member inline ``<*>`` ((f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` ) , _output: '``Monad<'U>`` , []_mthd:Default2) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) + static member inline ``<*>`` ((f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` ) , _output: '``Monad<'U>`` , []_mthd:Default3) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) static member inline ``<*>`` ((_: ^t when ^t : null and ^t: struct, _: ^u when ^u : null and ^u: struct), _output: ^r when ^r : null and ^r: struct, _mthd: Default1) = id static member inline ``<*>`` ((f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``), _output: '``Applicative<'U>``, []_mthd: Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x) From 64e91bdd72043a1e7354c1344b8956607ae15fc4 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Thu, 23 Nov 2023 08:50:57 +0100 Subject: [PATCH 07/12] Ambiguate KeyValuePair in Map --- src/FSharpPlus/Control/Functor.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FSharpPlus/Control/Functor.fs b/src/FSharpPlus/Control/Functor.fs index c7d356dc6..2058fd069 100644 --- a/src/FSharpPlus/Control/Functor.fs +++ b/src/FSharpPlus/Control/Functor.fs @@ -89,6 +89,7 @@ type Map = static member Map ((x: Result<_,'E> , f: 'T->'U), _mthd: Map) = Result.map f x static member Map ((x: Choice<_,'E> , f: 'T->'U), _mthd: Map) = Choice.map f x static member Map ((KeyValue(k, x) , f: 'T->'U), _mthd: Map) = KeyValuePair (k, f x) + static member Map ((x: KeyValuePair2<_, _> , f: 'T->'U), _mthd: Map) = let k, x = x.Key, x.Value in KeyValuePair2 (k, f x) static member Map ((x: Map<'Key,'T> , f: 'T->'U), _mthd: Map) = Map.map (const' f) x : Map<'Key,'U> static member Map ((x: Dictionary<_,_> , f: 'T->'U), _mthd: Map) = Dictionary.map f x : Dictionary<'Key,'U> #if !FABLE_COMPILER From bdfe1f21d9b73d0c44c9b23ec74c630e896e8cdd Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Fri, 24 Nov 2023 07:47:49 +0100 Subject: [PATCH 08/12] Use DmStruct2 --- src/FSharpPlus/Control/Applicative.fs | 7 +------ src/FSharpPlus/Control/Functor.fs | 2 +- src/FSharpPlus/Internals.fs | 1 + 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index b67f8bcff..6d2c340db 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -37,12 +37,7 @@ type Apply = static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default3) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default3) : KeyValuePair2<'Key,'U> = - let a = f.Key - let b = x.Key - let f = f.Value - let x = x.Value - KeyValuePair2 (Plus.Invoke a b, f x) + static member inline ``<*>`` ((_: DmStruct2<'Key, _>, _: DmStruct2<'Key, 'T>) , _output: DmStruct2<'Key,'U> , []_mthd: Default3) : DmStruct2<'Key,'U> = Unchecked.defaultof> static member ``<*>`` ((f: Map<'Key,_> , x: Map<'Key,'T> ) , _output: Map<'Key,'U> , []_mthd: Apply) : Map<'Key,'U> = Map (seq { for KeyValue(k, vf) in f do diff --git a/src/FSharpPlus/Control/Functor.fs b/src/FSharpPlus/Control/Functor.fs index 2058fd069..09a5196fa 100644 --- a/src/FSharpPlus/Control/Functor.fs +++ b/src/FSharpPlus/Control/Functor.fs @@ -89,7 +89,7 @@ type Map = static member Map ((x: Result<_,'E> , f: 'T->'U), _mthd: Map) = Result.map f x static member Map ((x: Choice<_,'E> , f: 'T->'U), _mthd: Map) = Choice.map f x static member Map ((KeyValue(k, x) , f: 'T->'U), _mthd: Map) = KeyValuePair (k, f x) - static member Map ((x: KeyValuePair2<_, _> , f: 'T->'U), _mthd: Map) = let k, x = x.Key, x.Value in KeyValuePair2 (k, f x) + static member Map ((_: DmStruct2<'T, 'E> , _: 'T->'U), _mthd: Map) = Unchecked.defaultof> static member Map ((x: Map<'Key,'T> , f: 'T->'U), _mthd: Map) = Map.map (const' f) x : Map<'Key,'U> static member Map ((x: Dictionary<_,_> , f: 'T->'U), _mthd: Map) = Dictionary.map f x : Dictionary<'Key,'U> #if !FABLE_COMPILER diff --git a/src/FSharpPlus/Internals.fs b/src/FSharpPlus/Internals.fs index b9b008bdb..8b7262da0 100644 --- a/src/FSharpPlus/Internals.fs +++ b/src/FSharpPlus/Internals.fs @@ -124,6 +124,7 @@ type Either<'t,'u> = | Right of 'u type DmStruct = struct end +type DmStruct2<'T1, 'T2> = struct end type KeyValuePair2<'TKey, 'TValue> = struct val Key : 'TKey From 6a3280b2f7c52602c5e39b7d4530055b681919eb Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Fri, 24 Nov 2023 09:58:45 +0100 Subject: [PATCH 09/12] Revert "Use DmStruct2" This reverts commit cce7f3507ce4e80d09b848a43b49b3ca692f13f3. --- src/FSharpPlus/Control/Applicative.fs | 11 ++++++++--- src/FSharpPlus/Control/Functor.fs | 2 +- src/FSharpPlus/Internals.fs | 1 - 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index 6d2c340db..39eda1fe0 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -37,7 +37,12 @@ type Apply = static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default3) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` ((_: DmStruct2<'Key, _>, _: DmStruct2<'Key, 'T>) , _output: DmStruct2<'Key,'U> , []_mthd: Default3) : DmStruct2<'Key,'U> = Unchecked.defaultof> + static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default3) : KeyValuePair2<'Key,'U> = + let a = f.Key + let b = x.Key + let f = f.Value + let x = x.Value + KeyValuePair2 (Plus.Invoke a b, f x) static member ``<*>`` ((f: Map<'Key,_> , x: Map<'Key,'T> ) , _output: Map<'Key,'U> , []_mthd: Apply) : Map<'Key,'U> = Map (seq { for KeyValue(k, vf) in f do @@ -60,7 +65,7 @@ type Apply = | true, vx -> dct.Add (k, vf vx) | _ -> () dct :> IDictionary<'Key,'U> - + static member ``<*>`` ((f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T>) , _output: IReadOnlyDictionary<'Key,'U> , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do @@ -73,7 +78,7 @@ type Apply = static member ``<*>`` ((f: Expr<'T->'U>, x: Expr<'T>), _output: Expr<'U>, []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) #endif static member ``<*>`` ((f: ('T->'U) ResizeArray, x: 'T ResizeArray), _output: 'U ResizeArray, []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray - + static member inline Invoke (f: '``Applicative<'T -> 'U>``) (x: '``Applicative<'T>``) : '``Applicative<'U>`` = let inline call (mthd : ^M, input1: ^I1, input2: ^I2, output: ^R) = ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : (_*_)*_*_ -> _) (input1, input2), output, mthd) diff --git a/src/FSharpPlus/Control/Functor.fs b/src/FSharpPlus/Control/Functor.fs index 09a5196fa..2058fd069 100644 --- a/src/FSharpPlus/Control/Functor.fs +++ b/src/FSharpPlus/Control/Functor.fs @@ -89,7 +89,7 @@ type Map = static member Map ((x: Result<_,'E> , f: 'T->'U), _mthd: Map) = Result.map f x static member Map ((x: Choice<_,'E> , f: 'T->'U), _mthd: Map) = Choice.map f x static member Map ((KeyValue(k, x) , f: 'T->'U), _mthd: Map) = KeyValuePair (k, f x) - static member Map ((_: DmStruct2<'T, 'E> , _: 'T->'U), _mthd: Map) = Unchecked.defaultof> + static member Map ((x: KeyValuePair2<_, _> , f: 'T->'U), _mthd: Map) = let k, x = x.Key, x.Value in KeyValuePair2 (k, f x) static member Map ((x: Map<'Key,'T> , f: 'T->'U), _mthd: Map) = Map.map (const' f) x : Map<'Key,'U> static member Map ((x: Dictionary<_,_> , f: 'T->'U), _mthd: Map) = Dictionary.map f x : Dictionary<'Key,'U> #if !FABLE_COMPILER diff --git a/src/FSharpPlus/Internals.fs b/src/FSharpPlus/Internals.fs index 8b7262da0..b9b008bdb 100644 --- a/src/FSharpPlus/Internals.fs +++ b/src/FSharpPlus/Internals.fs @@ -124,7 +124,6 @@ type Either<'t,'u> = | Right of 'u type DmStruct = struct end -type DmStruct2<'T1, 'T2> = struct end type KeyValuePair2<'TKey, 'TValue> = struct val Key : 'TKey From 4f8ab5cacf9d55f864634a43302c067932b92486 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:33:22 +0100 Subject: [PATCH 10/12] Use value tuples --- src/FSharpPlus/Control/Applicative.fs | 57 +++++++++++++-------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index 39eda1fe0..418033159 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -16,41 +16,41 @@ type Apply = #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 - static member ``<*>`` ((f: Lazy<'T->'U> , x: Lazy<'T> ) , _output: Lazy<'U> , []_mthd: Apply) = Lazy.apply f x : Lazy<'U> - static member ``<*>`` ((f: seq<_> , x: seq<'T> ) , _output: seq<'U> , []_mthd: Apply) = Seq.apply f x : seq<'U> - static member ``<*>`` ((f: NonEmptySeq<_> , x: NonEmptySeq<'T> ) , _output: NonEmptySeq<'U> , []_mthd: Apply) = NonEmptySeq.apply f x : NonEmptySeq<'U> - static member ``<*>`` ((f: IEnumerator<_> , x: IEnumerator<'T> ) , _output: IEnumerator<'U> , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> - static member ``<*>`` ((f: list<_> , x: list<'T> ) , _output: list<'U> , []_mthd: Apply) = List.apply f x : list<'U> - static member ``<*>`` ((f: _ [] , x: 'T [] ) , _output: 'U [] , []_mthd: Apply) = Array.apply f x : 'U [] - static member ``<*>`` ((f: 'r -> _ , g: _ -> 'T ) , _output: 'r -> 'U , []_mthd: Apply) = fun x -> let f' = f x in f' (g x) : 'U - static member inline ``<*>`` (((a: 'Monoid, f) , (b: 'Monoid, x: 'T) ) , _output: 'Monoid * 'U , []_mthd: Apply) = (Plus.Invoke a b, f x) : 'Monoid *'U - static member inline ``<*>`` ((struct (a: 'Monoid, f), struct (b: 'Monoid, x: 'T)), _output: struct ('Monoid * 'U), []_mthd: Apply) = struct (Plus.Invoke a b, f x) : struct ('Monoid * 'U) + static member ``<*>`` (struct (f: Lazy<'T->'U> , x: Lazy<'T> ) , _output: Lazy<'U> , []_mthd: Apply) = Lazy.apply f x : Lazy<'U> + static member ``<*>`` (struct (f: seq<_> , x: seq<'T> ) , _output: seq<'U> , []_mthd: Apply) = Seq.apply f x : seq<'U> + static member ``<*>`` (struct (f: NonEmptySeq<_> , x: NonEmptySeq<'T> ) , _output: NonEmptySeq<'U> , []_mthd: Apply) = NonEmptySeq.apply f x : NonEmptySeq<'U> + static member ``<*>`` (struct (f: IEnumerator<_> , x: IEnumerator<'T> ) , _output: IEnumerator<'U> , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> + static member ``<*>`` (struct (f: list<_> , x: list<'T> ) , _output: list<'U> , []_mthd: Apply) = List.apply f x : list<'U> + static member ``<*>`` (struct (f: _ [] , x: 'T [] ) , _output: 'U [] , []_mthd: Apply) = Array.apply f x : 'U [] + static member ``<*>`` (struct (f: 'r -> _ , g: _ -> 'T ) , _output: 'r -> 'U , []_mthd: Apply) = fun x -> let f' = f x in f' (g x) : 'U + static member inline ``<*>`` (struct ((a: 'Monoid, f) , (b: 'Monoid, x: 'T) ) , _output: 'Monoid * 'U , []_mthd: Apply) = (Plus.Invoke a b, f x) : 'Monoid *'U + static member inline ``<*>`` (struct (struct (a: 'Monoid, f), struct (b: 'Monoid, x: 'T)), _output: struct ('Monoid * 'U), []_mthd: Apply) = struct (Plus.Invoke a b, f x) : struct ('Monoid * 'U) #if !FABLE_COMPILER - static member ``<*>`` ((f: Task<_> , x: Task<'T> ), _output: Task<'U> , []_mthd: Apply) = Task.apply f x : Task<'U> + static member ``<*>`` (struct (f: Task<_> , x: Task<'T> ), _output: Task<'U> , []_mthd: Apply) = Task.apply f x : Task<'U> #endif #if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER - static member ``<*>`` ((f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Default3) = ValueTask.apply f x : ValueTask<'U> + static member ``<*>`` (struct (f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Default3) = ValueTask.apply f x : ValueTask<'U> #endif - static member ``<*>`` ((f: Async<_> , x: Async<'T> ), _output: Async<'U> , []_mthd: Apply) = Async.apply f x : Async<'U> - static member ``<*>`` ((f: option<_> , x: option<'T> ), _output: option<'U> , []_mthd: Apply) = Option.apply f x : option<'U> - static member ``<*>`` ((f: voption<_> , x: voption<'T> ), _output: voption<'U> , []_mthd: Apply) = ValueOption.apply f x : voption<'U> - static member ``<*>`` ((f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> - static member ``<*>`` ((f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> - static member inline ``<*>`` ((KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default3) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` ((f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default3) : KeyValuePair2<'Key,'U> = + static member ``<*>`` (struct (f: Async<_> , x: Async<'T> ), _output: Async<'U> , []_mthd: Apply) = Async.apply f x : Async<'U> + static member ``<*>`` (struct (f: option<_> , x: option<'T> ), _output: option<'U> , []_mthd: Apply) = Option.apply f x : option<'U> + static member ``<*>`` (struct (f: voption<_> , x: voption<'T> ), _output: voption<'U> , []_mthd: Apply) = ValueOption.apply f x : voption<'U> + static member ``<*>`` (struct (f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> + static member ``<*>`` (struct (f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> + static member inline ``<*>`` (struct (KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default3) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) + static member inline ``<*>`` (struct (f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default3) : KeyValuePair2<'Key,'U> = let a = f.Key let b = x.Key let f = f.Value let x = x.Value KeyValuePair2 (Plus.Invoke a b, f x) - static member ``<*>`` ((f: Map<'Key,_> , x: Map<'Key,'T> ) , _output: Map<'Key,'U> , []_mthd: Apply) : Map<'Key,'U> = Map (seq { + static member ``<*>`` (struct (f: Map<'Key,_> , x: Map<'Key,'T> ) , _output: Map<'Key,'U> , []_mthd: Apply) : Map<'Key,'U> = Map (seq { for KeyValue(k, vf) in f do match Map.tryFind k x with | Some vx -> yield k, vf vx | _ -> () }) - static member ``<*>`` ((f: Dictionary<'Key,_>, x: Dictionary<'Key,'T>) , _output: Dictionary<'Key,'U> , []_mthd: Apply) : Dictionary<'Key,'U> = + static member ``<*>`` (struct (f: Dictionary<'Key,_>, x: Dictionary<'Key,'T>) , _output: Dictionary<'Key,'U> , []_mthd: Apply) : Dictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -58,7 +58,7 @@ type Apply = | _ -> () dct - static member ``<*>`` ((f: IDictionary<'Key,_>, x: IDictionary<'Key,'T>) , _output: IDictionary<'Key,'U> , []_mthd: Apply) : IDictionary<'Key,'U> = + static member ``<*>`` (struct (f: IDictionary<'Key,_>, x: IDictionary<'Key,'T>) , _output: IDictionary<'Key,'U> , []_mthd: Apply) : IDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -66,7 +66,7 @@ type Apply = | _ -> () dct :> IDictionary<'Key,'U> - static member ``<*>`` ((f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T>) , _output: IReadOnlyDictionary<'Key,'U> , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = + static member ``<*>`` (struct (f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T>) , _output: IReadOnlyDictionary<'Key,'U> , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do match x.TryGetValue k with @@ -75,16 +75,15 @@ type Apply = dct :> IReadOnlyDictionary<'Key,'U> #if !FABLE_COMPILER - static member ``<*>`` ((f: Expr<'T->'U>, x: Expr<'T>), _output: Expr<'U>, []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) + static member ``<*>`` (struct (f: Expr<'T->'U>, x: Expr<'T>), _output: Expr<'U>, []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) #endif - static member ``<*>`` ((f: ('T->'U) ResizeArray, x: 'T ResizeArray), _output: 'U ResizeArray, []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray + static member ``<*>`` (struct (f: ('T->'U) ResizeArray, x: 'T ResizeArray), _output: 'U ResizeArray, []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray static member inline Invoke (f: '``Applicative<'T -> 'U>``) (x: '``Applicative<'T>``) : '``Applicative<'U>`` = let inline call (mthd : ^M, input1: ^I1, input2: ^I2, output: ^R) = - ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : (_*_)*_*_ -> _) (input1, input2), output, mthd) + ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : struct (_*_) * _ * _ -> _) (struct (input1, input2)), output, mthd) call(Unchecked.defaultof, f, x, Unchecked.defaultof<'``Applicative<'U>``>) - #endif static member inline InvokeOnInstance (f: '``Applicative<'T->'U>``) (x: '``Applicative<'T>``) : '``Applicative<'U>`` = @@ -93,10 +92,10 @@ type Apply = #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 type Apply with - static member inline ``<*>`` ((f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` ) , _output: '``Monad<'U>`` , []_mthd:Default3) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) - static member inline ``<*>`` ((_: ^t when ^t : null and ^t: struct, _: ^u when ^u : null and ^u: struct), _output: ^r when ^r : null and ^r: struct, _mthd: Default1) = id + static member inline ``<*>`` (struct (f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` ) , _output: '``Monad<'U>`` , []_mthd:Default3) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) + static member inline ``<*>`` (struct (_: ^t when ^t : null and ^t: struct, _: ^u when ^u : null and ^u: struct), _output: ^r when ^r : null and ^r: struct, _mthd: Default1) = id - static member inline ``<*>`` ((f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``), _output: '``Applicative<'U>``, []_mthd: Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x) + static member inline ``<*>`` (struct (f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``), _output: '``Applicative<'U>``, []_mthd: Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x) type Lift2 = From 9474025fb7a20b355900d07fe4e95ee43b77b2cd Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:04:09 +0100 Subject: [PATCH 11/12] Align code --- src/FSharpPlus/Control/Applicative.fs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index 418033159..384b0f827 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -37,11 +37,9 @@ type Apply = static member ``<*>`` (struct (f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> static member ``<*>`` (struct (f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> static member inline ``<*>`` (struct (KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default3) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` (struct (f: KeyValuePair2<'Key, _>, x: KeyValuePair2<'Key, 'T>), _output: KeyValuePair2<'Key,'U>, []_mthd: Default3) : KeyValuePair2<'Key,'U> = - let a = f.Key - let b = x.Key - let f = f.Value - let x = x.Value + static member inline ``<*>`` (struct (f: KeyValuePair2<_,_>, x: KeyValuePair2<_,'T> ), _output: KeyValuePair2<_,'U> , []_mthd: Default3) : KeyValuePair2<'Key,'U> = + let a, b = f.Key, x.Key + let f, x = f.Value, x.Value KeyValuePair2 (Plus.Invoke a b, f x) static member ``<*>`` (struct (f: Map<'Key,_> , x: Map<'Key,'T> ) , _output: Map<'Key,'U> , []_mthd: Apply) : Map<'Key,'U> = Map (seq { @@ -65,7 +63,7 @@ type Apply = | true, vx -> dct.Add (k, vf vx) | _ -> () dct :> IDictionary<'Key,'U> - + static member ``<*>`` (struct (f: IReadOnlyDictionary<'Key,_>, x: IReadOnlyDictionary<'Key,'T>) , _output: IReadOnlyDictionary<'Key,'U> , []_mthd: Apply) : IReadOnlyDictionary<'Key,'U> = let dct = Dictionary () for KeyValue(k, vf) in f do @@ -78,7 +76,7 @@ type Apply = static member ``<*>`` (struct (f: Expr<'T->'U>, x: Expr<'T>), _output: Expr<'U>, []_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x)) #endif static member ``<*>`` (struct (f: ('T->'U) ResizeArray, x: 'T ResizeArray), _output: 'U ResizeArray, []_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray - + static member inline Invoke (f: '``Applicative<'T -> 'U>``) (x: '``Applicative<'T>``) : '``Applicative<'U>`` = let inline call (mthd : ^M, input1: ^I1, input2: ^I2, output: ^R) = ((^M or ^I1 or ^I2 or ^R) : (static member ``<*>`` : struct (_*_) * _ * _ -> _) (struct (input1, input2)), output, mthd) From c9944b060b49bd0dea74dd6b5937c97d72d5545a Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:45:12 +0100 Subject: [PATCH 12/12] Use Default2 --- src/FSharpPlus/Control/Applicative.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index 384b0f827..880b7c470 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -29,15 +29,15 @@ type Apply = static member ``<*>`` (struct (f: Task<_> , x: Task<'T> ), _output: Task<'U> , []_mthd: Apply) = Task.apply f x : Task<'U> #endif #if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER - static member ``<*>`` (struct (f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Default3) = ValueTask.apply f x : ValueTask<'U> + static member ``<*>`` (struct (f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , []_mthd: Default2) = ValueTask.apply f x : ValueTask<'U> #endif static member ``<*>`` (struct (f: Async<_> , x: Async<'T> ), _output: Async<'U> , []_mthd: Apply) = Async.apply f x : Async<'U> static member ``<*>`` (struct (f: option<_> , x: option<'T> ), _output: option<'U> , []_mthd: Apply) = Option.apply f x : option<'U> static member ``<*>`` (struct (f: voption<_> , x: voption<'T> ), _output: voption<'U> , []_mthd: Apply) = ValueOption.apply f x : voption<'U> static member ``<*>`` (struct (f: Result<_,'E> , x: Result<'T,'E> ), _output: Result<'b,'E> , []_mthd: Apply) = Result.apply f x : Result<'U,'E> static member ``<*>`` (struct (f: Choice<_,'E> , x: Choice<'T,'E> ), _output: Choice<'b,'E> , []_mthd: Apply) = Choice.apply f x : Choice<'U,'E> - static member inline ``<*>`` (struct (KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default3) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) - static member inline ``<*>`` (struct (f: KeyValuePair2<_,_>, x: KeyValuePair2<_,'T> ), _output: KeyValuePair2<_,'U> , []_mthd: Default3) : KeyValuePair2<'Key,'U> = + static member inline ``<*>`` (struct (KeyValue(a: 'Key, f), KeyValue(b: 'Key, x: 'T)), _output: KeyValuePair<'Key,'U>, []_mthd: Default2) : KeyValuePair<'Key,'U> = KeyValuePair (Plus.Invoke a b, f x) + static member inline ``<*>`` (struct (f: KeyValuePair2<_,_>, x: KeyValuePair2<_,'T> ), _output: KeyValuePair2<_,'U> , []_mthd: Default2) : KeyValuePair2<'Key,'U> = let a, b = f.Key, x.Key let f, x = f.Value, x.Value KeyValuePair2 (Plus.Invoke a b, f x) @@ -90,7 +90,7 @@ type Apply = #if (!FABLE_COMPILER || FABLE_COMPILER_3) && !FABLE_COMPILER_4 type Apply with - static member inline ``<*>`` (struct (f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` ) , _output: '``Monad<'U>`` , []_mthd:Default3) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) + static member inline ``<*>`` (struct (f: '``Monad<'T->'U>`` , x: '``Monad<'T>`` ) , _output: '``Monad<'U>`` , []_mthd:Default2) : '``Monad<'U>`` = Bind.InvokeOnInstance f (fun (x1: 'T->'U) -> Bind.InvokeOnInstance x (fun x2 -> Return.InvokeOnInstance (x1 x2))) static member inline ``<*>`` (struct (_: ^t when ^t : null and ^t: struct, _: ^u when ^u : null and ^u: struct), _output: ^r when ^r : null and ^r: struct, _mthd: Default1) = id static member inline ``<*>`` (struct (f: '``Applicative<'T->'U>``, x: '``Applicative<'T>``), _output: '``Applicative<'U>``, []_mthd: Default1) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) f, x)