diff --git a/src/FSharpPlus/Functor.fs b/src/FSharpPlus/Functor.fs index 534508cd3..4e582ea33 100644 --- a/src/FSharpPlus/Functor.fs +++ b/src/FSharpPlus/Functor.fs @@ -139,35 +139,32 @@ type Return = type Apply = inherit Default1 - - 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<_>.Create (fun () -> f.Value x.Value) : Lazy<'U> - static member ``<*>`` (f: seq<_> , x: seq<'T> , []_output: seq<'U> , []_mthd: Apply) = Seq.apply f x : seq<'U> + static member ``<*>`` ((f: Lazy<'T->'U> , x: Lazy<'T> , _output: Lazy<'U>) , []_mthd: Apply) = Lazy<_>.Create (fun () -> f.Value x.Value) : Lazy<'U> + static member ``<*>`` ((f: seq<_> , x: seq<'T> , _output: seq<'U>) , []_mthd: Apply) = Seq.apply f x : seq<'U> #if !FABLE_COMPILER - static member ``<*>`` (f: IEnumerator<_> , x: IEnumerator<'T> , []_output: IEnumerator<'U> , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> + static member ``<*>`` ((f: IEnumerator<_> , x: IEnumerator<'T> , _output: IEnumerator<'U>) , []_mthd: Apply) = Enumerator.map2 id f x : IEnumerator<'U> #endif - 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.collect (fun x1 -> Array.collect (fun x2 -> [|x1 x2|]) x) f : 'U [] - static member ``<*>`` (f: 'r -> _ , g: _ -> 'T , []_output: 'r -> 'U , []_mthd: Apply) = fun x -> f x (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 ``<*>`` ((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.collect (fun x1 -> Array.collect (fun x2 -> [|x1 x2|]) x) f : 'U [] + static member ``<*>`` ((f: 'r -> _ , g: _ -> 'T , _output: 'r -> 'U) , []_mthd: Apply) = fun x -> f x (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 #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 - 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: 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: 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: 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: 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 @@ -176,19 +173,24 @@ type Apply = dct #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) = + static member ``<*>`` ((f: ('T->'U) ResizeArray, x: 'T ResizeArray, _output: 'U ResizeArray), []_mthd: Apply) = ResizeArray (Seq.collect (fun x1 -> Seq.collect (fun x2 -> Seq.singleton (x1 x2)) x) f) : '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>``>) static member inline InvokeOnInstance (f: '``Applicative<'T->'U>``) (x: '``Applicative<'T>``) : '``Applicative<'U>`` = ((^``Applicative<'T->'U>`` or ^``Applicative<'T>`` or ^``Applicative<'U>``) : (static member (<*>) : _*_ -> _) (f, x)) +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) + // Functor class ---------------------------------------------------------- type Iterate = @@ -900,4 +902,4 @@ module internal MonadOps = #endif let inline (<*>) f x = Apply.Invoke f x let inline (<|>) x y = Append.Invoke x y - let inline (>=>) (f: 'a->'``Monad<'b>``) (g: 'b->'``Monad<'c>``) (x: 'a) : '``Monad<'c>`` = f x >>= g \ No newline at end of file + let inline (>=>) (f: 'a->'``Monad<'b>``) (g: 'b->'``Monad<'c>``) (x: 'a) : '``Monad<'c>`` = f x >>= g