Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gusty committed Sep 26, 2023
1 parent f3dba96 commit cf3c0c9
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/FSharpPlus/Data/NonEmptySeq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type NonEmptySeq<'t> =
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<_>) = printfn "asking if it's left zero"; false
static member IsLeftZero (_: NonEmptySeq<_>) = false

// no need, it should take the one from Seq --> member this.Head (x: NonEmptySeq<'T> , [<Optional>]_impl: Head ) = x.First

Expand All @@ -78,36 +78,24 @@ type NonEmptySeq<'t> =


static member inline Traverse (t: _ seq, f) =
printfn "traverse 1"
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<_>.unsafeOfSeq (Seq.foldBack cons_f t (result Seq.empty))

static member inline Traverse (t: NonEmptySeq<'T>, f: 'T->'``Functor<'U>``) =
printfn "traverse 2"
let mapped = NonEmptySeq<_>.map f t
Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq<_>.ofList) : '``Functor<NonEmptySeq<'U>>``

#if !FABLE_COMPILER
static member Traverse (t: 't NonEmptySeq, f: 't->Async<'u>) : Async<NonEmptySeq<_>> = async {
printfn "traverse 3"
let! ct = Async.CancellationToken
return seq {
use enum = t.GetEnumerator ()
while enum.MoveNext() do
yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) } |> NonEmptySeq<_>.unsafeOfSeq }
#endif

static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>) = printfn "sequence 1"; Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq<_>.ofList) : '``Applicative<NonEmptySeq<'T>>``
// static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<NonEmptySeq<'T>>`` , [<Optional>]_impl: obj) = printfn "sequence 1"; Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq<_>.ofList) : '``Applicative<NonEmptySeq<'T>>``
// static member Sequence (t: NonEmptySeq<option<'t>> ) = Sequence.ForInfiniteSequences(t, Option.isNone, NonEmptySeq<_>.ofList) : option<NonEmptySeq<'t>>
// static member Sequence (t: NonEmptySeq<Result<'t,'e>>) = Sequence.ForInfiniteSequences(t, (function Error _ -> true | _ -> false), NonEmptySeq<_>.ofList) : Result<NonEmptySeq<'t>, 'e>
// static member Sequence (t: NonEmptySeq<Choice<'t,'e>>) = Sequence.ForInfiniteSequences(t, (function Choice2Of2 _ -> true | _ -> false), NonEmptySeq<_>.ofList) : Choice<NonEmptySeq<'t>, 'e>
// static member Sequence (t: NonEmptySeq<list<'t>> ) = Sequence.ForInfiniteSequences(t, List.isEmpty, NonEmptySeq<_>.ofList) : list<NonEmptySeq<'t>>
// static member Sequence (t: NonEmptySeq<'t []> ) = Sequence.ForInfiniteSequences(t, Array.isEmpty, NonEmptySeq<_>.ofList) : NonEmptySeq<'t> []
// #if !FABLE_COMPILER
// static member Sequence (t: NonEmptySeq<Async<'t>>) = Async.Sequence t |> Async.map NonEmptySeq<_>.unsafeOfSeq : Async<NonEmptySeq<'t>>
// #endif
static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>) = Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq<_>.ofList) : '``Applicative<NonEmptySeq<'T>>``

/// A type alias for NonEmptySeq<'t>
type neseq<'t> = NonEmptySeq<'t>
Expand Down

0 comments on commit cf3c0c9

Please sign in to comment.