Skip to content

Commit 050bee6

Browse files
committed
Exclude code for Fable
1 parent 2f9f3d3 commit 050bee6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/FSharpPlus/Data/NonEmptySeq.fs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,27 @@ type NonEmptySeq<'t> =
4545

4646
static member (<|>) (x: 'T NonEmptySeq , y) = NonEmptySeq<'T>.append x y
4747

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 ()
5051
e.MoveNext() |> ignore
5152
let mutable res = e.Current
5253
while e.MoveNext() && not (IsAltLeftZero.Invoke res) do
5354
res <- Append.Invoke res e.Current
5455

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+
5563
static member (<*>) (f: NonEmptySeq<_> , x: NonEmptySeq<'T>) : NonEmptySeq<'U> = NonEmptySeq<_>.apply f x
5664
static member Lift2 (f, x: NonEmptySeq<_> , y: NonEmptySeq<_>) = NonEmptySeq<_>.lift2 f x y
5765
static member Lift3 (f, x: NonEmptySeq<_> , y: NonEmptySeq<_> , z: NonEmptySeq<_>) = NonEmptySeq<_>.lift3 f x y z
5866
static member IsLeftZero (_: NonEmptySeq<_>) = false
5967

60-
static member Head (x: NonEmptySeq<'T>, [<Optional>]_impl: Head) = x.First
6168

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
6469

6570
static member Map (x: NonEmptySeq<_>, f: 'T -> 'U) = NonEmptySeq<_>.map f x : NonEmptySeq<'U>
6671

@@ -70,7 +75,6 @@ type NonEmptySeq<'t> =
7075
static member Map3 (f, x: NonEmptySeq<_>, y: NonEmptySeq<_>, z: NonEmptySeq<_>) = Seq.map3 f x y z |> NonEmptySeq<_>.unsafeOfSeq
7176
static member IsZipLeftZero (_: NonEmptySeq<_>) = false
7277

73-
static member Unzip (source: NonEmptySeq<'T * 'U>) = Map.Invoke fst source, Map.Invoke snd source
7478
static member Zip (x: NonEmptySeq<'T>, y: NonEmptySeq<'U>) = NonEmptySeq<_>.zip x y
7579
static member (>>=) (source: NonEmptySeq<'T>, f: 'T -> NonEmptySeq<'U>) = NonEmptySeq<_>.collect f source : NonEmptySeq<'U>
7680

@@ -84,6 +88,7 @@ type NonEmptySeq<'t> =
8488
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>
8589
static member inline (+) (x: _ NonEmptySeq , y: _ NonEmptySeq) = NonEmptySeq<_>.append x y
8690

91+
#if !FABLE_COMPILER
8792

8893
static member inline Traverse (t: _ seq, f) =
8994
let cons x y = seq {yield x; yield! y}
@@ -94,14 +99,13 @@ type NonEmptySeq<'t> =
9499
let mapped = NonEmptySeq<_>.map f t
95100
Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq<_>.ofList, Return.Invoke) : '``Functor<NonEmptySeq<'U>>``
96101

97-
#if !FABLE_COMPILER
98102
static member Traverse (t: 'T NonEmptySeq, f: 'T->Async<'u>) : Async<NonEmptySeq<_>> = async {
99103
let! ct = Async.CancellationToken
100104
return seq {
101105
use enum = t.GetEnumerator ()
102106
while enum.MoveNext() do
103107
yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) } |> NonEmptySeq<_>.unsafeOfSeq }
104-
#endif
108+
// #endif
105109

106110
static member inline SequenceImpl (t, _, _:obj) = printfn "Using default4"; Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq<_>.ofList , Return.Invoke)
107111
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> =
110114
static member SequenceImpl (t: NonEmptySeq<Choice<'T, 'E>>) : Choice<NonEmptySeq<'T>, 'E> = Choice.Sequential t |> Choice.map NonEmptySeq<_>.unsafeOfSeq
111115
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)
112116
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
114118
static member SequenceImpl (t: NonEmptySeq<Async<'T>> ) : Async<NonEmptySeq<'T>> = Async.SequentialLazy t |> Async.map NonEmptySeq<_>.unsafeOfSeq
115-
#endif
116119

117120
static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>) : '``Applicative<NonEmptySeq<'T>>`` =
118121
let inline call_3 (a: ^a, b: ^b, c: ^c) = ((^a or ^b or ^c) : (static member SequenceImpl : _*_*_ -> _) b, c, a)
119122
let inline call (a: 'a, b: 'b) = call_3 (a, b, Unchecked.defaultof<'R>) : 'R
120123
call (Unchecked.defaultof<Sequence>, t)
121124

125+
#endif
122126

123127

124128

0 commit comments

Comments
 (0)