@@ -45,22 +45,27 @@ type NonEmptySeq<'t> =
45
45
46
46
static member (<|>) ( x : 'T NonEmptySeq , y ) = NonEmptySeq< 'T>. append x y
47
47
48
- static member inline Choice ( x : ref < NonEmptySeq < '``Alternative < 'T > ``>>, _mthd : Choice ) =
49
- use e = x.Value.GetEnumerator ()
48
+ #if ! FABLE_ COMPILER
49
+ static member inline Choice ( x : NonEmptySeq < '``Alternative < 'T > ``>) =
50
+ use e = x.GetEnumerator ()
50
51
e.MoveNext() |> ignore
51
52
let mutable res = e.Current
52
53
while e.MoveNext() && not ( IsAltLeftZero.Invoke res) do
53
54
res <- Append.Invoke res e.Current
54
55
56
+ static member Head ( x : NonEmptySeq < 'T >, [<Optional>] _impl : Head ) = x.First
57
+ static member TryHead ( x : NonEmptySeq < 'T >, [<Optional>] _impl : TryHead ) = Some x.First
58
+ static member TryLast ( x : NonEmptySeq < 'T >, [<Optional>] _impl : TryLast ) = Some <| Seq.last x
59
+ static member Unzip ( source : NonEmptySeq < 'T * 'U >) = Map.Invoke fst source, Map.Invoke snd source
60
+ #endif
61
+
62
+
55
63
static member (<*>) ( f : NonEmptySeq < _ > , x : NonEmptySeq < 'T >) : NonEmptySeq < 'U > = NonEmptySeq<_>. apply f x
56
64
static member Lift2 ( f , x : NonEmptySeq < _ > , y : NonEmptySeq < _ >) = NonEmptySeq<_>. lift2 f x y
57
65
static member Lift3 ( f , x : NonEmptySeq < _ > , y : NonEmptySeq < _ > , z : NonEmptySeq < _ >) = NonEmptySeq<_>. lift3 f x y z
58
66
static member IsLeftZero ( _ : NonEmptySeq < _ >) = false
59
67
60
- static member Head ( x : NonEmptySeq < 'T >, [<Optional>] _impl : Head ) = x.First
61
68
62
- static member TryHead ( x : NonEmptySeq < 'T >, [<Optional>] _impl : TryHead ) = Some x.First
63
- static member TryLast ( x : NonEmptySeq < 'T >, [<Optional>] _impl : TryLast ) = Some <| Seq.last x
64
69
65
70
static member Map ( x : NonEmptySeq < _ >, f : 'T -> 'U ) = NonEmptySeq<_>. map f x : NonEmptySeq< 'U>
66
71
@@ -70,7 +75,6 @@ type NonEmptySeq<'t> =
70
75
static member Map3 ( f , x : NonEmptySeq < _ >, y : NonEmptySeq < _ >, z : NonEmptySeq < _ >) = Seq.map3 f x y z |> NonEmptySeq<_>. unsafeOfSeq
71
76
static member IsZipLeftZero ( _ : NonEmptySeq < _ >) = false
72
77
73
- static member Unzip ( source : NonEmptySeq < 'T * 'U >) = Map.Invoke fst source, Map.Invoke snd source
74
78
static member Zip ( x : NonEmptySeq < 'T >, y : NonEmptySeq < 'U >) = NonEmptySeq<_>. zip x y
75
79
static member (>>= ) ( source: NonEmptySeq< 'T>, f: 'T -> NonEmptySeq< 'U>) = NonEmptySeq<_>. collect f source : NonEmptySeq< 'U>
76
80
@@ -84,6 +88,7 @@ type NonEmptySeq<'t> =
84
88
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>
85
89
static member inline (+) ( x : _ NonEmptySeq , y : _ NonEmptySeq ) = NonEmptySeq<_>. append x y
86
90
91
+ #if ! FABLE_ COMPILER
87
92
88
93
static member inline Traverse ( t : _ seq , f ) =
89
94
let cons x y = seq { yield x; yield ! y}
@@ -94,14 +99,13 @@ type NonEmptySeq<'t> =
94
99
let mapped = NonEmptySeq<_>. map f t
95
100
Sequence.ForInfiniteSequences ( mapped, IsLeftZero.Invoke, NonEmptySeq<_>. ofList, Return.Invoke) : '`` Functor<NonEmptySeq<'U>> ``
96
101
97
- #if ! FABLE_ COMPILER
98
102
static member Traverse ( t : 'T NonEmptySeq , f : 'T -> Async < 'u >) : Async < NonEmptySeq < _ >> = async {
99
103
let! ct = Async.CancellationToken
100
104
return seq {
101
105
use enum = t.GetEnumerator ()
102
106
while enum .MoveNext() do
103
107
yield Async.RunSynchronously ( f enum .Current, cancellationToken = ct) } |> NonEmptySeq<_>. unsafeOfSeq }
104
- #endif
108
+ // #endif
105
109
106
110
static member inline SequenceImpl ( t , _ , _ : obj ) = printfn " Using default4" ; Sequence.ForInfiniteSequences ( t, IsLeftZero.Invoke, NonEmptySeq<_>. ofList , Return.Invoke)
107
111
static member SequenceImpl ( t : NonEmptySeq < option < 'T >>, _ : option < NonEmptySeq < 'T >>, _ : Sequence ) : option < NonEmptySeq < 'T >> = printfn " Not using default4" ; Option.Sequential t |> Option.map NonEmptySeq<_>. unsafeOfSeq
@@ -110,15 +114,15 @@ type NonEmptySeq<'t> =
110
114
static member SequenceImpl ( t : NonEmptySeq < Choice < 'T , 'E >>) : Choice < NonEmptySeq < 'T >, 'E > = Choice.Sequential t |> Choice.map NonEmptySeq<_>. unsafeOfSeq
111
115
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, List.singleton)
112
116
static member SequenceImpl ( t : NonEmptySeq < 'T []> ) : NonEmptySeq < 'T > [] = Sequence.ForInfiniteSequences ( t, Array.isEmpty, NonEmptySeq<_>. ofList, Array.singleton)
113
- #if ! FABLE_ COMPILER
117
+ // #if !FABLE_COMPILER
114
118
static member SequenceImpl ( t : NonEmptySeq < Async < 'T >> ) : Async < NonEmptySeq < 'T >> = Async.SequentialLazy t |> Async.map NonEmptySeq<_>. unsafeOfSeq
115
- #endif
116
119
117
120
static member inline Sequence ( t : NonEmptySeq < '``Applicative < 'T > ``>) : '``Applicative < NonEmptySeq < 'T >> `` =
118
121
let inline call_3 ( a : ^a , b : ^b , c : ^c ) = (( ^a or ^b or ^c ) : ( static member SequenceImpl : _*_*_ -> _) b, c, a)
119
122
let inline call ( a : 'a , b : 'b ) = call_ 3 ( a, b, Unchecked.defaultof< 'R>) : 'R
120
123
call ( Unchecked.defaultof< Sequence>, t)
121
124
125
+ #endif
122
126
123
127
124
128
0 commit comments