diff --git a/docsrc/content/abstraction-applicative.fsx b/docsrc/content/abstraction-applicative.fsx index f88534077..3d6a5b4fb 100644 --- a/docsrc/content/abstraction-applicative.fsx +++ b/docsrc/content/abstraction-applicative.fsx @@ -199,7 +199,7 @@ let opt122 = iI tryDiv (tryParse "488") (trySqrt 16) Ji open FSharpPlus.Math.Applicative -let opt121' = Some 21 .+. tryParse "100" +// let opt121' = Some 21 .+. tryParse "100" let optTrue = 30 >. tryParse "29" let optFalse = tryParse "30" .< 29 let m1m2m3 = -.[1; 2; 3] diff --git a/src/FSharpPlus/Builders.fs b/src/FSharpPlus/Builders.fs index cfaf86ca4..8328ffd85 100644 --- a/src/FSharpPlus/Builders.fs +++ b/src/FSharpPlus/Builders.fs @@ -18,7 +18,6 @@ namespace FSharpPlus module GenericBuilders = open FSharpPlus.Operators - open FSharpPlus.Data // Idiom brackets type Ii = Ii diff --git a/src/FSharpPlus/Control/Alternative.fs b/src/FSharpPlus/Control/Alternative.fs index fac6b2d4f..99409c321 100644 --- a/src/FSharpPlus/Control/Alternative.fs +++ b/src/FSharpPlus/Control/Alternative.fs @@ -10,7 +10,6 @@ namespace FSharpPlus.Control open System.Runtime.InteropServices open FSharpPlus -open FSharpPlus.Data open FSharpPlus.Internals @@ -38,8 +37,6 @@ type Empty with type Append = inherit Default1 static member ``<|>`` (x: 'T seq , y , []_mthd: Default2) = Seq.append x y - static member ``<|>`` (x: 'T NonEmptySeq , y , []_mthd: Default2) = NonEmptySeq.append x y - static member inline ``<|>`` (x: '``Alt<'T>`` , y: '``Alt<'T>``, []_mthd: Default1) = (^``Alt<'T>`` : (static member (<|>) : _*_ -> _) x, y) : '``Alt<'T>`` static member inline ``<|>`` (_: ^t when ^t: null and ^t: struct , _, _mthd: Default1) = () @@ -114,14 +111,6 @@ type Choice = res <- Append.Invoke res e.Current res - static member inline Choice (x: ref``>>, _mthd: Choice) = - use e = x.Value.GetEnumerator () - e.MoveNext() |> ignore - let mutable res = e.Current - while e.MoveNext() && not (IsAltLeftZero.Invoke res) do - res <- Append.Invoke res e.Current - res - static member inline Choice (x: ref``>>, _mthd: Choice) = use e = (List.toSeq x.Value ).GetEnumerator () let mutable res = Empty.Invoke () diff --git a/src/FSharpPlus/Control/Applicative.fs b/src/FSharpPlus/Control/Applicative.fs index 5124498b6..728b4ad41 100644 --- a/src/FSharpPlus/Control/Applicative.fs +++ b/src/FSharpPlus/Control/Applicative.fs @@ -8,7 +8,6 @@ open Microsoft.FSharp.Quotations open FSharpPlus.Internals open FSharpPlus -open FSharpPlus.Data type Apply = @@ -18,7 +17,6 @@ type Apply = 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 [] @@ -101,8 +99,7 @@ type Lift2 = inherit Default1 static member Lift2 (f, (x: Lazy<_> , y: Lazy<_> ), _mthd: Lift2) = Lazy.map2 f x y - static member Lift2 (f, (x: seq<_> , y: seq<_> ), _mthd: Lift2) = Seq.lift2 f x y - static member Lift2 (f, (x: NonEmptySeq<_> , y: NonEmptySeq<_> ), _mthd: Lift2) = NonEmptySeq.lift2 f x y + static member Lift2 (f, (x: seq<_> , y: seq<_> ), _mthd: Lift2) = Seq.lift2 f x y static member Lift2 (f, (x: IEnumerator<_> , y: IEnumerator<_> ), _mthd: Lift2) = Enumerator.map2 f x y static member Lift2 (f, (x , y ), _mthd: Lift2) = List.lift2 f x y static member Lift2 (f, (x , y ), _mthd: Lift2) = Array.lift2 f x y @@ -150,8 +147,7 @@ type Lift3 = inherit Default1 static member Lift3 (f, (x: Lazy<_> , y: Lazy<_> , z: Lazy<_> ), _mthd: Lift3) = Lazy.map3 f x y z - static member Lift3 (f, (x: seq<_> , y: seq<_> , z: seq<_> ), _mthd: Lift3) = Seq.lift3 f x y z - static member Lift3 (f, (x: NonEmptySeq<_> , y: NonEmptySeq<_> , z: NonEmptySeq<_> ), _mthd: Lift3) = NonEmptySeq.lift3 f x y z + static member Lift3 (f, (x: seq<_> , y: seq<_> , z: seq<_> ), _mthd: Lift3) = Seq.lift3 f x y z static member Lift3 (f, (x: IEnumerator<_> , y: IEnumerator<_> , z: IEnumerator<_> ), _mthd: Lift3) = Enumerator.map3 f x y z static member Lift3 (f, (x , y , z ), _mthd: Lift3) = List.lift3 f x y z static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Array.lift3 f x y z @@ -197,8 +193,7 @@ type Lift3 with type IsLeftZero = inherit Default1 - static member IsLeftZero (t: ref> , _mthd: IsLeftZero) = Seq.isEmpty t.Value - static member IsLeftZero (_: ref>, _mthd: IsLeftZero) = false + static member IsLeftZero (t: ref> , _mthd: IsLeftZero) = Seq.isEmpty t.Value static member IsLeftZero (t: ref> , _mthd: IsLeftZero) = List.isEmpty t.Value static member IsLeftZero (t: ref> , _mthd: IsLeftZero) = Array.isEmpty t.Value static member IsLeftZero (t: ref> , _mthd: IsLeftZero) = Option.isNone t.Value diff --git a/src/FSharpPlus/Control/Foldable.fs b/src/FSharpPlus/Control/Foldable.fs index 9287d375c..0691a4ec4 100644 --- a/src/FSharpPlus/Control/Foldable.fs +++ b/src/FSharpPlus/Control/Foldable.fs @@ -34,7 +34,6 @@ open System.Runtime.InteropServices open System.Text open System.Collections.Generic open FSharpPlus -open FSharpPlus.Data open FSharpPlus.Internals open FSharpPlus.Internals.Prelude @@ -266,7 +265,6 @@ type Head = static member Head (x: 'T voption , []_impl: Head ) = x.Value static member Head (x: Result<_, _> , []_impl: Head ) = Result.get x static member Head (x: 'T [] , []_impl: Head ) = x.[0] - static member Head (x: NonEmptySeq<'T> , []_impl: Head ) = x.First static member Head (x: Id<'T> , []_impl: Head ) = x.getValue static member Head (x: ResizeArray<'T> , []_impl: Head ) = x.[0] static member Head (x: string , []_impl: Head ) = x.[0] @@ -281,8 +279,7 @@ type TryHead = inherit Default1 static member inline TryHead (x , []_impl: Default1) = Seq.tryHead <| ToSeq.Invoke x static member TryHead (x: 't list , []_impl: TryHead ) = List.tryHead x - static member TryHead (x: 't [] , []_impl: TryHead ) = Array.tryHead x - static member TryHead (x: NonEmptySeq<'T>,[]_impl: TryHead) = Some x.First + static member TryHead (x: 't [] , []_impl: TryHead ) = Array.tryHead x static member TryHead (x: Id<'T> , []_impl: TryHead ) = Some x.getValue static member TryHead (x: string , []_impl: TryHead ) = String.tryHead x static member TryHead (x: StringBuilder, []_impl: TryHead ) = if x.Length = 0 then None else Some (x.ToString().[0]) @@ -297,8 +294,7 @@ type TryLast = inherit Default1 static member inline TryLast (x , []_impl: Default1) = Seq.tryLast <| ToSeq.Invoke x static member TryLast (x: 't list , []_impl: TryLast) = List.tryLast x - static member TryLast (x: 't [] , []_impl: TryLast) = Array.tryLast x - static member TryLast (x: NonEmptySeq<'T>, []_impl: TryLast) = Some <| Seq.last x + static member TryLast (x: 't [] , []_impl: TryLast) = Array.tryLast x static member TryLast (x: Id<'T> , []_impl: TryLast ) = Some x.getValue static member TryLast (x: string , []_impl: TryLast ) = String.tryLast x static member TryLast (x: StringBuilder , []_impl: TryLast ) = if x.Length = 0 then None else Some (x.ToString().[x.Length - 1]) diff --git a/src/FSharpPlus/Control/Functor.fs b/src/FSharpPlus/Control/Functor.fs index 33857b3e5..d8179b881 100644 --- a/src/FSharpPlus/Control/Functor.fs +++ b/src/FSharpPlus/Control/Functor.fs @@ -12,7 +12,6 @@ open FSharpPlus.Internals open FSharpPlus.Internals.Prelude open FSharpPlus open FSharpPlus.Extensions -open FSharpPlus.Data #if !FABLE_COMPILER @@ -130,7 +129,7 @@ type Map with , f: 'T->'U), []_mthd: Default3) = Apply.InvokeOnInstance (Return.InvokeOnInstance f: '``Applicative<'T->'U>``) x : '``Applicative<'U>`` static member Map ((x: seq<_> , f: 'T->'U), _mthd: Default2) = Seq.map f x : seq<'U> - static member Map ((x: NonEmptySeq<_> , f: 'T->'U), _mthd: Default2) = NonEmptySeq.map f x : NonEmptySeq<'U> + static member Map ((x: NonEmptySeq2<'T> , f: 'T->'U), _mthd: Default2) = failwith "no Map implementation for NonEmptySeq2<'U>" : NonEmptySeq2<'U> static member Map ((x: IEnumerator<_> , f: 'T->'U), _mthd: Default2) = Enumerator.map f x : IEnumerator<'U> static member Map ((x: IDictionary<_,_> , f: 'T->'U), _mthd: Default2) = Dict.map f x : IDictionary<'Key,'U> static member Map ((x: IReadOnlyDictionary<_,_>, f: 'T->'U), _mthd: Default2) = IReadOnlyDictionary.mapValues f x : IReadOnlyDictionary<'Key,_> @@ -187,8 +186,7 @@ type Unzip = static member Unzip ((source: ResizeArray<'T * 'U> , _output: ResizeArray<'T> * ResizeArray<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source - static member Unzip ((source: seq<'T * 'U> , _output: seq<'T> * seq<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source - static member Unzip ((source: NonEmptySeq<'T * 'U> , _output: NonEmptySeq<'T> * NonEmptySeq<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source + static member Unzip ((source: seq<'T * 'U> , _output: seq<'T> * seq<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source static member Unzip ((source: IEnumerator<'T * 'U> , _output: IEnumerator<'T> * ResizeArray<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source static member Unzip ((source: IDictionary<'Key, 'T * 'U> , _output: IDictionary<_,'T> * IDictionary<_,'U> ) , _mthd: Unzip ) = Dict.unzip source @@ -208,8 +206,7 @@ type Unzip = type Zip = inherit Default1 static member Zip ((x: IEnumerator<'T> , y: IEnumerator<'U> , _output: IEnumerator<'T*'U> ), _mthd: Zip) = Enumerator.zip x y - static member Zip ((x: seq<'T> , y: seq<'U> , _output: seq<'T*'U> ), _mthd: Zip) = Seq.zip x y - static member Zip ((x: NonEmptySeq<'T> , y: NonEmptySeq<'U> , _output: NonEmptySeq<'T*'U> ), _mthd: Zip) = NonEmptySeq.zip x y + static member Zip ((x: seq<'T> , y: seq<'U> , _output: seq<'T*'U> ), _mthd: Zip) = Seq.zip x y static member Zip ((x: IDictionary<'K, 'T> , y: IDictionary<'K,'U> , _output: IDictionary<'K,'T*'U> ), _mthd: Zip) = Dict.zip x y static member Zip ((x: IReadOnlyDictionary<'K, 'T>, y: IReadOnlyDictionary<'K,'U>, _output: IReadOnlyDictionary<'K,'T*'U>), _mthd: Zip) = IReadOnlyDictionary.zip x y static member Zip ((x: Dictionary<'K, 'T> , y: Dictionary<'K,'U> , _output: Dictionary<'K,'T*'U> ), _mthd: Zip) = Dict.zip x y :?> Dictionary<'K,'T*'U> diff --git a/src/FSharpPlus/Control/Monad.fs b/src/FSharpPlus/Control/Monad.fs index 2260364ec..8503a4c45 100644 --- a/src/FSharpPlus/Control/Monad.fs +++ b/src/FSharpPlus/Control/Monad.fs @@ -8,7 +8,6 @@ open System.Threading.Tasks open Microsoft.FSharp.Quotations open FSharpPlus -open FSharpPlus.Data open FSharpPlus.Internals open FSharpPlus.Internals.Prelude @@ -60,8 +59,6 @@ type Bind = static member (>>=) (source: ResizeArray<'T>, f: 'T -> ResizeArray<'U>) = ResizeArray (Seq.bind (f >> seq<_>) source) : ResizeArray<'U> - static member (>>=) (source: NonEmptySeq<'T>, f: 'T -> NonEmptySeq<'U>) = NonEmptySeq.collect f source : NonEmptySeq<'U> - #if !FABLE_COMPILER static member inline Invoke (source: '``Monad<'T>``) (binder: 'T -> '``Monad<'U>``) : '``Monad<'U>`` = let inline call (_mthd: 'M, input: 'I, _output: 'R, f) = ((^M or ^I or ^R) : (static member (>>=) : _*_ -> _) input, f) @@ -115,8 +112,6 @@ type Join = dct static member Join (x: ResizeArray> , []_output: ResizeArray<'T> , []_mthd: Join) = ResizeArray (Seq.bind seq<_> x) : ResizeArray<'T> - - static member Join (x: NonEmptySeq> , []_output: NonEmptySeq<'T> , []_mthd: Join) = NonEmptySeq.concat x : NonEmptySeq<'T> static member inline Invoke (source: '``Monad>``) : '``Monad<'T>`` = let inline call (mthd: 'M, input: 'I, output: 'R) = ((^M or ^I or ^R) : (static member Join : _*_*_ -> _) input, output, mthd) @@ -137,7 +132,6 @@ type Return = static member Return (_: seq<'a> , _: Default2) = fun x -> Seq.singleton x : seq<'a> - static member Return (_: NonEmptySeq<'a>, _: Default2) = fun x -> NonEmptySeq.singleton x : NonEmptySeq<'a> static member Return (_: IEnumerator<'a>, _: Default2) = fun x -> Enumerator.upto None (fun _ -> x) : IEnumerator<'a> static member inline Return (_: 'R , _: Default1) = fun (x: 'T) -> Return.InvokeOnInstance x : 'R static member Return (_: Lazy<'a> , _: Return ) = fun x -> Lazy<_>.CreateFromValue x : Lazy<'a> @@ -180,7 +174,6 @@ type Delay = static member inline Delay (_mthd: Default1, _: unit-> ^t when ^t : null and ^t : struct , _ ) = () static member Delay (_mthd: Default2, x: unit-> _ , _ ) = Seq.delay x : seq<'T> - static member Delay (_mthd: Default2, x: unit-> _ , _ ) = NonEmptySeq.delay x : NonEmptySeq<'T> static member Delay (_mthd: Default2, x: unit-> 'R -> _ , _ ) = (fun s -> x () s): 'R -> _ static member Delay (_mthd: Delay , x: unit-> _ , _ ) = async.Delay x : Async<'T> static member Delay (_mthd: Delay , x: unit-> Task<_> , _ ) = x () : Task<'T> @@ -240,7 +233,6 @@ type TryWith = static member inline TryWith (_: unit -> ^t when ^t: null and ^t: struct, _ : exn -> 't , _: Default1, _) = () static member TryWith (computation: unit -> seq<_> , catchHandler: exn -> seq<_> , _: Default2, _) = seq (try (Seq.toArray (computation ())) with e -> Seq.toArray (catchHandler e)) - static member TryWith (computation: unit -> NonEmptySeq<_>, catchHandler: exn -> NonEmptySeq<_>, _: Default2, _) = seq (try (Seq.toArray (computation ())) with e -> Seq.toArray (catchHandler e)) |> NonEmptySeq.unsafeOfSeq static member TryWith (computation: unit -> 'R -> _ , catchHandler: exn -> 'R -> _ , _: Default2, _) = (fun s -> try (computation ()) s with e -> catchHandler e s) : 'R ->_ static member TryWith (computation: unit -> Async<_> , catchHandler: exn -> Async<_> , _: TryWith , _) = async.TryWith ((computation ()), catchHandler) #if !FABLE_COMPILER @@ -265,7 +257,6 @@ type TryFinally = inherit Default1 static member TryFinally ((computation: unit -> seq<_> , compensation: unit -> unit), _: Default2, _, _) = seq { try for e in computation () do yield e finally compensation () } - static member TryFinally ((computation: unit -> NonEmptySeq<_>, compensation: unit -> unit), _: Default2, _, _) = seq { try for e in computation () do yield e finally compensation () } |> NonEmptySeq.unsafeOfSeq [] static member TryFinally ((_: unit -> 'R -> _ , _: unit -> unit), _: Default2 , _, _defaults: False) = raise Internals.Errors.exnUnreachable @@ -307,7 +298,6 @@ type Using = inherit Default1 static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> seq<'U> , _: Using) = seq { try for e in body resource do yield e finally if not (isNull (box resource)) then resource.Dispose () } : seq<'U> - static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> NonEmptySeq<'U>, _: Using) = seq { try for e in body resource do yield e finally if not (isNull (box resource)) then resource.Dispose () } |> NonEmptySeq.unsafeOfSeq : NonEmptySeq<'U> static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> 'R -> 'U , _: Using ) = (fun s -> try body resource s finally if not (isNull (box resource)) then resource.Dispose ()) : 'R->'U static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> Async<'U>, _: Using ) = async.Using (resource, body) #if !FABLE_COMPILER diff --git a/src/FSharpPlus/Control/Monoid.fs b/src/FSharpPlus/Control/Monoid.fs index 69c0d4ec2..a67dd58aa 100644 --- a/src/FSharpPlus/Control/Monoid.fs +++ b/src/FSharpPlus/Control/Monoid.fs @@ -8,7 +8,6 @@ open System.Runtime.InteropServices open Microsoft.FSharp.Quotations open System.Threading.Tasks open FSharpPlus -open FSharpPlus.Data open FSharpPlus.Internals open FSharpPlus.Internals.Prelude @@ -155,7 +154,6 @@ type Plus with #if !FABLE_COMPILER static member inline ``+`` (x: IReadOnlyDictionary<'K,'V>, y: IReadOnlyDictionary<'K,'V>, []_mthd: Default3) = IReadOnlyDictionary.unionWith Plus.Invoke x y #endif - static member inline ``+`` (x: _ NonEmptySeq , y: _ NonEmptySeq , []_mthd: Default3) = NonEmptySeq.append x y diff --git a/src/FSharpPlus/Control/Traversable.fs b/src/FSharpPlus/Control/Traversable.fs index 570ebd082..e8a5bc186 100644 --- a/src/FSharpPlus/Control/Traversable.fs +++ b/src/FSharpPlus/Control/Traversable.fs @@ -5,7 +5,6 @@ open System.Runtime.InteropServices open System.ComponentModel open FSharpPlus -open FSharpPlus.Data open FSharpPlus.Internals open FSharpPlus.Internals.MonadOps open FSharpPlus.Extensions @@ -53,13 +52,6 @@ type Traverse = let cons_f x ys = Map.Invoke (Seq.cons: 'a -> seq<_> -> seq<_>) (f x) <*> ys Seq.foldBack cons_f t (result Seq.empty) - static member inline Traverse (t: _ NonEmptySeq, f, []_output: 'R, []_impl: Default3) = - #if TEST_TRACE - Traces.add "Traverse NonEmptySeq" - #endif - let cons_f x ys = Map.Invoke (Seq.cons: 'a -> seq<_> -> seq<_>) (f x) <*> ys - Map.Invoke NonEmptySeq.ofSeq (Seq.foldBack cons_f t (result Seq.empty)) - static member inline Traverse (t: seq<'T>, f: 'T -> '``Functor<'U>``, []_output: '``Functor>``, []_impl: Default2) = #if TEST_TRACE Traces.add "Traverse seq, 'T -> Functor<'U>" @@ -67,13 +59,6 @@ type Traverse = let mapped = Seq.map f t Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, List.toSeq, Return.Invoke) : '``Functor>`` - static member inline Traverse (t: NonEmptySeq<'T>, f: 'T -> '``Functor<'U>``, []_output: '``Functor>``, []_impl: Default2) = - #if TEST_TRACE - Traces.add "Traverse NonEmptySeq, 'T -> Functor<'U>" - #endif - let mapped = NonEmptySeq.map f t - Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq.ofList, Return.Invoke) : '``Functor>`` - static member inline Traverse (t: ^a, f, []_output: 'R, []_impl: Default1) : 'R = #if TEST_TRACE Traces.add "Traverse ^a" @@ -93,19 +78,6 @@ type Traverse = while enum.MoveNext() do yield Async.AsTask(f enum.Current, cancellationToken = ct).Result }} #endif - - #if !FABLE_COMPILER - static member Traverse (t: 't NonEmptySeq, f: 't -> Async<'u>, []_output: Async>, []_impl: Traverse) : Async> = async { - #if TEST_TRACE - Traces.add "Traverse 't NonEmptySeq, 't -> Async<'u>" - #endif - - let! ct = Async.CancellationToken - return seq { - use enum = t.GetEnumerator () - while enum.MoveNext() do - yield Async.AsTask(f enum.Current, cancellationToken = ct).Result } |> NonEmptySeq.unsafeOfSeq } - #endif static member Traverse (t: Id<'t>, f: 't -> option<'u>, []_output: option>, []_impl: Traverse) = #if TEST_TRACE @@ -200,15 +172,6 @@ type Sequence with #if !FABLE_COMPILER static member Sequence (t: seq> , []_output: Async> , []_impl: Default3) : Async> = Async.SequentialLazy t #endif - static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>, []_output: '``Applicative>``, []_impl: Default4) : '``Applicative>`` = Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>) - static member Sequence (t: NonEmptySeq> , []_output: option> , []_impl: Default3) : option> = Option.Sequential t |> Option.map NonEmptySeq.unsafeOfSeq - static member Sequence (t: NonEmptySeq>, []_output: Result, 'e>, []_impl: Default3) : Result, 'e> = Result.Sequential t |> Result.map NonEmptySeq.unsafeOfSeq - static member Sequence (t: NonEmptySeq>, []_output: Choice, 'e>, []_impl: Default3) : Choice, 'e> = Choice.Sequential t |> Choice.map NonEmptySeq.unsafeOfSeq - static member Sequence (t: NonEmptySeq> , []_output: list> , []_impl: Default3) : list> = Sequence.ForInfiniteSequences(t, List.isEmpty , NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>) - static member Sequence (t: NonEmptySeq<'t []> , []_output: NonEmptySeq<'t> [] , []_impl: Default3) : NonEmptySeq<'t> [] = Sequence.ForInfiniteSequences(t, Array.isEmpty, NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>) - #if !FABLE_COMPILER - static member Sequence (t: NonEmptySeq> , []_output: Async> , []_impl: Default3) = Async.SequentialLazy t |> Async.map NonEmptySeq.unsafeOfSeq : Async> - #endif static member inline Sequence (t: ^a , []_output: 'R, []_impl: Default2) : 'R = Traverse.InvokeOnInstance id t static member inline Sequence (t: ^a , []_output: 'R, []_impl: Default1) : 'R = Sequence.InvokeOnInstance t @@ -293,27 +256,7 @@ type Gather = let cons_f x ys = Map.Invoke (cons: 'a -> seq<_> -> seq<_>) (f x) <.> ys Seq.foldBack cons_f t (Pure.Invoke Seq.empty) - static member inline Gather (t: _ NonEmptySeq, f, []_output: 'R, []_impl: Default3) = - #if TEST_TRACE - Traces.add "Gather NonEmptySeq" - #endif - let cons x y = seq {yield x; yield! y} - let cons_f x ys = Map.Invoke (cons: 'a -> seq<_> -> seq<_>) (f x) <.> ys - Map.Invoke NonEmptySeq.ofSeq (Seq.foldBack cons_f t (Pure.Invoke Seq.empty)) - - static member inline Gather (t: seq<'T>, f: 'T -> '``Functor<'U>``, []_output: '``Functor>``, []_impl: Default2) = - #if TEST_TRACE - Traces.add "Gather seq, 'T -> Functor<'U>" - #endif - let mapped = Seq.map f t - Transpose.ForInfiniteSequences (mapped, IsZipLeftZero.Invoke, List.toSeq, Pure.Invoke) : '``Functor>`` - - static member inline Gather (t: NonEmptySeq<'T>, f: 'T -> '``Functor<'U>``, []_output: '``Functor>``, []_impl: Default2) = - #if TEST_TRACE - Traces.add "Gather NonEmptySeq, 'T -> Functor<'U>" - #endif - let mapped = NonEmptySeq.map f t - Transpose.ForInfiniteSequences (mapped, IsZipLeftZero.Invoke, NonEmptySeq.ofList, Pure.Invoke) : '``Functor>`` + static member inline Gather (t: ^a, f, []_output: 'R, []_impl: Default1) : 'R = #if TEST_TRACE @@ -335,18 +278,6 @@ type Gather = yield Async.AsTask(f enum.Current, cancellationToken = ct).Result }} #endif - #if !FABLE_COMPILER - static member Gather (t: 't NonEmptySeq, f: 't -> Async<'u>, []_output: Async>, []_impl: Gather) : Async> = async { - #if TEST_TRACE - Traces.add "Gather 't NonEmptySeq, 't -> Async<'u>" - #endif - - let! ct = Async.CancellationToken - return seq { - use enum = t.GetEnumerator () - while enum.MoveNext() do - yield Async.AsTask(f enum.Current, cancellationToken = ct).Result } |> NonEmptySeq.unsafeOfSeq } - #endif static member Gather (t: Id<'t>, f: 't -> option<'u>, []_output: option>, []_impl: Gather) = #if TEST_TRACE @@ -440,15 +371,6 @@ type Transpose with #if !FABLE_COMPILER static member Transpose (t: seq> , []_output: Async> , []_impl: Default3) : Async> = Async.Parallel t |> Async.map Array.toSeq #endif - static member inline Transpose (t: NonEmptySeq<'``Applicative<'T>``>, []_output: '``Applicative>``, []_impl: Default4) : '``Applicative>`` = Transpose.ForInfiniteSequences (t, IsZipLeftZero.Invoke, NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>) - static member Transpose (t: NonEmptySeq> , []_output: option> , []_impl: Default3) : option> = Option.Sequential t |> Option.map NonEmptySeq.unsafeOfSeq - static member inline Transpose (t: NonEmptySeq>, []_output: Result, 'e>, []_impl: Default3) : Result, 'e> = Result.Parallel ((++), t) |> Result.map NonEmptySeq.unsafeOfSeq - static member inline Transpose (t: NonEmptySeq>, []_output: Choice, 'e>, []_impl: Default3) : Choice, 'e> = Choice.Parallel ((++), t) |> Choice.map NonEmptySeq.unsafeOfSeq - static member Transpose (t: NonEmptySeq> , []_output: list> , []_impl: Default3) : list> = Transpose.ForInfiniteSequences (t, List.isEmpty , NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>) - static member Transpose (t: NonEmptySeq<'t []> , []_output: NonEmptySeq<'t> [] , []_impl: Default3) : NonEmptySeq<'t> [] = Transpose.ForInfiniteSequences (t, Array.isEmpty, NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>) - #if !FABLE_COMPILER - static member Transpose (t: NonEmptySeq> , []_output: Async> , []_impl: Default3) = Async.Parallel t |> Async.map NonEmptySeq.unsafeOfSeq : Async> - #endif static member inline Transpose (t: ^a , []_output: 'R, []_impl: Default2) : 'R = Gather.InvokeOnInstance id t static member inline Transpose (t: ^a , []_output: 'R, []_impl: Default1) : 'R = Transpose.InvokeOnInstance t diff --git a/src/FSharpPlus/Control/ZipApplicative.fs b/src/FSharpPlus/Control/ZipApplicative.fs index 760b68151..993bd6e22 100644 --- a/src/FSharpPlus/Control/ZipApplicative.fs +++ b/src/FSharpPlus/Control/ZipApplicative.fs @@ -10,7 +10,6 @@ open Microsoft.FSharp.Quotations open FSharpPlus.Internals open FSharpPlus.Internals.Prelude open FSharpPlus -open FSharpPlus.Data [] @@ -30,8 +29,7 @@ type Pure = let inline call (mthd: ^M, output: ^R) = ((^M or ^R) : (static member Pure : _*_ -> _) output, mthd) call (Unchecked.defaultof, Unchecked.defaultof<'``ZipApplicative<'T>``>) x - static member Pure (_: seq<'a> , _: Default2 ) = fun x -> Seq.initInfinite (fun _ -> x) : seq<'a> - static member Pure (_: NonEmptySeq<'a> , _: Default2 ) = fun x -> NonEmptySeq.initInfinite (fun _ -> x) : NonEmptySeq<'a> + static member Pure (_: seq<'a> , _: Default2 ) = fun x -> Seq.initInfinite (fun _ -> x) : seq<'a> static member Pure (_: IEnumerator<'a> , _: Default2 ) = fun x -> Enumerator.upto None (fun _ -> x) : IEnumerator<'a> static member inline Pure (_: 'R , _: Default1 ) = fun (x: 'T) -> Pure.InvokeOnInstance x : 'R static member Pure (x: Lazy<'a> , _: Pure) = Return.Return (x, Unchecked.defaultof) : _ -> Lazy<'a> @@ -78,8 +76,7 @@ type ZipApply = #if !FABLE_COMPILER static member ``<.>`` (struct (f: Lazy<'T->'U> , x: Lazy<'T> ), []_output: Lazy<'U> , []_mthd: ZipApply) = Apply.``<*>`` (struct (f, x), _output, Unchecked.defaultof) - static member ``<.>`` (struct (f: seq<_> , x: seq<'T> ), []_output: seq<'U> , []_mthd: ZipApply) = Seq.map2 (<|) f x - static member ``<.>`` (struct (f: NonEmptySeq<_> , x: NonEmptySeq<'T> ), []_output: NonEmptySeq<'U> , []_mthd: ZipApply) = NonEmptySeq.map2 (<|) f x + static member ``<.>`` (struct (f: seq<_> , x: seq<'T> ), []_output: seq<'U> , []_mthd: ZipApply) = Seq.map2 (<|) f x static member ``<.>`` (struct (f: IEnumerator<_> , x: IEnumerator<'T> ), []_output: IEnumerator<'U> , []_mthd: ZipApply) = Apply.``<*>`` (struct (f, x), _output, Unchecked.defaultof) static member ``<.>`` (struct (f: list<_> , x: list<'T> ), []_output: list<'U> , []_mthd: ZipApply) = List.map2Shortest (<|) f x static member ``<.>`` (struct (f: _ [] , x: 'T [] ), []_output: 'U [] , []_mthd: ZipApply) = Array.map2Shortest (<|) f x @@ -136,8 +133,7 @@ type Map2 = inherit Default1 static member Map2 (f, (x: Lazy<_> , y: Lazy<_> ), _mthd: Map2) = Lift2.Lift2 (f, (x, y), Unchecked.defaultof) - static member Map2 (f, (x: seq<_> , y: seq<_> ), _mthd: Map2) = Seq.map2 f x y - static member Map2 (f, (x: NonEmptySeq<_> , y: NonEmptySeq<_> ), _mthd: Map2) = NonEmptySeq.map2 f x y + static member Map2 (f, (x: seq<_> , y: seq<_> ), _mthd: Map2) = Seq.map2 f x y static member Map2 (f, (x: IEnumerator<_> , y: IEnumerator<_> ), _mthd: Map2) = Lift2.Lift2 (f, (x, y), Unchecked.defaultof) static member Map2 (f, (x , y ), _mthd: Map2) = List.map2Shortest f x y static member Map2 (f, (x: _ [] , y: _ [] ), _mthd: Map2) = Array.map2Shortest f x y @@ -183,8 +179,7 @@ type Map3 = inherit Default1 static member Map3 (f, (x: Lazy<_> , y: Lazy<_> , z: Lazy<_> ), _mthd: Map3) = Lift3.Lift3 (f, (x, y, z), Unchecked.defaultof) - static member Map3 (f, (x: seq<_> , y: seq<_> , z: seq<_> ), _mthd: Map3) = Seq.map3 f x y z - static member Map3 (f, (x: NonEmptySeq<_> , y: NonEmptySeq<_> , z: NonEmptySeq<_> ), _mthd: Map3) = NonEmptySeq.map3 f x y z + static member Map3 (f, (x: seq<_> , y: seq<_> , z: seq<_> ), _mthd: Map3) = Seq.map3 f x y z static member Map3 (f, (x: IEnumerator<_> , y: IEnumerator<_> , z: IEnumerator<_> ), _mthd: Map3) = Lift3.Lift3 (f, (x, y, z), Unchecked.defaultof) static member Map3 (f, (x , y , z ), _mthd: Map3) = List.map3Shortest f x y z static member Map3 (f, (x: _ [] , y: _ [] , z: _ [] ), _mthd: Map3) = Array.map3Shortest f x y z @@ -228,8 +223,7 @@ type Map3 with type IsZipLeftZero = inherit Default1 - static member IsZipLeftZero (t: ref> , _mthd: IsZipLeftZero) = Seq.isEmpty t.Value - static member IsZipLeftZero (_: ref>, _mthd: IsZipLeftZero) = false + static member IsZipLeftZero (t: ref> , _mthd: IsZipLeftZero) = Seq.isEmpty t.Value static member IsZipLeftZero (t: ref> , _mthd: IsZipLeftZero) = List.isEmpty t.Value static member IsZipLeftZero (t: ref> , _mthd: IsZipLeftZero) = Array.isEmpty t.Value static member IsZipLeftZero (t: ref> , _mthd: IsZipLeftZero) = IsLeftZero.IsLeftZero (t, Unchecked.defaultof) diff --git a/src/FSharpPlus/Data/NonEmptySeq.fs b/src/FSharpPlus/Data/NonEmptySeq.fs index afea9d162..c3f921c24 100644 --- a/src/FSharpPlus/Data/NonEmptySeq.fs +++ b/src/FSharpPlus/Data/NonEmptySeq.fs @@ -5,11 +5,161 @@ open System.Runtime.InteropServices open System.ComponentModel open System.Collections.Generic open FSharpPlus +open FSharpPlus.Internals +open FSharpPlus.Extensions +open FSharpPlus.Control +open Microsoft.FSharp.Core.CompilerServices /// A type-safe sequence that contains at least one element. -type NonEmptySeq<'T> = - inherit IEnumerable<'T> - abstract member First: 'T +[] +type NonEmptySeq<'t> = + inherit IEnumerable<'t> + abstract member First: 't + + // boilerplate + static member unsafeOfSeq (seq: _ seq) = + { new NonEmptySeq<_> with + member _.First = Seq.head seq + member _.GetEnumerator() = seq.GetEnumerator() + member _.GetEnumerator() = seq.GetEnumerator() :> Collections.IEnumerator } + + static member ofList (list: _ list) = match list with [] -> invalidArg "list" "The input list was empty." | _ -> NonEmptySeq<_>.unsafeOfSeq list + static member collect (mapping: 'a -> '``#NonEmptySeq<'b>``) (source: NonEmptySeq<'a>) : NonEmptySeq<'b> when '``#NonEmptySeq<'b>`` :> NonEmptySeq<'b> = Seq.collect mapping source |> NonEmptySeq<_>.unsafeOfSeq + static member concat (sources: NonEmptySeq<'``#NonEmptySeq<'a>``>) : NonEmptySeq<'a> when '``#NonEmptySeq<'a>`` :> NonEmptySeq<'a> = Seq.concat sources |> NonEmptySeq<'a>.unsafeOfSeq + static member allPairs (source1: _ NonEmptySeq) (source2: _ NonEmptySeq) = Seq.allPairs source1 source2 |> NonEmptySeq<_>.unsafeOfSeq + static member append (source1: 'a NonEmptySeq) (source2: 'a NonEmptySeq) = Seq.append source1 source2 |> NonEmptySeq<'a>.unsafeOfSeq + static member map mapping (source: NonEmptySeq<_>) = source |> Seq.map mapping |> NonEmptySeq<_>.unsafeOfSeq + static member bind (mapping: 'T->NonEmptySeq<'U>) source = NonEmptySeq<'U>.collect mapping source + static member apply f x = NonEmptySeq<_>.bind (fun f -> NonEmptySeq<_>.map ((<|) f) x) f + static member lift2 f x1 x2 = NonEmptySeq<_>.allPairs x1 x2 |> NonEmptySeq<_>.map (fun (x, y) -> f x y) + static member lift3 f x1 x2 x3 = + NonEmptySeq<_>.allPairs x2 x3 + |> NonEmptySeq<_>.allPairs x1 + |> NonEmptySeq<_>.map (fun x -> (fst (snd x), snd (snd x), fst x)) + |> NonEmptySeq<_>.map (fun (x, y, z) -> f x y z) + + static member zip (source1: NonEmptySeq<_>) (source2: NonEmptySeq<_>) = Seq.zip source1 source2 |> NonEmptySeq<_>.unsafeOfSeq + static member singleton value = Seq.singleton value |> NonEmptySeq<_>.unsafeOfSeq + static member delay (generator: unit -> NonEmptySeq<'a>) : NonEmptySeq<'a> = Seq.delay (fun () -> generator () :> _) |> NonEmptySeq<_>.unsafeOfSeq + + // Statics + + static member (<|>) (x: 'T NonEmptySeq , y) = NonEmptySeq<'T>.append x y + + #if !FABLE_COMPILER + static member inline Choice (x: NonEmptySeq<'``Alternative<'T>``>) = + use e = x.GetEnumerator () + e.MoveNext() |> ignore + let mutable res = e.Current + while e.MoveNext() && not (IsAltLeftZero.Invoke res) do + res <- Append.Invoke res e.Current + + static member Head (x: NonEmptySeq<'T>, []_impl: Head) = x.First + static member TryHead (x: NonEmptySeq<'T>,[]_impl: TryHead) = Some x.First + static member TryLast (x: NonEmptySeq<'T>, []_impl: TryLast) = Some <| Seq.last x + #endif + + static member Unzip (source: NonEmptySeq<'T * 'U>) = NonEmptySeq<_>.map fst source, NonEmptySeq<_>.map snd source + + static member (<*>) (f: NonEmptySeq<_> , x: NonEmptySeq<'T>) : NonEmptySeq<'U> = NonEmptySeq<_>.apply f x + static member Lift2 (f, x: NonEmptySeq<_> , y: NonEmptySeq<_>) = NonEmptySeq<_>.lift2 f x y + static member Lift3 (f, x: NonEmptySeq<_> , y: NonEmptySeq<_> , z: NonEmptySeq<_>) = NonEmptySeq<_>.lift3 f x y z + static member IsLeftZero (_: NonEmptySeq<_>) = false + + + + static member Map (x: NonEmptySeq<_>, f: 'T -> 'U) = NonEmptySeq<_>.map f x : NonEmptySeq<'U> + + static member Pure (x: 'T) : NonEmptySeq<'T> = Seq.initInfinite (fun _ -> x) |> NonEmptySeq<_>.unsafeOfSeq + static member (<.>) (f: NonEmptySeq<_>, x: NonEmptySeq<'T>) : NonEmptySeq<'U> = Seq.map2 (<|) f x |> NonEmptySeq<_>.unsafeOfSeq + static member Map2 (f, x: NonEmptySeq<_>, y: NonEmptySeq<_>) = Seq.map2 f x y |> NonEmptySeq<_>.unsafeOfSeq + static member Map3 (f, x: NonEmptySeq<_>, y: NonEmptySeq<_>, z: NonEmptySeq<_>) = Seq.map3 f x y z |> NonEmptySeq<_>.unsafeOfSeq + static member IsZipLeftZero (_: NonEmptySeq<_>) = false + + static member Zip (x: NonEmptySeq<'T>, y: NonEmptySeq<'U>) = NonEmptySeq<_>.zip x y + static member (>>=) (source: NonEmptySeq<'T>, f: 'T -> NonEmptySeq<'U>) = NonEmptySeq<_>.collect f source : NonEmptySeq<'U> + + static member Join (x: NonEmptySeq>) = NonEmptySeq<_>.concat x : NonEmptySeq<'T> + + static member Return (x: 'a) = NonEmptySeq<_>.singleton x : NonEmptySeq<'a> + + static member Delay (x: unit-> _ ) = NonEmptySeq<_>.delay x : NonEmptySeq<'T> + static member TryWith (computation: unit -> NonEmptySeq<_>, catchHandler: exn -> NonEmptySeq<_>) = seq (try (Seq.toArray (computation ())) with e -> Seq.toArray (catchHandler e)) |> NonEmptySeq<_>.unsafeOfSeq + static member TryFinally (computation: unit -> NonEmptySeq<_>, compensation: unit -> unit) = seq { try for e in computation () do yield e finally compensation () } |> NonEmptySeq<_>.unsafeOfSeq + static member Using (resource: 'T when 'T :> IDisposable, body: 'T -> NonEmptySeq<'U>) = seq { try for e in body resource do yield e finally if not (isNull (box resource)) then resource.Dispose () } |> NonEmptySeq<_>.unsafeOfSeq : NonEmptySeq<'U> + static member inline (+) (x: _ NonEmptySeq , y: _ NonEmptySeq) = NonEmptySeq<_>.append x y + + #if !FABLE_COMPILER + + static member inline Traverse (t: _ seq, f) = + let cons_f x ys = Map.Invoke (Seq.cons: 'a -> seq<_> -> seq<_>) (f x) <*> ys + Map.Invoke NonEmptySeq<_>.unsafeOfSeq (Seq.foldBack cons_f t (result Seq.empty)) + + static member inline Traverse (t: NonEmptySeq<'T>, f: 'T -> '``Functor<'U>``) = + let mapped = NonEmptySeq<_>.map f t + Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq<_>.ofList, Return.Invoke) : '``Functor>`` + + static member Traverse (t: 'T NonEmptySeq, f: 'T -> Async<'u>) : Async> = async { + let! ct = Async.CancellationToken + return seq { + use enum = t.GetEnumerator () + while enum.MoveNext() do + yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) } |> NonEmptySeq<_>.unsafeOfSeq } + + static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>) = + Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq<_>.ofList, Return.Invoke) : '``Applicative>`` + + + + + static member inline Gather (t: seq<'T>, f: 'T -> '``Functor<'U>``) = + #if TEST_TRACE + Traces.add "Gather seq, 'T -> Functor<'U>" + #endif + let mapped = Seq.map f t + Transpose.ForInfiniteSequences (mapped, IsZipLeftZero.Invoke, List.toSeq, Pure.Invoke) : '``Functor>`` + + static member inline Gather (t: _ NonEmptySeq, f: 'T -> '``ZipFunctor<'U>``) = + #if TEST_TRACE + Traces.add "Gather NonEmptySeq" + #endif + let cons_f x ys = Map.Invoke (Seq.cons: 'a -> seq<_> -> seq<_>) (f x) <.> ys + Map.Invoke NonEmptySeq<_>.unsafeOfSeq (Seq.foldBack cons_f t (Pure.Invoke Seq.empty)) + + + static member inline Gather (t: NonEmptySeq<'T>, f: 'T -> '``ZipFunctor<'U>``) = + #if TEST_TRACE + Traces.add "Gather NonEmptySeq, 'T -> Functor<'U>" + #endif + let mapped = NonEmptySeq<_>.map f t + Transpose.ForInfiniteSequences (mapped, IsZipLeftZero.Invoke, NonEmptySeq<_>.ofList, Pure.Invoke) : '``Functor>`` + + + static member Gather (t: 't NonEmptySeq, f: 't -> Async<'u>) : Async> = async { + #if TEST_TRACE + Traces.add "Gather 't NonEmptySeq, 't -> Async<'u>" + #endif + + let! ct = Async.CancellationToken + return seq { + use enum = t.GetEnumerator () + while enum.MoveNext() do + yield Async.AsTask(f enum.Current, cancellationToken = ct).Result } |> NonEmptySeq<_>.unsafeOfSeq } + #endif + + static member inline Transpose (t: NonEmptySeq<'``ZipApplicative<'T>``>) : '``ZipApplicative>`` = Transpose.ForInfiniteSequences (t, IsZipLeftZero.Invoke, NonEmptySeq<_>.ofList, fun _ -> Unchecked.defaultof<_>) + static member Transpose (t: NonEmptySeq> ) : option> = Option.Sequential t |> Option.map NonEmptySeq<_>.unsafeOfSeq + static member inline Transpose (t: NonEmptySeq> ) : Result, 'e> = Result.Parallel ((++), t) |> Result.map NonEmptySeq<_>.unsafeOfSeq + static member inline Transpose (t: NonEmptySeq> ) : Choice, 'e> = Choice.Parallel ((++), t) |> Choice.map NonEmptySeq<_>.unsafeOfSeq + static member Transpose (t: NonEmptySeq> ) : list> = Transpose.ForInfiniteSequences (t, List.isEmpty , NonEmptySeq<_>.ofList, fun _ -> Unchecked.defaultof<_>) + static member Transpose (t: NonEmptySeq<'t []> ) : NonEmptySeq<'t> [] = Transpose.ForInfiniteSequences (t, Array.isEmpty, NonEmptySeq<_>.ofList, fun _ -> Unchecked.defaultof<_>) + #if !FABLE_COMPILER + static member Transpose (t: NonEmptySeq>) : Async> = Async.Parallel t |> Async.map NonEmptySeq<_>.unsafeOfSeq + #endif + + + + /// A type alias for NonEmptySeq<'t> type neseq<'t> = NonEmptySeq<'t> @@ -1122,6 +1272,8 @@ module NonEmptySeq = Seq.replace oldValue newValue source |> unsafeOfSeq + + [] module NonEmptySeqBuilder = type NESeqBuilder () = diff --git a/src/FSharpPlus/FSharpPlus.fsproj b/src/FSharpPlus/FSharpPlus.fsproj index b4b8374b4..fddb96ae5 100644 --- a/src/FSharpPlus/FSharpPlus.fsproj +++ b/src/FSharpPlus/FSharpPlus.fsproj @@ -23,7 +23,6 @@ AnyCPU 8.0 6.0 - $(DefineConstants);TEST_TRACE $(DefineConstants);FABLE_COMPILER $(DefineConstants);FABLE_COMPILER;FABLE_COMPILER_4 @@ -58,7 +57,6 @@ - @@ -86,6 +84,7 @@ + diff --git a/src/FSharpPlus/Internals.fs b/src/FSharpPlus/Internals.fs index 37ca1448a..ac09ef426 100644 --- a/src/FSharpPlus/Internals.fs +++ b/src/FSharpPlus/Internals.fs @@ -125,6 +125,10 @@ end [] type Set2<'T when 'T: comparison >() = class end +type NonEmptySeq2<'T> = + inherit System.Collections.Generic.IEnumerable<'T> + abstract member First: 'T + // BitConverter #nowarn "9" diff --git a/tests/FSharpPlus.Tests/Applicatives.fs b/tests/FSharpPlus.Tests/Applicatives.fs index 0f5ca4dd7..fdd6821ae 100644 --- a/tests/FSharpPlus.Tests/Applicatives.fs +++ b/tests/FSharpPlus.Tests/Applicatives.fs @@ -13,9 +13,10 @@ module Applicatives = let pureAndZipApply () = let res9n5 = map ((+) 1) [8;4] CollectionAssert.AreEqual ([9; 5], res9n5) - + (* let red20n30 = pur (+) <.> pur 10 <.> NonEmptySeq.ofList [10;20] CollectionAssert.AreEqual (NonEmptySeq.ofList [20; 30], red20n30) + *) [] diff --git a/tests/FSharpPlus.Tests/General.fs b/tests/FSharpPlus.Tests/General.fs index 97d0d522c..74ae5c6ed 100644 --- a/tests/FSharpPlus.Tests/General.fs +++ b/tests/FSharpPlus.Tests/General.fs @@ -966,9 +966,9 @@ module Applicative = Assert.AreEqual ([113; 213; 123; 223; 114; 214; 124; 224], testVal) Assert.IsInstanceOf>> (Some testVal) - let testVal2 = NonEmptySeq.create 1 [2] .+. NonEmptySeq.create 10 [20] .+. NonEmptySeq.create 100 [200] .+ 2 - Assert.AreEqual ([113; 213; 123; 223; 114; 214; 124; 224], Seq.toList testVal2) - Assert.IsInstanceOf>> (Some testVal2) + // let testVal2 = NonEmptySeq.create 1 [2] .+. NonEmptySeq.create 10 [20] .+. NonEmptySeq.create 100 [200] .+ 2 + // Assert.AreEqual ([113; 213; 123; 223; 114; 214; 124; 224], Seq.toList testVal2) + // Assert.IsInstanceOf>> (Some testVal2) let testLTE1 = Some 1 .<=. Some 2 Assert.AreEqual (Some true, testLTE1)