@@ -5,7 +5,9 @@ open System.Runtime.InteropServices
55open System.ComponentModel
66open System.Collections .Generic
77open FSharpPlus
8+ open FSharpPlus.Extensions
89open FSharpPlus.Control
10+ open Microsoft.FSharp .Core .CompilerServices
911
1012/// A type-safe sequence that contains at least one element.
1113[<Interface>]
@@ -78,24 +80,42 @@ type NonEmptySeq<'t> =
7880
7981
8082 static member inline Traverse ( t : _ seq , f ) =
81- let cons x y = seq { yield x; yield ! y}
82- let cons_f x ys = Map.Invoke ( cons: 'a-> seq<_> -> seq<_>) ( f x) <*> ys
83- Map.Invoke NonEmptySeq<_>. unsafeOfSeq ( Seq.foldBack cons_ f t ( result Seq.empty))
83+ let cons x y = seq { yield x; yield ! y}
84+ let cons_f x ys = Map.Invoke ( cons: 'a-> seq<_> -> seq<_>) ( f x) <*> ys
85+ Map.Invoke NonEmptySeq<_>. unsafeOfSeq ( Seq.foldBack cons_ f t ( result Seq.empty))
8486
8587 static member inline Traverse ( t : NonEmptySeq < 'T >, f : 'T -> '``Functor < 'U > ``) =
8688 let mapped = NonEmptySeq<_>. map f t
8789 Sequence.ForInfiniteSequences ( mapped, IsLeftZero.Invoke, NonEmptySeq<_>. ofList) : '`` Functor<NonEmptySeq<'U>> ``
8890
8991 #if ! FABLE_ COMPILER
90- static member Traverse ( t : 't NonEmptySeq , f : 't -> Async < 'u >) : Async < NonEmptySeq < _ >> = async {
92+ static member Traverse ( t : 'T NonEmptySeq , f : 'T -> Async < 'u >) : Async < NonEmptySeq < _ >> = async {
9193 let! ct = Async.CancellationToken
9294 return seq {
9395 use enum = t.GetEnumerator ()
9496 while enum .MoveNext() do
9597 yield Async.RunSynchronously ( f enum .Current, cancellationToken = ct) } |> NonEmptySeq<_>. unsafeOfSeq }
9698 #endif
9799
98- static member inline Sequence ( t : NonEmptySeq < '``Applicative < 'T > ``>) = Sequence.ForInfiniteSequences ( t, IsLeftZero.Invoke, NonEmptySeq<_>. ofList) : '`` Applicative<NonEmptySeq<'T>> ``
100+ static member inline SequenceImpl ( t , _ , _ : obj ) = printfn " Using default4" ; Sequence.ForInfiniteSequences ( t, IsLeftZero.Invoke, NonEmptySeq<_>. ofList)
101+ static member SequenceImpl ( t : NonEmptySeq < option < 'T >>, _ : option < NonEmptySeq < 'T >>, _ : Sequence ) : option < NonEmptySeq < 'T >> = printfn " Not using default4" ; Option.Sequence t |> Option.map NonEmptySeq<_>. unsafeOfSeq
102+
103+ static member SequenceImpl ( t : NonEmptySeq < Result < 'T , 'E >>) : Result < NonEmptySeq < 'T >, 'E > = Result.Sequence t |> Result.map NonEmptySeq<_>. unsafeOfSeq
104+ static member SequenceImpl ( t : NonEmptySeq < Choice < 'T , 'E >>) : Choice < NonEmptySeq < 'T >, 'E > = Choice.Sequence t |> Choice.map NonEmptySeq<_>. unsafeOfSeq
105+ static member SequenceImpl ( t : NonEmptySeq < list < 'T >> , _ : list < NonEmptySeq < 'T >> , _ : Sequence ) : list < NonEmptySeq < 'T >> = printfn " Not using default4" ; Sequence.ForInfiniteSequences ( t, List.isEmpty , NonEmptySeq<_>. ofList)
106+ static member SequenceImpl ( t : NonEmptySeq < 'T []> ) : NonEmptySeq < 'T > [] = Sequence.ForInfiniteSequences ( t, Array.isEmpty, NonEmptySeq<_>. ofList)
107+ #if ! FABLE_ COMPILER
108+ static member SequenceImpl ( t : NonEmptySeq < Async < 'T >> ) : Async < NonEmptySeq < 'T >> = Async.Sequence t |> Async.map NonEmptySeq<_>. unsafeOfSeq
109+ #endif
110+
111+ static member inline Sequence ( t : NonEmptySeq < '``Applicative < 'T > ``>) : '``Applicative < NonEmptySeq < 'T >> `` =
112+ let inline call_3 ( a : ^a , b : ^b , c : ^c ) = (( ^a or ^b or ^c ) : ( static member SequenceImpl : _*_*_ -> _) b, c, a)
113+ let inline call ( a : 'a , b : 'b ) = call_ 3 ( a, b, Unchecked.defaultof< 'R>) : 'R
114+ call ( Unchecked.defaultof< Sequence>, t)
115+
116+
117+
118+
99119
100120/// A type alias for NonEmptySeq<'t>
101121type neseq < 't > = NonEmptySeq< 't>
0 commit comments