anchor.diff:                                                        return (if res then Some v else None) }
                           member x.Dispose() = () } }
       
  +  [<RequireQualifiedAccess>]
     type AppendState<'T> =
        | NotStarted1     of AsyncSeq<'T> * AsyncSeq<'T>
        | HaveEnumerator1 of IAsyncEnumerator<'T> * AsyncSeq<'T>
  
positive.code:      | Finished 
  
    let collect (f: 'T -> AsyncSeq<'U>) (inp: AsyncSeq<'T>) : AsyncSeq<'U> = 
          // Note: this is put outside the object deliberately, so the object doesn't permanently capture inp1 and inp2
          let initialState = NotStarted inp
          { new IAsyncEnumerable<'U> with 
                member x.GetEnumerator() = 
                    let state = ref initialState
                    { new IAsyncEnumerator<'U> with 
                          member x.MoveNext() = 
                              async { match !state with 
                                      | NotStarted inp -> 
                                          return! 
                                             (let e1 = inp.GetEnumerator()
                                              state := HaveInputEnumerator e1
                                              x.MoveNext())
                                      | HaveInputEnumerator e1 ->   
                                          let! res1 = e1.MoveNext() 
                                          return! 
                                             (match res1 with
                                              | Some v1 ->
                                                  let e2 = (f v1).GetEnumerator()
                                                  state := HaveInnerEnumerator (e1, e2)
                                              | None -> 
                                                  x.Dispose()
                                              x.MoveNext())
                                      | HaveInnerEnumerator (e1, e2) ->   
                                          let! res2 = e2.MoveNext() 
                                          match res2 with 
                                          | None ->
                                              state := HaveInputEnumerator e1
                                              dispose e2
                                              return! x.MoveNext()
                                          | Some _ -> 
  
negative.code:                                     | _ -> return None}
                          member x.Dispose() = 
                              match !state with 
                              | CollectSeqState.HaveInputEnumerator e1 -> 
                                  state := CollectSeqState.Finished
                                  dispose e1 
                              | CollectSeqState.HaveInnerEnumerator (e1, e2) -> 
                                  state := CollectSeqState.Finished
                                  dispose e2
                                  dispose e1
                                  x.Dispose()
                              | _ -> () } }
  
    [<RequireQualifiedAccess>]
    type MapState<'T> =
       | NotStarted    of seq<'T>
       | HaveEnumerator of IEnumerator<'T>
       | Finished 
  
    let ofSeq (inp: seq<'T>) : AsyncSeq<'T> = 
          { new IAsyncEnumerable<'T> with 
                member x.GetEnumerator() = 
                    let state = ref (MapState.NotStarted inp)
                    { new IAsyncEnumerator<'T> with 
                          member x.MoveNext() = 
                              async { match !state with 
                                      | MapState.NotStarted inp -> 
                                          let e = inp.GetEnumerator()
                                          state := MapState.HaveEnumerator e
                                          return! x.MoveNext()
                                      | MapState.HaveEnumerator e ->   
                                          return 
                                              (if e.MoveNext()  then 
                                                   Some e.Current
  