From cb219a88aec11aabe36b37869e5413601b1606a0 Mon Sep 17 00:00:00 2001
From: Paul Westcott
Date: Mon, 13 Mar 2017 20:06:20 +1100
Subject: [PATCH 001/120] Added ISeq module
---
.../SurfaceArea.net40.fs | 193 ++
src/fsharp/FSharp.Core/FSharp.Core.fsproj | 6 +
src/fsharp/FSharp.Core/iseq.fs | 1725 +++++++++++++++++
src/fsharp/FSharp.Core/iseq.fsi | 362 ++++
4 files changed, 2286 insertions(+)
create mode 100644 src/fsharp/FSharp.Core/iseq.fs
create mode 100644 src/fsharp/FSharp.Core/iseq.fsi
diff --git a/src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs b/src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs
index 7db771e825d..17083f1f7ae 100644
--- a/src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs
+++ b/src/fsharp/FSharp.Core.Unittests/SurfaceArea.net40.fs
@@ -280,6 +280,199 @@ Microsoft.FSharp.Collections.HashIdentity: System.Collections.Generic.IEqualityC
Microsoft.FSharp.Collections.HashIdentity: System.Collections.Generic.IEqualityComparer`1[T] Structural[T]()
Microsoft.FSharp.Collections.HashIdentity: System.String ToString()
Microsoft.FSharp.Collections.HashIdentity: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void .ctor()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Int32 HaltedIdx
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: TResult Result
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void .ctor(TResult, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void OnComplete(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void OnDispose()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Int32 HaltedIdx
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: TResult Result
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void .ctor(TResult, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+IOutOfBand: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]: ISeq`1 PushTransform[TResult](TransformFactory`2)
+Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]: TResult Fold[TResult,TState](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]])
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Activity`2 Compose[V](IOutOfBand, Int32, Activity`2)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Void .ctor()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void .ctor(Activity, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void OnComplete(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void OnDispose()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void .ctor(Activity, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Void .ctor(a)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Void .ctor(a, b)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: b _2
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Void .ctor(a, b, c)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: b _2
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: c _3
+Microsoft.FSharp.Collections.ISeqModule+Core: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Activity
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+IOutOfBand
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+NoValue
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]
+Microsoft.FSharp.Collections.ISeqModule+Core: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule: Boolean Contains[T](T, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Exists2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,System.Boolean]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Exists[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean ForAll2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,System.Boolean]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean ForAll[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Append[T](ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Choose[a,b](Microsoft.FSharp.Core.FSharpFunc`2[a,Microsoft.FSharp.Core.FSharpOption`1[b]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Concat[TCollection,T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 CountByRef[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 CountByVal[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Delay[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 DistinctBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Distinct[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Empty[T]()
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Except[T](System.Collections.Generic.IEnumerable`1[T], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Filter[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 GroupByRef[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 GroupByVal[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Indexed[a](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 InitializeInfinite[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Initialize[T](Int32, Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map2[T,TResult,V](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,V]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map3[T,TResult,V,W](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.FSharpFunc`2[V,W]]], ISeq`1, ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 MapIndexed2[T,TResult,V](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,V]]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 MapIndexed[a,b](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[a,b]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfArray[T](T[])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfList[T](Microsoft.FSharp.Collections.FSharpList`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfResizeArrayUnchecked[T](System.Collections.Generic.List`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfSeq[T](System.Collections.Generic.IEnumerable`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Pairwise[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Permute[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,System.Int32], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Reverse[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 ScanBack[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]], ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Scan[TState,T](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T,TState]], TState, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SkipWhile[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Skip[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SortBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SortWith[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,System.Int32]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Sort[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Tail[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 TakeWhile[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Take[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Truncate[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Unfold[TState,T](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[T,TState]]], TState)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Windowed[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Zip[T1,T2](ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Int32 CompareWith[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,System.Int32]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule: Int32 Length[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Collections.ISeqModule+Core
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[System.Int32] TryFindIndex[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[TResult] TryPick[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpOption`1[TResult]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryFind[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryHead[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryItem[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule: T Average[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T ExactlyOne[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Head[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Last[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T MaxBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Max[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T MinBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Min[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T ReduceBack[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,T]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Reduce[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,T]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Sum[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TResult AverageBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TResult SumBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TState Fold2[T1,T2,TState](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,TState]]], TState, ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TState FoldBack2[T1,T2,TState](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]]], ISeq`1, ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: TState FoldBack[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]], ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: TState Fold[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T,TState]], TState, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T[] ToArray[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void Iterate2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.Unit]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void IterateIndexed2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.Unit]]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void IterateIndexed[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.Unit]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void Iterate[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.Unit], ISeq`1)
Microsoft.FSharp.Collections.ListModule: Boolean Contains[T](T, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Boolean Equals(System.Object)
Microsoft.FSharp.Collections.ListModule: Boolean Exists2[T1,T2](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,System.Boolean]], Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
diff --git a/src/fsharp/FSharp.Core/FSharp.Core.fsproj b/src/fsharp/FSharp.Core/FSharp.Core.fsproj
index 204f628733d..207cf5b3861 100644
--- a/src/fsharp/FSharp.Core/FSharp.Core.fsproj
+++ b/src/fsharp/FSharp.Core/FSharp.Core.fsproj
@@ -104,6 +104,12 @@
Collections/seqcore.fs
+
+ Collections/iseq.fsi
+
+
+ Collections/iseq.fs
+
Collections/seq.fsi
diff --git a/src/fsharp/FSharp.Core/iseq.fs b/src/fsharp/FSharp.Core/iseq.fs
new file mode 100644
index 00000000000..d99e39639cd
--- /dev/null
+++ b/src/fsharp/FSharp.Core/iseq.fs
@@ -0,0 +1,1725 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Collections
+
+ open System
+ open System.Diagnostics
+ open System.Collections
+ open System.Collections.Generic
+ open System.Reflection
+ open Microsoft.FSharp.Core
+ open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
+ open Microsoft.FSharp.Core.Operators
+ open Microsoft.FSharp.Core.CompilerServices
+ open Microsoft.FSharp.Control
+ open Microsoft.FSharp.Collections
+ open Microsoft.FSharp.Primitives.Basics
+
+ []
+ module ISeq =
+ open IEnumerator
+
+ module Core =
+ []
+ type NoValue = struct end
+
+ []
+ type Value<'a> =
+ val mutable _1 : 'a
+ new (a:'a) = { _1 = a }
+
+ []
+ type Values<'a,'b> =
+ val mutable _1 : 'a
+ val mutable _2 : 'b
+ new (a:'a, b: 'b) = { _1 = a; _2 = b }
+
+ []
+ type Values<'a,'b,'c> =
+ val mutable _1 : 'a
+ val mutable _2 : 'b
+ val mutable _3 : 'c
+ new (a:'a, b:'b, c:'c) = { _1 = a; _2 = b; _3 = c }
+
+ type PipeIdx = int
+
+ type IOutOfBand =
+ abstract StopFurtherProcessing : PipeIdx -> unit
+
+ []
+ type Activity() =
+ abstract ChainComplete : stopTailCall:byref * PipeIdx -> unit
+ abstract ChainDispose : stopTailCall:byref -> unit
+
+ []
+ type Activity<'T,'U> () =
+ inherit Activity()
+ abstract ProcessNext : input:'T -> bool
+
+ []
+ type Transform<'T,'U,'State> =
+ inherit Activity<'T,'U>
+
+ new (next:Activity, initState:'State) = {
+ inherit Activity<'T,'U> ()
+ State = initState
+ Next = next
+ }
+
+ val mutable State : 'State
+ val Next : Activity
+
+ override this.ChainComplete (stopTailCall, terminatingIdx) =
+ this.Next.ChainComplete (&stopTailCall, terminatingIdx)
+ override this.ChainDispose stopTailCall =
+ this.Next.ChainDispose (&stopTailCall)
+
+ []
+ type TransformWithPostProcessing<'T,'U,'State>(next:Activity, initState:'State) =
+ inherit Transform<'T,'U,'State>(next, initState)
+
+ abstract OnComplete : PipeIdx -> unit
+ abstract OnDispose : unit -> unit
+
+ override this.ChainComplete (stopTailCall, terminatingIdx) =
+ this.OnComplete terminatingIdx
+ this.Next.ChainComplete (&stopTailCall, terminatingIdx)
+ override this.ChainDispose stopTailCall =
+ try this.OnDispose ()
+ finally this.Next.ChainDispose (&stopTailCall)
+
+ []
+ type Folder<'T,'Result,'State> =
+ inherit Activity<'T,'T>
+
+ val mutable Result : 'Result
+ val mutable State : 'State
+
+ val mutable HaltedIdx : int
+ member this.StopFurtherProcessing pipeIdx = this.HaltedIdx <- pipeIdx
+ interface IOutOfBand with
+ member this.StopFurtherProcessing pipeIdx = this.StopFurtherProcessing pipeIdx
+
+ new (initalResult,initState) = {
+ inherit Activity<'T,'T>()
+ State = initState
+ HaltedIdx = 0
+ Result = initalResult
+ }
+
+ override this.ChainComplete (_,_) = ()
+ override this.ChainDispose _ = ()
+
+ []
+ type FolderWithPostProcessing<'T,'Result,'State>(initResult,initState) =
+ inherit Folder<'T,'Result,'State>(initResult,initState)
+
+ abstract OnComplete : PipeIdx -> unit
+ abstract OnDispose : unit -> unit
+
+ override this.ChainComplete (stopTailCall, terminatingIdx) =
+ this.OnComplete terminatingIdx
+ override this.ChainDispose _ =
+ this.OnDispose ()
+
+ []
+ type TransformFactory<'T,'U> () =
+ abstract Compose<'V> : IOutOfBand -> PipeIdx -> Activity<'U,'V> -> Activity<'T,'V>
+
+ type ISeq<'T> =
+ inherit IEnumerable<'T>
+ abstract member PushTransform<'U> : TransformFactory<'T,'U> -> ISeq<'U>
+ abstract member Fold<'Result,'State> : f:(PipeIdx->Folder<'T,'Result,'State>) -> 'Result
+
+ open Core
+
+ module internal TailCall =
+ // used for performance reasons; these are not recursive calls, so should be safe
+ // ** it should be noted that potential changes to the f# compiler may render this function
+ // ineffictive **
+ let inline avoid boolean = match boolean with true -> true | false -> false
+
+ module internal Upcast =
+ // The f# compiler outputs unnecessary unbox.any calls in upcasts. If this functionality
+ // is fixed with the compiler then these functions can be removed.
+ let inline seq<'T,'seq when 'seq :> ISeq<'T> and 'seq : not struct> (t:'seq) : ISeq<'T> = (# "" t : ISeq<'T> #)
+ let inline enumerable<'T,'enumerable when 'enumerable :> IEnumerable<'T> and 'enumerable : not struct> (t:'enumerable) : IEnumerable<'T> = (# "" t : IEnumerable<'T> #)
+ let inline enumerator<'T,'enumerator when 'enumerator :> IEnumerator<'T> and 'enumerator : not struct> (t:'enumerator) : IEnumerator<'T> = (# "" t : IEnumerator<'T> #)
+ let inline enumeratorNonGeneric<'enumerator when 'enumerator :> IEnumerator and 'enumerator : not struct> (t:'enumerator) : IEnumerator = (# "" t : IEnumerator #)
+ let inline outOfBand<'outOfBand when 'outOfBand :> IOutOfBand and 'outOfBand : not struct> (t:'outOfBand) : IOutOfBand = (# "" t : IOutOfBand #)
+
+ let createFold (factory:TransformFactory<_,_>) (folder:Folder<_,_,_>) pipeIdx =
+ factory.Compose (Upcast.outOfBand folder) pipeIdx folder
+
+ let inline valueComparer<'T when 'T : equality> ()=
+ let c = HashIdentity.Structural<'T>
+ { new IEqualityComparer> with
+ member __.GetHashCode o = c.GetHashCode o._1
+ member __.Equals (lhs,rhs) = c.Equals (lhs._1, rhs._1) }
+
+ type ComposedFactory<'T,'U,'V> private (first:TransformFactory<'T,'U>, second:TransformFactory<'U,'V>) =
+ inherit TransformFactory<'T,'V>()
+
+ override this.Compose<'W> (outOfBand:IOutOfBand) (pipeIdx:PipeIdx) (next:Activity<'V,'W>) : Activity<'T,'W> =
+ first.Compose outOfBand (pipeIdx-1) (second.Compose outOfBand pipeIdx next)
+
+ static member Combine (first:TransformFactory<'T,'U>) (second:TransformFactory<'U,'V>) : TransformFactory<'T,'V> =
+ upcast ComposedFactory(first, second)
+
+ and IdentityFactory<'T> private () =
+ inherit TransformFactory<'T,'T> ()
+ static let singleton : TransformFactory<'T,'T> = upcast (IdentityFactory<'T>())
+ override __.Compose<'V> (_outOfBand:IOutOfBand) (_pipeIdx:PipeIdx) (next:Activity<'T,'V>) : Activity<'T,'V> = next
+ static member Instance = singleton
+
+ and ISkipable =
+ // Seq.init(Infinite)? lazily uses Current. The only ISeq component that can do that is Skip
+ // and it can only do it at the start of a sequence
+ abstract CanSkip : unit -> bool
+
+ type SeqProcessNextStates =
+ | InProcess = 0
+ | NotStarted = 1
+ | Finished = 2
+
+ type Result<'T>() =
+ inherit Folder<'T,'T,NoValue>(Unchecked.defaultof<'T>,Unchecked.defaultof)
+
+ member val SeqState = SeqProcessNextStates.NotStarted with get, set
+
+ override this.ProcessNext (input:'T) : bool =
+ this.Result <- input
+ true
+
+ module Fold =
+ type IIterate<'T> =
+ abstract Iterate<'U,'Result,'State> : outOfBand:Folder<'U,'Result,'State> -> consumer:Activity<'T,'U> -> unit
+
+ []
+ type enumerable<'T> (enumerable:IEnumerable<'T>) =
+ interface IIterate<'T> with
+ member __.Iterate (outOfBand:Folder<'U,'Result,'State>) (consumer:Activity<'T,'U>) =
+ use enumerator = enumerable.GetEnumerator ()
+ let rec iterate () =
+ if enumerator.MoveNext () then
+ consumer.ProcessNext enumerator.Current |> ignore
+ if outOfBand.HaltedIdx = 0 then
+ iterate ()
+ iterate ()
+
+ []
+ type Array<'T> (array:array<'T>) =
+ interface IIterate<'T> with
+ member __.Iterate (outOfBand:Folder<'U,'Result,'State>) (consumer:Activity<'T,'U>) =
+ let array = array
+ let rec iterate idx =
+ if idx < array.Length then
+ consumer.ProcessNext array.[idx] |> ignore
+ if outOfBand.HaltedIdx = 0 then
+ iterate (idx+1)
+ iterate 0
+
+ []
+ type resizeArray<'T> (array:ResizeArray<'T>) =
+ interface IIterate<'T> with
+ member __.Iterate (outOfBand:Folder<'U,'Result,'State>) (consumer:Activity<'T,'U>) =
+ let array = array
+ let rec iterate idx =
+ if idx < array.Count then
+ consumer.ProcessNext array.[idx] |> ignore
+ if outOfBand.HaltedIdx = 0 then
+ iterate (idx+1)
+ iterate 0
+
+ []
+ type List<'T> (alist:list<'T>) =
+ interface IIterate<'T> with
+ member __.Iterate (outOfBand:Folder<'U,'Result,'State>) (consumer:Activity<'T,'U>) =
+ let rec iterate lst =
+ match lst with
+ | hd :: tl ->
+ consumer.ProcessNext hd |> ignore
+ if outOfBand.HaltedIdx = 0 then
+ iterate tl
+ | _ -> ()
+ iterate alist
+
+ []
+ type unfold<'S,'T> (generator:'S->option<'T*'S>, state:'S) =
+ interface IIterate<'T> with
+ member __.Iterate (outOfBand:Folder<'U,'Result,'State>) (consumer:Activity<'T,'U>) =
+ let generator = generator
+ let rec iterate current =
+ match generator current with
+ | Some (item, next) ->
+ consumer.ProcessNext item |> ignore
+ if outOfBand.HaltedIdx = 0 then
+ iterate next
+ | _ -> ()
+ iterate state
+
+ []
+ type init<'T> (f:int->'T, terminatingIdx:int) =
+ interface IIterate<'T> with
+ member __.Iterate (outOfBand:Folder<'U,'Result,'State>) (consumer:Activity<'T,'U>) =
+ let terminatingIdx = terminatingIdx
+ let f = f
+
+ let firstIdx =
+ match box consumer with
+ | :? ISkipable as skipping ->
+ let rec skip idx =
+ if idx = terminatingIdx || outOfBand.HaltedIdx <> 0 then
+ terminatingIdx
+ elif skipping.CanSkip () then
+ skip (idx+1)
+ else
+ idx
+ skip -1
+ | _ -> -1
+
+ let rec iterate idx =
+ if idx < terminatingIdx then
+ consumer.ProcessNext (f (idx+1)) |> ignore
+ if outOfBand.HaltedIdx = 0 then
+ iterate (idx+1)
+ else
+ idx
+ else
+ idx
+
+ let finalIdx = iterate firstIdx
+ if outOfBand.HaltedIdx = 0 && finalIdx = System.Int32.MaxValue then
+ raise <| System.InvalidOperationException (SR.GetString(SR.enumerationPastIntMaxValue))
+
+ let execute (createFolder:PipeIdx->Folder<'U,'Result,'State>) (transformFactory:TransformFactory<'T,'U>) pipeIdx (executeOn:#IIterate<'T>) =
+ let mutable stopTailCall = ()
+ let result = createFolder (pipeIdx+1)
+ let consumer = createFold transformFactory result pipeIdx
+ try
+ executeOn.Iterate result consumer
+ consumer.ChainComplete (&stopTailCall, result.HaltedIdx)
+ result.Result
+ finally
+ consumer.ChainDispose (&stopTailCall)
+
+ let executeThin (createFolder:PipeIdx->Folder<'T,'Result,'State>) (executeOn:#IIterate<'T>) =
+ let mutable stopTailCall = ()
+ let result = createFolder 1
+ try
+ executeOn.Iterate result result
+ result.ChainComplete (&stopTailCall, result.HaltedIdx)
+ result.Result
+ finally
+ result.ChainDispose (&stopTailCall)
+
+ module Enumerable =
+ type Empty<'T>() =
+ let current () = failwith "library implementation error: Current should never be called"
+ interface IEnumerator<'T> with
+ member __.Current = current ()
+ interface IEnumerator with
+ member __.Current = current ()
+ member __.MoveNext () = false
+ member __.Reset (): unit = noReset ()
+ interface IDisposable with
+ member __.Dispose () = ()
+
+ type EmptyEnumerators<'T>() =
+ static let element : IEnumerator<'T> = upcast (new Empty<'T> ())
+ static member Element = element
+
+ []
+ type EnumeratorBase<'T>(result:Result<'T>, activity:Activity) =
+ interface IDisposable with
+ member __.Dispose () : unit =
+ let mutable stopTailCall = ()
+ activity.ChainDispose (&stopTailCall)
+
+ interface IEnumerator with
+ member this.Current : obj = box ((Upcast.enumerator this)).Current
+ member __.MoveNext () = failwith "library implementation error: derived class should implement (should be abstract)"
+ member __.Reset () : unit = noReset ()
+
+ interface IEnumerator<'T> with
+ member __.Current =
+ if result.SeqState = SeqProcessNextStates.InProcess then result.Result
+ else
+ match result.SeqState with
+ | SeqProcessNextStates.NotStarted -> notStarted()
+ | SeqProcessNextStates.Finished -> alreadyFinished()
+ | _ -> failwith "library implementation error: all states should have been handled"
+
+ and [] EnumerableBase<'T> () =
+ let derivedClassShouldImplement () =
+ failwith "library implementation error: derived class should implement (should be abstract)"
+
+ abstract member Append : (ISeq<'T>) -> ISeq<'T>
+
+ default this.Append source = Upcast.seq (AppendEnumerable [this; source])
+
+ interface IEnumerable with
+ member this.GetEnumerator () : IEnumerator =
+ let genericEnumerable = Upcast.enumerable this
+ let genericEnumerator = genericEnumerable.GetEnumerator ()
+ Upcast.enumeratorNonGeneric genericEnumerator
+
+ interface IEnumerable<'T> with
+ member this.GetEnumerator () : IEnumerator<'T> = derivedClassShouldImplement ()
+
+ interface ISeq<'T> with
+ member __.PushTransform _ = derivedClassShouldImplement ()
+ member __.Fold _ = derivedClassShouldImplement ()
+
+ and Enumerator<'T,'U>(source:IEnumerator<'T>, activity:Activity<'T,'U>, result:Result<'U>) =
+ inherit EnumeratorBase<'U>(result, activity)
+
+ let rec moveNext () =
+ if (result.HaltedIdx = 0) && source.MoveNext () then
+ if activity.ProcessNext source.Current then
+ true
+ else
+ moveNext ()
+ else
+ result.SeqState <- SeqProcessNextStates.Finished
+ let mutable stopTailCall = ()
+ activity.ChainComplete (&stopTailCall, result.HaltedIdx)
+ false
+
+ interface IEnumerator with
+ member __.MoveNext () =
+ result.SeqState <- SeqProcessNextStates.InProcess
+ moveNext ()
+
+ interface IDisposable with
+ member __.Dispose () =
+ try
+ source.Dispose ()
+ finally
+ let mutable stopTailCall = ()
+ activity.ChainDispose (&stopTailCall)
+
+ and Enumerable<'T,'U>(enumerable:IEnumerable<'T>, current:TransformFactory<'T,'U>, pipeIdx:PipeIdx) =
+ inherit EnumerableBase<'U>()
+
+ interface IEnumerable<'U> with
+ member this.GetEnumerator () : IEnumerator<'U> =
+ let result = Result<'U> ()
+ Upcast.enumerator (new Enumerator<'T,'U>(enumerable.GetEnumerator(), createFold current result pipeIdx, result))
+
+ interface ISeq<'U> with
+ member __.PushTransform (next:TransformFactory<'U,'V>) : ISeq<'V> =
+ Upcast.seq (new Enumerable<'T,'V>(enumerable, ComposedFactory.Combine current next, pipeIdx+1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'U,'Result,'State>) =
+ Fold.execute f current pipeIdx (Fold.enumerable enumerable)
+
+ and EnumerableThin<'T>(enumerable:IEnumerable<'T>) =
+ inherit EnumerableBase<'T>()
+
+ interface IEnumerable<'T> with
+ member this.GetEnumerator () = enumerable.GetEnumerator ()
+
+ interface ISeq<'T> with
+ member __.PushTransform (next:TransformFactory<'T,'U>) : ISeq<'U> =
+ Upcast.seq (new Enumerable<'T,'U>(enumerable, next, 1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'T,'Result,'State>) =
+ Fold.executeThin f (Fold.enumerable enumerable)
+
+ and SeqDelayed<'T>(delayed:unit->ISeq<'T>, pipeIdx:PipeIdx) =
+ inherit EnumerableBase<'T>()
+
+ interface IEnumerable<'T> with
+ member this.GetEnumerator () : IEnumerator<'T> = (delayed()).GetEnumerator ()
+
+ interface ISeq<'T> with
+ member __.PushTransform (next:TransformFactory<'T,'U>) : ISeq<'U> =
+ Upcast.seq (new SeqDelayed<'U>((fun () -> (delayed()).PushTransform next), pipeIdx+1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'T,'Result,'State>) =
+ (delayed()).Fold f
+
+ and ConcatEnumerator<'T, 'Collection when 'Collection :> seq<'T>> (sources:seq<'Collection>) =
+ let mutable state = SeqProcessNextStates.NotStarted
+ let main = sources.GetEnumerator ()
+
+ let mutable active = EmptyEnumerators.Element
+
+ let rec moveNext () =
+ if active.MoveNext () then
+ true
+ elif main.MoveNext () then
+ active.Dispose ()
+ active <- main.Current.GetEnumerator ()
+ moveNext ()
+ else
+ state <- SeqProcessNextStates.Finished
+ false
+
+ interface IEnumerator<'T> with
+ member __.Current =
+ if state = SeqProcessNextStates.InProcess then active.Current
+ else
+ match state with
+ | SeqProcessNextStates.NotStarted -> notStarted()
+ | SeqProcessNextStates.Finished -> alreadyFinished()
+ | _ -> failwith "library implementation error: all states should have been handled"
+
+ interface IEnumerator with
+ member this.Current = box ((Upcast.enumerator this)).Current
+ member __.MoveNext () =
+ state <- SeqProcessNextStates.InProcess
+ moveNext ()
+ member __.Reset () = noReset ()
+
+ interface IDisposable with
+ member __.Dispose () =
+ main.Dispose ()
+ active.Dispose ()
+
+ and AppendEnumerable<'T> (sources:list>) =
+ inherit EnumerableBase<'T>()
+
+ interface IEnumerable<'T> with
+ member this.GetEnumerator () : IEnumerator<'T> =
+ Upcast.enumerator (new ConcatEnumerator<_,_> (sources |> List.rev))
+
+ override this.Append source =
+ Upcast.seq (AppendEnumerable (source::sources))
+
+ interface ISeq<'T> with
+ member this.PushTransform (next:TransformFactory<'T,'U>) : ISeq<'U> =
+ Upcast.seq (Enumerable<'T,'V>(this, next, 1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'T,'Result,'State>) =
+ Fold.executeThin f (Fold.enumerable this)
+
+ and ConcatEnumerable<'T, 'Collection when 'Collection :> seq<'T>> (sources:seq<'Collection>) =
+ inherit EnumerableBase<'T>()
+
+ interface IEnumerable<'T> with
+ member this.GetEnumerator () : IEnumerator<'T> =
+ Upcast.enumerator (new ConcatEnumerator<_,_> (sources))
+
+ interface ISeq<'T> with
+ member this.PushTransform (next:TransformFactory<'T,'U>) : ISeq<'U> =
+ Upcast.seq (Enumerable<'T,'V>(this, next, 1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'T,'Result,'State>) =
+ Fold.executeThin f (Fold.enumerable this)
+
+ let create enumerable current =
+ Upcast.seq (Enumerable (enumerable, current, 1))
+
+ module EmptyEnumerable =
+ type Enumerable<'T> () =
+ inherit Enumerable.EnumerableBase<'T>()
+
+ static let singleton = Enumerable<'T>() :> ISeq<'T>
+ static member Instance = singleton
+
+ interface IEnumerable<'T> with
+ member this.GetEnumerator () : IEnumerator<'T> = IEnumerator.Empty<'T>()
+
+ override this.Append source =
+ Upcast.seq (Enumerable.EnumerableThin<'T> source)
+
+ interface ISeq<'T> with
+ member this.PushTransform (next:TransformFactory<'T,'U>) : ISeq<'U> =
+ Upcast.seq (Enumerable.Enumerable<'T,'V>(this, next, 1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'T,'Result,'State>) =
+ Fold.executeThin f (Fold.enumerable this)
+
+ module Array =
+ type Enumerator<'T,'U>(array:array<'T>, activity:Activity<'T,'U>, result:Result<'U>) =
+ inherit Enumerable.EnumeratorBase<'U>(result, activity)
+
+ let mutable idx = 0
+
+ let rec moveNext () =
+ if (result.HaltedIdx = 0) && idx < array.Length then
+ idx <- idx+1
+ if activity.ProcessNext array.[idx-1] then
+ true
+ else
+ moveNext ()
+ else
+ result.SeqState <- SeqProcessNextStates.Finished
+ let mutable stopTailCall = ()
+ activity.ChainComplete (&stopTailCall, result.HaltedIdx)
+ false
+
+ interface IEnumerator with
+ member __.MoveNext () =
+ result.SeqState <- SeqProcessNextStates.InProcess
+ moveNext ()
+
+ type Enumerable<'T,'U>(array:array<'T>, transformFactory:TransformFactory<'T,'U>, pipeIdx:PipeIdx) =
+ inherit Enumerable.EnumerableBase<'U>()
+
+ interface IEnumerable<'U> with
+ member this.GetEnumerator () : IEnumerator<'U> =
+ let result = Result<'U> ()
+ Upcast.enumerator (new Enumerator<'T,'U>(array, createFold transformFactory result pipeIdx, result))
+
+ interface ISeq<'U> with
+ member __.PushTransform (next:TransformFactory<'U,'V>) : ISeq<'V> =
+ Upcast.seq (new Enumerable<'T,'V>(array, ComposedFactory.Combine transformFactory next, 1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'U,'Result,'State>) =
+ Fold.execute f transformFactory pipeIdx (Fold.Array array)
+
+ module ResizeArray =
+ type Enumerator<'T,'U>(array:ResizeArray<'T>, activity:Activity<'T,'U>, result:Result<'U>) =
+ inherit Enumerable.EnumeratorBase<'U>(result, activity)
+
+ let mutable idx = 0
+
+ let rec moveNext () =
+ if (result.HaltedIdx = 0) && idx < array.Count then
+ idx <- idx+1
+ if activity.ProcessNext array.[idx-1] then
+ true
+ else
+ moveNext ()
+ else
+ result.SeqState <- SeqProcessNextStates.Finished
+ let mutable stopTailCall = ()
+ activity.ChainComplete (&stopTailCall, result.HaltedIdx)
+ false
+
+ interface IEnumerator with
+ member __.MoveNext () =
+ result.SeqState <- SeqProcessNextStates.InProcess
+ moveNext ()
+
+ type Enumerable<'T,'U>(resizeArray:ResizeArray<'T>, transformFactory:TransformFactory<'T,'U>, pipeIdx:PipeIdx) =
+ inherit Enumerable.EnumerableBase<'U>()
+
+ interface IEnumerable<'U> with
+ member this.GetEnumerator () : IEnumerator<'U> =
+ let result = Result<'U> ()
+ Upcast.enumerator (new Enumerator<'T,'U>(resizeArray, createFold transformFactory result pipeIdx, result))
+
+ interface ISeq<'U> with
+ member __.PushTransform (next:TransformFactory<'U,'V>) : ISeq<'V> =
+ Upcast.seq (new Enumerable<'T,'V>(resizeArray, ComposedFactory.Combine transformFactory next, 1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'U,'Result,'State>) =
+ Fold.execute f transformFactory pipeIdx (Fold.resizeArray resizeArray)
+
+ module List =
+ type Enumerator<'T,'U>(alist:list<'T>, activity:Activity<'T,'U>, result:Result<'U>) =
+ inherit Enumerable.EnumeratorBase<'U>(result, activity)
+
+ let mutable list = alist
+
+ let rec moveNext current =
+ match result.HaltedIdx, current with
+ | 0, head::tail ->
+ if activity.ProcessNext head then
+ list <- tail
+ true
+ else
+ moveNext tail
+ | _ ->
+ result.SeqState <- SeqProcessNextStates.Finished
+ let mutable stopTailCall = ()
+ activity.ChainComplete (&stopTailCall, result.HaltedIdx)
+ false
+
+ interface IEnumerator with
+ member __.MoveNext () =
+ result.SeqState <- SeqProcessNextStates.InProcess
+ moveNext list
+
+ type Enumerable<'T,'U>(alist:list<'T>, transformFactory:TransformFactory<'T,'U>, pipeIdx:PipeIdx) =
+ inherit Enumerable.EnumerableBase<'U>()
+
+ interface IEnumerable<'U> with
+ member this.GetEnumerator () : IEnumerator<'U> =
+ let result = Result<'U> ()
+ Upcast.enumerator (new Enumerator<'T,'U>(alist, createFold transformFactory result pipeIdx, result))
+
+ interface ISeq<'U> with
+ member __.PushTransform (next:TransformFactory<'U,'V>) : ISeq<'V> =
+ Upcast.seq (new Enumerable<'T,'V>(alist, ComposedFactory.Combine transformFactory next, pipeIdx+1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'U,'Result,'State>) =
+ Fold.execute f transformFactory pipeIdx (Fold.List alist)
+
+ let create alist current =
+ Upcast.seq (Enumerable(alist, current, 1))
+
+ module Unfold =
+ type Enumerator<'T,'U,'State>(generator:'State->option<'T*'State>, state:'State, activity:Activity<'T,'U>, result:Result<'U>) =
+ inherit Enumerable.EnumeratorBase<'U>(result, activity)
+
+ let mutable current = state
+
+ let rec moveNext () =
+ match result.HaltedIdx, generator current with
+ | 0, Some (item, nextState) ->
+ current <- nextState
+ if activity.ProcessNext item then
+ true
+ else
+ moveNext ()
+ | _ -> false
+
+ interface IEnumerator with
+ member __.MoveNext () =
+ result.SeqState <- SeqProcessNextStates.InProcess
+ moveNext ()
+
+ type Enumerable<'T,'U,'GeneratorState>(generator:'GeneratorState->option<'T*'GeneratorState>, state:'GeneratorState, transformFactory:TransformFactory<'T,'U>, pipeIdx:PipeIdx) =
+ inherit Enumerable.EnumerableBase<'U>()
+
+ interface IEnumerable<'U> with
+ member this.GetEnumerator () : IEnumerator<'U> =
+ let result = Result<'U> ()
+ Upcast.enumerator (new Enumerator<'T,'U,'GeneratorState>(generator, state, createFold transformFactory result pipeIdx, result))
+
+ interface ISeq<'U> with
+ member this.PushTransform (next:TransformFactory<'U,'V>) : ISeq<'V> =
+ Upcast.seq (new Enumerable<'T,'V,'GeneratorState>(generator, state, ComposedFactory.Combine transformFactory next, pipeIdx+1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'U,'Result,'State>) =
+ Fold.execute f transformFactory pipeIdx (Fold.unfold (generator, state))
+
+ module Init =
+ // The original implementation of "init" delayed the calculation of Current, and so it was possible
+ // to do MoveNext without it's value being calculated.
+ // I can imagine only two scenerios where that is possibly sane, although a simple solution is readily
+ // at hand in both cases. The first is that of an expensive generator function, where you skip the
+ // first n elements. The simple solution would have just been to have a map ((+) n) as the first operation
+ // instead. The second case would be counting elements, but that is only of use if you're not filtering
+ // or mapping or doing anything else (as that would cause Current to be evaluated!) and
+ // so you already know what the count is!! Anyway, someone thought it was a good idea, so
+ // I have had to add an extra function that is used in Skip to determine if we are touching
+ // Current or not.
+
+ let getTerminatingIdx (count:Nullable) =
+ // we are offset by 1 to allow for values going up to System.Int32.MaxValue
+ // System.Int32.MaxValue is an illegal value for the "infinite" sequence
+ if count.HasValue then
+ count.Value - 1
+ else
+ System.Int32.MaxValue
+
+ type Enumerator<'T,'U>(count:Nullable, f:int->'T, activity:Activity<'T,'U>, result:Result<'U>) =
+ inherit Enumerable.EnumeratorBase<'U>(result, activity)
+
+ let isSkipping =
+ match box activity with
+ | :? ISkipable as skip -> skip.CanSkip
+ | _ -> fun () -> false
+
+ let terminatingIdx =
+ getTerminatingIdx count
+
+ let mutable maybeSkipping = true
+ let mutable idx = -1
+
+ let rec moveNext () =
+ if result.HaltedIdx = 0 && idx < terminatingIdx then
+ idx <- idx + 1
+
+ if maybeSkipping then
+ // Skip can only is only checked at the start of the sequence, so once
+ // triggered, we stay triggered.
+ maybeSkipping <- isSkipping ()
+
+ if maybeSkipping then
+ moveNext ()
+ elif activity.ProcessNext (f idx) then
+ true
+ else
+ moveNext ()
+ elif result.HaltedIdx = 0 && idx = System.Int32.MaxValue then
+ raise <| System.InvalidOperationException (SR.GetString(SR.enumerationPastIntMaxValue))
+ else
+ result.SeqState <- SeqProcessNextStates.Finished
+ let mutable stopTailCall = ()
+ activity.ChainComplete (&stopTailCall, result.HaltedIdx)
+ false
+
+ interface IEnumerator with
+ member __.MoveNext () =
+ result.SeqState <- SeqProcessNextStates.InProcess
+ moveNext ()
+
+ type Enumerable<'T,'U>(count:Nullable, f:int->'T, transformFactory:TransformFactory<'T,'U>, pipeIdx:PipeIdx) =
+ inherit Enumerable.EnumerableBase<'U>()
+
+ interface IEnumerable<'U> with
+ member this.GetEnumerator () : IEnumerator<'U> =
+ let result = Result<'U> ()
+ Upcast.enumerator (new Enumerator<'T,'U>(count, f, createFold transformFactory result pipeIdx, result))
+
+ interface ISeq<'U> with
+ member this.PushTransform (next:TransformFactory<'U,'V>) : ISeq<'V> =
+ Upcast.seq (new Enumerable<'T,'V>(count, f, ComposedFactory.Combine transformFactory next, pipeIdx+1))
+
+ member this.Fold<'Result,'State> (createResult:PipeIdx->Folder<'U,'Result,'State>) =
+ let terminatingIdx = getTerminatingIdx count
+ Fold.execute createResult transformFactory pipeIdx (Fold.init (f, terminatingIdx))
+
+ let upto lastOption f =
+ match lastOption with
+ | Some b when b<0 -> failwith "library implementation error: upto can never be called with a negative value"
+ | _ ->
+ let unstarted = -1 // index value means unstarted (and no valid index)
+ let completed = -2 // index value means completed (and no valid index)
+ let unreachable = -3 // index is unreachable from 0,1,2,3,...
+ let finalIndex = match lastOption with
+ | Some b -> b // here b>=0, a valid end value.
+ | None -> unreachable // run "forever", well as far as Int32.MaxValue since indexing with a bounded type.
+ // The Current value for a valid index is "f i".
+ // Lazy<_> values are used as caches, to store either the result or an exception if thrown.
+ // These "Lazy<_>" caches are created only on the first call to current and forced immediately.
+ // The lazy creation of the cache nodes means enumerations that skip many Current values are not delayed by GC.
+ // For example, the full enumeration of Seq.initInfinite in the tests.
+ // state
+ let index = ref unstarted
+ // a Lazy node to cache the result/exception
+ let current = ref (Unchecked.defaultof<_>)
+ let setIndex i = index := i; current := (Unchecked.defaultof<_>) // cache node unprimed, initialised on demand.
+ let getCurrent() =
+ if !index = unstarted then notStarted()
+ if !index = completed then alreadyFinished()
+ match box !current with
+ | null -> current := Lazy<_>.Create(fun () -> f !index)
+ | _ -> ()
+ // forced or re-forced immediately.
+ (!current).Force()
+ { new IEnumerator<'U> with
+ member x.Current = getCurrent()
+ interface IEnumerator with
+ member x.Current = box (getCurrent())
+ member x.MoveNext() =
+ if !index = completed then
+ false
+ elif !index = unstarted then
+ setIndex 0
+ true
+ else (
+ if !index = System.Int32.MaxValue then raise <| System.InvalidOperationException (SR.GetString(SR.enumerationPastIntMaxValue))
+ if !index = finalIndex then
+ false
+ else
+ setIndex (!index + 1)
+ true
+ )
+ member this.Reset() = noReset()
+ interface System.IDisposable with
+ member x.Dispose () = () }
+
+ type EnumerableDecider<'T>(count:Nullable, f:int->'T, pipeIdx:PipeIdx) =
+ inherit Enumerable.EnumerableBase<'T>()
+
+ interface IEnumerable<'T> with
+ member this.GetEnumerator () : IEnumerator<'T> =
+ // we defer back to the original implementation as, as it's quite idiomatic in it's decision
+ // to calculate Current in a lazy fashion. I doubt anyone is really using this functionality
+ // in the way presented, but it's possible.
+ upto (if count.HasValue then Some (count.Value-1) else None) f
+
+ interface ISeq<'T> with
+ member this.PushTransform (next:TransformFactory<'T,'U>) : ISeq<'U> =
+ Upcast.seq (Enumerable<'T,'V>(count, f, next, pipeIdx+1))
+
+ member this.Fold<'Result,'State> (f:PipeIdx->Folder<'T,'Result,'State>) =
+ Fold.executeThin f (Fold.enumerable (Upcast.enumerable this))
+
+ []
+ let ofResizeArrayUnchecked (source:ResizeArray<'T>) : ISeq<'T> =
+ Upcast.seq (ResizeArray.Enumerable (source, IdentityFactory.Instance, 1))
+
+ []
+ let ofArray (source:array<'T>) : ISeq<'T> =
+ checkNonNull "source" source
+ Upcast.seq (Array.Enumerable (source, IdentityFactory.Instance, 1))
+
+ []
+ let ofList (source:list<'T>) : ISeq<'T> =
+ Upcast.seq (List.Enumerable (source, IdentityFactory.Instance, 1))
+
+ []
+ let ofSeq (source:seq<'T>) : ISeq<'T> =
+ match source with
+ | :? ISeq<'T> as seq -> seq
+ | :? array<'T> as array -> ofArray array
+ | :? list<'T> as list -> ofList list
+ | null -> nullArg "source"
+ | _ -> Upcast.seq (Enumerable.EnumerableThin<'T> source)
+
+ []
+ let inline average (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,'T,int> (LanguagePrimitives.GenericZero, 0) with
+ override this.ProcessNext value =
+ this.Result <- Checked.(+) this.Result value
+ this.State <- this.State + 1
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State = 0 then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ this.Result <- LanguagePrimitives.DivideByInt<'T> this.Result this.State
+ override this.OnDispose () = () })
+
+ []
+ let inline averageBy (f:'T->'U) (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,'U,int>(LanguagePrimitives.GenericZero,0) with
+ override this.ProcessNext value =
+ this.Result <- Checked.(+) this.Result (f value)
+ this.State <- this.State + 1
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State = 0 then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ this.Result <- LanguagePrimitives.DivideByInt<'U> this.Result this.State
+ override this.OnDispose () = () })
+
+ []
+ let empty<'T> = EmptyEnumerable.Enumerable<'T>.Instance
+
+ []
+ let exactlyOne (source:ISeq<'T>) : 'T =
+ source.Fold (fun pipeIdx ->
+ upcast { new FolderWithPostProcessing<'T,'T,Values>(Unchecked.defaultof<'T>, Values(true, false)) with
+ override this.ProcessNext value =
+ if this.State._1 then
+ this.State._1 <- false
+ this.Result <- value
+ else
+ this.State._2 <- true
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State._1 then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ elif this.State._2 then
+ invalidArg "source" (SR.GetString SR.inputSequenceTooLong)
+ override this.OnDispose () = () })
+
+ []
+ let inline fold<'T,'State> (f:'State->'T->'State) (seed:'State) (source:ISeq<'T>) : 'State =
+ source.Fold (fun _ ->
+ upcast { new Folder<'T,'State,NoValue>(seed,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ this.Result <- f this.Result value
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline fold2<'T1,'T2,'State> (folder:'State->'T1->'T2->'State) (state:'State) (source1:ISeq<'T1>) (source2: ISeq<'T2>) =
+ source1.Fold (fun pipeIdx ->
+ upcast { new FolderWithPostProcessing<_,'State,IEnumerator<'T2>>(state,source2.GetEnumerator()) with
+ override this.ProcessNext value =
+ if this.State.MoveNext() then
+ this.Result <- folder this.Result value this.State.Current
+ else
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ = ()
+ override this.OnDispose () = this.State.Dispose () })
+
+ []
+ let unfold (generator:'State->option<'T * 'State>) (state:'State) : ISeq<'T> =
+ Upcast.seq (new Unfold.Enumerable<'T,'T,'State>(generator, state, IdentityFactory.Instance, 1))
+
+ []
+ let initInfinite<'T> (f:int->'T) : ISeq<'T> =
+ Upcast.seq (new Init.EnumerableDecider<'T>(Nullable (), f, 1))
+
+ []
+ let init<'T> (count:int) (f:int->'T) : ISeq<'T> =
+ if count < 0 then invalidArgInputMustBeNonNegative "count" count
+ elif count = 0 then empty else
+ Upcast.seq (new Init.EnumerableDecider<'T>(Nullable count, f, 1))
+
+ []
+ let inline iter f (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new Folder<'T,unit,NoValue> ((),Unchecked.defaultof) with
+ override this.ProcessNext value =
+ f value
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline iter2 (f:'T->'U->unit) (source1:ISeq<'T>) (source2:ISeq<'U>) : unit =
+ source1.Fold (fun pipeIdx ->
+ upcast { new FolderWithPostProcessing<'T,unit,IEnumerator<'U>> ((),source2.GetEnumerator()) with
+ override this.ProcessNext value =
+ if this.State.MoveNext() then
+ f value this.State.Current
+ else
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ = ()
+ override this.OnDispose () = this.State.Dispose () })
+
+ []
+ let inline iteri2 (f:int->'T->'U->unit) (source1:ISeq<'T>) (source2:ISeq<'U>) : unit =
+ source1.Fold (fun pipeIdx ->
+ upcast { new FolderWithPostProcessing<'T,unit,Values>>((),Values<_,_>(-1,source2.GetEnumerator())) with
+ override this.ProcessNext value =
+ if this.State._2.MoveNext() then
+ f this.State._1 value this.State._2.Current
+ this.State._1 <- this.State._1 + 1
+ Unchecked.defaultof<_>
+ else
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_>
+ override this.OnComplete _ = ()
+ override this.OnDispose () = this.State._2.Dispose () })
+
+ []
+ let tryHead (source:ISeq<'T>) =
+ source.Fold (fun pipeIdx ->
+ upcast { new Folder<'T, Option<'T>,NoValue> (None,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ this.Result <- Some value
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let head (source:ISeq<_>) =
+ match tryHead source with
+ | None -> invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ | Some x -> x
+
+ []
+ let inline iteri f (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ { new Folder<'T,unit,int> ((),0) with
+ override this.ProcessNext value =
+ f this.State value
+ this.State <- this.State + 1
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline except (itemsToExclude: seq<'T>) (source:ISeq<'T>) : ISeq<'T> when 'T:equality =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,Lazy>>(next,lazy(HashSet<'T>(itemsToExclude,HashIdentity.Structural<'T>))) with
+ override this.ProcessNext (input:'T) : bool =
+ this.State.Value.Add input && TailCall.avoid (next.ProcessNext input) }}
+
+ []
+ let inline exists f (source:ISeq<'T>) =
+ source.Fold (fun pipeIdx ->
+ upcast { new Folder<'T, bool,NoValue> (false,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ if f value then
+ this.Result <- true
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline exists2 (predicate:'T->'U->bool) (source1:ISeq<'T>) (source2: ISeq<'U>) : bool =
+ source1.Fold (fun pipeIdx ->
+ upcast { new FolderWithPostProcessing<'T,bool,IEnumerator<'U>>(false,source2.GetEnumerator()) with
+ override this.ProcessNext value =
+ if this.State.MoveNext() then
+ if predicate value this.State.Current then
+ this.Result <- true
+ this.StopFurtherProcessing pipeIdx
+ else
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ = ()
+ override this.OnDispose () = this.State.Dispose () })
+
+ []
+ let inline contains element (source:ISeq<'T>) =
+ source.Fold (fun pipeIdx ->
+ upcast { new Folder<'T, bool,NoValue> (false,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ if element = value then
+ this.Result <- true
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline forall predicate (source:ISeq<'T>) =
+ source.Fold (fun pipeIdx ->
+ upcast { new Folder<'T, bool,NoValue> (true,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ if not (predicate value) then
+ this.Result <- false
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline forall2 predicate (source1:ISeq<'T>) (source2:ISeq<'U>) : bool =
+ source1.Fold (fun pipeIdx ->
+ upcast { new FolderWithPostProcessing<'T,bool,IEnumerator<'U>>(true,source2.GetEnumerator()) with
+ override this.ProcessNext value =
+ if this.State.MoveNext() then
+ if not (predicate value this.State.Current) then
+ this.Result <- false
+ this.StopFurtherProcessing pipeIdx
+ else
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ = ()
+ override this.OnDispose () = this.State.Dispose () })
+
+ []
+ let inline filter<'T> (f:'T->bool) (source:ISeq<'T>) : ISeq<'T> =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,NoValue>(next,Unchecked.defaultof) with
+ override __.ProcessNext input =
+ if f input then TailCall.avoid (next.ProcessNext input)
+ else false } }
+
+ []
+ let inline map<'T,'U> (f:'T->'U) (source:ISeq<'T>) : ISeq<'U> =
+ source.PushTransform { new TransformFactory<'T,'U>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,NoValue>(next,Unchecked.defaultof) with
+ override __.ProcessNext input =
+ TailCall.avoid (next.ProcessNext (f input)) } }
+
+ []
+ let inline mapi f (source:ISeq<_>) =
+ source.PushTransform { new TransformFactory<'T,'U>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,int>(next, -1) with
+ override this.ProcessNext (input:'T) : bool =
+ this.State <- this.State + 1
+ TailCall.avoid (next.ProcessNext (f this.State input)) } }
+
+ []
+ let inline map2<'T,'U,'V> (map:'T->'U->'V) (source1:ISeq<'T>) (source2:ISeq<'U>) : ISeq<'V> =
+ source1.PushTransform { new TransformFactory<'T,'V>() with
+ override __.Compose outOfBand pipeIdx (next:Activity<'V,'W>) =
+ upcast { new TransformWithPostProcessing<'T,'W, IEnumerator<'U>>(next, (source2.GetEnumerator ())) with
+ override this.ProcessNext input =
+ if this.State.MoveNext () then
+ TailCall.avoid (next.ProcessNext (map input this.State.Current))
+ else
+ outOfBand.StopFurtherProcessing pipeIdx
+ false
+ override this.OnComplete _ = ()
+ override this.OnDispose () = this.State.Dispose () }}
+
+ []
+ let inline mapi2<'T,'U,'V> (map:int->'T->'U->'V) (source1:ISeq<'T>) (source2:ISeq<'U>) : ISeq<'V> =
+ source1.PushTransform { new TransformFactory<'T,'V>() with
+ override __.Compose<'W> outOfBand pipeIdx next =
+ upcast { new TransformWithPostProcessing<'T,'W, Values>>(next, Values<_,_>(-1,source2.GetEnumerator ())) with
+ override this.ProcessNext t =
+ let idx : byref<_> = &this.State._1
+ let u = this.State._2
+ if u.MoveNext () then
+ idx <- idx + 1
+ TailCall.avoid (next.ProcessNext (map idx t u.Current))
+ else
+ outOfBand.StopFurtherProcessing pipeIdx
+ false
+ override this.OnDispose () = this.State._2.Dispose ()
+ override this.OnComplete _ = () }}
+
+ []
+ let inline map3<'T,'U,'V,'W>(map:'T->'U->'V->'W) (source1:ISeq<'T>) (source2:ISeq<'U>) (source3:ISeq<'V>) : ISeq<'W> =
+ source1.PushTransform { new TransformFactory<'T,'W>() with
+ override __.Compose<'X> outOfBand pipeIdx next =
+ upcast { new TransformWithPostProcessing<'T,'X,Values,IEnumerator<'V>>>(next,Values<_,_>(source2.GetEnumerator(),source3.GetEnumerator())) with
+ override this.ProcessNext t =
+ let u = this.State._1
+ let v = this.State._2
+ if u.MoveNext() && v.MoveNext () then
+ TailCall.avoid (next.ProcessNext (map t u.Current v.Current))
+ else
+ outOfBand.StopFurtherProcessing pipeIdx
+ false
+ override this.OnComplete _ = ()
+ override this.OnDispose () =
+ this.State._1.Dispose ()
+ this.State._2.Dispose () }}
+
+ []
+ let inline compareWith (f:'T->'T->int) (source1:ISeq<'T>) (source2:ISeq<'T>) : int =
+ source1.Fold (fun pipeIdx ->
+ upcast { new FolderWithPostProcessing<'T,int,IEnumerator<'T>>(0,source2.GetEnumerator()) with
+ override this.ProcessNext value =
+ if not (this.State.MoveNext()) then
+ this.Result <- 1
+ this.StopFurtherProcessing pipeIdx
+ else
+ let c = f value this.State.Current
+ if c <> 0 then
+ this.Result <- c
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+ override this.OnComplete _ =
+ if this.Result = 0 && this.State.MoveNext() then
+ this.Result <- -1
+ override this.OnDispose () = this.State.Dispose () })
+
+ []
+ let inline choose (f:'T->option<'U>) (source:ISeq<'T>) : ISeq<'U> =
+ source.PushTransform { new TransformFactory<'T,'U>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,NoValue>(next,Unchecked.defaultof) with
+ override __.ProcessNext input =
+ match f input with
+ | Some value -> TailCall.avoid (next.ProcessNext value)
+ | None -> false } }
+
+ []
+ let inline distinct (source:ISeq<'T>) : ISeq<'T> when 'T:equality =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,HashSet<'T>>(next,HashSet HashIdentity.Structural) with
+ override this.ProcessNext (input:'T) : bool =
+ this.State.Add input && TailCall.avoid (next.ProcessNext input) }}
+
+ []
+ let inline distinctBy (keyf:'T->'Key) (source:ISeq<'T>) :ISeq<'T> when 'Key:equality =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,HashSet<'Key>> (next,HashSet HashIdentity.Structural) with
+ override this.ProcessNext (input:'T) : bool =
+ this.State.Add (keyf input) && TailCall.avoid (next.ProcessNext input) }}
+
+ []
+ let inline max (source:ISeq<'T>) : 'T when 'T:comparison =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,'T,bool>(Unchecked.defaultof<'T>,true) with
+ override this.ProcessNext value =
+ if this.State then
+ this.State <- false
+ this.Result <- value
+ elif value > this.Result then
+ this.Result <- value
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ override this.OnDispose () = () })
+
+ []
+ let inline maxBy (f:'T->'U) (source:ISeq<'T>) : 'T when 'U:comparison =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,'T,Values>(Unchecked.defaultof<'T>,Values<_,_>(true,Unchecked.defaultof<'U>)) with
+ override this.ProcessNext value =
+ match this.State._1, f value with
+ | true, valueU ->
+ this.State._1 <- false
+ this.State._2 <- valueU
+ this.Result <- value
+ | false, valueU when valueU > this.State._2 ->
+ this.State._2 <- valueU
+ this.Result <- value
+ | _ -> ()
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State._1 then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ override this.OnDispose () = () })
+
+ []
+ let inline min (source:ISeq<'T>) : 'T when 'T:comparison =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,'T,bool>(Unchecked.defaultof<'T>,true) with
+ override this.ProcessNext value =
+ if this.State then
+ this.State <- false
+ this.Result <- value
+ elif value < this.Result then
+ this.Result <- value
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ override this.OnDispose () = () })
+
+ []
+ let inline minBy (f:'T->'U) (source:ISeq<'T>) : 'T =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,'T,Values>(Unchecked.defaultof<'T>,Values<_,_>(true,Unchecked.defaultof< 'U>)) with
+ override this.ProcessNext value =
+ match this.State._1, f value with
+ | true, valueU ->
+ this.State._1 <- false
+ this.State._2 <- valueU
+ this.Result <- value
+ | false, valueU when valueU < this.State._2 ->
+ this.State._2 <- valueU
+ this.Result <- value
+ | _ -> ()
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State._1 then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ override this.OnDispose () = () })
+
+ []
+ let pairwise (source:ISeq<'T>) : ISeq<'T*'T> =
+ source.PushTransform { new TransformFactory<'T,'T * 'T>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'U,Values>(next, Values(true, Unchecked.defaultof<'T>)) with
+ // member this.isFirst = this.State._1
+ // member this.lastValue = this.State._2
+ override this.ProcessNext (input:'T) : bool =
+ if this.State._1 then
+ this.State._2 <- input
+ this.State._1 <- false
+ false
+ else
+ let currentPair = this.State._2, input
+ this.State._2 <- input
+ TailCall.avoid (next.ProcessNext currentPair) }}
+
+ []
+ let inline reduce (f:'T->'T->'T) (source: ISeq<'T>) : 'T =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,'T,bool>(Unchecked.defaultof<'T>,true) with
+ override this.ProcessNext value =
+ if this.State then
+ this.State <- false
+ this.Result <- value
+ else
+ this.Result <- f this.Result value
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ if this.State then
+ invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ override this.OnDispose () = () })
+
+ []
+ let inline scan (folder:'State->'T->'State) (initialState:'State) (source:ISeq<'T>) :ISeq<'State> =
+ source.PushTransform { new TransformFactory<'T,'State>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,'State>(next, initialState) with
+ override this.ProcessNext (input:'T) : bool =
+ this.State <- folder this.State input
+ TailCall.avoid (next.ProcessNext this.State) } }
+
+ []
+ let skip (skipCount:int) (source:ISeq<'T>) : ISeq<'T> =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ override __.Compose _ _ next =
+ let mutable this = Unchecked.defaultof>
+ let skipper =
+ { new TransformWithPostProcessing<'T,'U,int>(next,(*count*)0) with
+ // member this.count = this.State
+ override this.ProcessNext (input:'T) : bool =
+ if this.State < skipCount then
+ this.State <- this.State + 1
+ false
+ else
+ TailCall.avoid (next.ProcessNext input)
+
+ override this.OnComplete _ =
+ if this.State < skipCount then
+ let x = skipCount - this.State
+ invalidOpFmt "{0}\ntried to skip {1} {2} past the end of the seq"
+ [|SR.GetString SR.notEnoughElements; x; (if x=1 then "element" else "elements")|]
+ override this.OnDispose () = ()
+
+ interface ISkipable with
+ member __.CanSkip () =
+ if this.State < skipCount then
+ this.State <- this.State + 1
+ true
+ else
+ false }
+ this <- skipper
+ upcast this }
+
+ []
+ let inline skipWhile (predicate:'T->bool) (source:ISeq<'T>) : ISeq<'T> =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ override __.Compose _ _ next =
+ upcast { new Transform<'T,'V,bool>(next,true) with
+ // member this.skip = this.State
+ override this.ProcessNext (input:'T) : bool =
+ if this.State then
+ this.State <- predicate input
+ if this.State then
+ false
+ else
+ TailCall.avoid (next.ProcessNext input)
+ else
+ TailCall.avoid (next.ProcessNext input) }}
+
+ []
+ let inline sum (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new Folder<'T,'T,NoValue> (LanguagePrimitives.GenericZero,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ this.Result <- Checked.(+) this.Result value
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline sumBy (f:'T->'U) (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new Folder<'T,'U,NoValue> (LanguagePrimitives.GenericZero<'U>,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ this.Result <- Checked.(+) this.Result (f value)
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let take (takeCount:int) (source:ISeq<'T>) : ISeq<'T> =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ member __.Compose outOfBand pipelineIdx next =
+ upcast { new TransformWithPostProcessing<'T,'U,int>(next,(*count*)0) with
+ // member this.count = this.State
+ override this.ProcessNext (input:'T) : bool =
+ if this.State < takeCount then
+ this.State <- this.State + 1
+ if this.State = takeCount then
+ outOfBand.StopFurtherProcessing pipelineIdx
+ TailCall.avoid (next.ProcessNext input)
+ else
+ outOfBand.StopFurtherProcessing pipelineIdx
+ false
+
+ override this.OnComplete terminatingIdx =
+ if terminatingIdx < pipelineIdx && this.State < takeCount then
+ let x = takeCount - this.State
+ invalidOpFmt "tried to take {0} {1} past the end of the seq"
+ [|SR.GetString SR.notEnoughElements; x; (if x=1 then "element" else "elements")|]
+ override this.OnDispose () = () }}
+
+ []
+ let inline takeWhile (predicate:'T->bool) (source:ISeq<'T>) : ISeq<'T> =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ member __.Compose outOfBand pipeIdx next =
+ upcast { new Transform<'T,'V,NoValue>(next,Unchecked.defaultof) with
+ override __.ProcessNext (input:'T) : bool =
+ if predicate input then
+ TailCall.avoid (next.ProcessNext input)
+ else
+ outOfBand.StopFurtherProcessing pipeIdx
+ false }}
+
+ []
+ let tail (source:ISeq<'T>) : ISeq<'T> =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ member __.Compose _ _ next =
+ upcast { new TransformWithPostProcessing<'T,'V,bool>(next,true) with
+ // member this.isFirst = this.State
+ override this.ProcessNext (input:'T) : bool =
+ if this.State then
+ this.State <- false
+ false
+ else
+ TailCall.avoid (next.ProcessNext input)
+ override this.OnComplete _ =
+ if this.State then
+ invalidArg "source" (SR.GetString SR.notEnoughElements)
+ override this.OnDispose () = () }}
+
+ []
+ let truncate (truncateCount:int) (source:ISeq<'T>) : ISeq<'T> =
+ source.PushTransform { new TransformFactory<'T,'T>() with
+ member __.Compose outOfBand pipeIdx next =
+ upcast { new Transform<'T,'U,int>(next,(*count*)0) with
+ // member this.count = this.State
+ override this.ProcessNext (input:'T) : bool =
+ if this.State < truncateCount then
+ this.State <- this.State + 1
+ if this.State = truncateCount then
+ outOfBand.StopFurtherProcessing pipeIdx
+ TailCall.avoid (next.ProcessNext input)
+ else
+ outOfBand.StopFurtherProcessing pipeIdx
+ false }}
+
+ []
+ let indexed source =
+ mapi (fun i x -> i,x) source
+
+ []
+ let tryItem index (source:ISeq<'T>) =
+ if index < 0 then None else
+ source |> skip index |> tryHead
+
+ []
+ let inline tryPick f (source:ISeq<'T>) =
+ source.Fold (fun pipeIdx ->
+ upcast { new Folder<'T, Option<'U>,NoValue> (None,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ match f value with
+ | (Some _) as some ->
+ this.Result <- some
+ this.StopFurtherProcessing pipeIdx
+ | None -> ()
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline tryFind f (source:ISeq<'T>) =
+ source.Fold (fun pipeIdx ->
+ upcast { new Folder<'T, Option<'T>,NoValue> (None,Unchecked.defaultof) with
+ override this.ProcessNext value =
+ if f value then
+ this.Result <- Some value
+ this.StopFurtherProcessing pipeIdx
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let inline tryFindIndex (predicate:'T->bool) (source:ISeq<'T>) : int option =
+ source.Fold (fun pipeIdx ->
+ { new Folder<'T, Option, int>(None, 0) with
+ // member this.index = this.State
+ override this.ProcessNext value =
+ if predicate value then
+ this.Result <- Some this.State
+ this.StopFurtherProcessing pipeIdx
+ else
+ this.State <- this.State + 1
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let tryLast (source:ISeq<'T>) : 'T option =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,option<'T>,Values>(None,Values(true, Unchecked.defaultof<'T>)) with
+ // member this.noItems = this.State._1
+ // memebr this.last = this.State._2
+ override this.ProcessNext value =
+ if this.State._1 then
+ this.State._1 <- false
+ this.State._2 <- value
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+ override this.OnComplete _ =
+ if not this.State._1 then
+ this.Result <- Some this.State._2
+ override this.OnDispose () = () })
+
+ []
+ let last (source:ISeq<_>) =
+ match tryLast source with
+ | None -> invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ | Some x -> x
+
+ []
+ let windowed (windowSize:int) (source:ISeq<'T>) : ISeq<'T[]> =
+ if windowSize <= 0 then
+ invalidArgFmt "windowSize" "{0}\nwindowSize = {1}" [|SR.GetString SR.inputMustBePositive; windowSize|]
+
+ source.PushTransform { new TransformFactory<'T,'T[]>() with
+ member __.Compose outOfBand pipeIdx next =
+ upcast {
+ new Transform<'T,'U,Values<'T[],int,int>>(next,Values<'T[],int,int>(Array.zeroCreateUnchecked windowSize, 0, windowSize-1)) with
+ override this.ProcessNext (input:'T) : bool =
+ let circularBuffer = this.State._1
+ let idx : byref<_> = &this.State._2
+ let priming : byref<_> = &this.State._3
+
+ circularBuffer.[idx] <- input
+
+ idx <- idx + 1
+ if idx = windowSize then
+ idx <- 0
+
+ if priming > 0 then
+ priming <- priming - 1
+ false
+ elif windowSize < 32 then
+ let idx = idx
+ let window :'T [] = Array.init windowSize (fun i -> circularBuffer.[(idx+i) % windowSize]: 'T)
+ TailCall.avoid (next.ProcessNext window)
+ else
+ let window = Array.zeroCreateUnchecked windowSize
+ Array.Copy (circularBuffer, idx, window, 0, windowSize - idx)
+ Array.Copy (circularBuffer, 0, window, windowSize - idx, idx)
+ TailCall.avoid (next.ProcessNext window) }}
+
+ []
+ let concat (sources:ISeq<#ISeq<'T>>) : ISeq<'T> =
+ Upcast.seq (Enumerable.ConcatEnumerable sources)
+
+ []
+ let append (source1:ISeq<'T>) (source2: ISeq<'T>) : ISeq<'T> =
+ match source1 with
+ | :? Enumerable.EnumerableBase<'T> as s -> s.Append source2
+ | _ -> Upcast.seq (new Enumerable.AppendEnumerable<_>([source2; source1]))
+
+ []
+ let delay (delayed:unit->ISeq<'T>) =
+ Upcast.seq (Enumerable.SeqDelayed (delayed, 1))
+
+ module internal GroupBy =
+ let inline private impl (comparer:IEqualityComparer<'SafeKey>) (keyf:'T->'SafeKey) (getKey:'SafeKey->'Key) (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,ISeq<'Key*ISeq<'T>>,_>(Unchecked.defaultof<_>,Dictionary comparer) with
+ override this.ProcessNext v =
+ let safeKey = keyf v
+ match this.State.TryGetValue safeKey with
+ | false, _ ->
+ let prev = ResizeArray ()
+ this.State.[safeKey] <- prev
+ prev.Add v
+ | true, prev -> prev.Add v
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ let maxWastage = 4
+ for value in this.State.Values do
+ if value.Capacity - value.Count > maxWastage then value.TrimExcess ()
+
+ this.Result <-
+ this.State
+ |> ofSeq
+ |> map (fun kv -> getKey kv.Key, ofResizeArrayUnchecked kv.Value)
+
+ override this.OnDispose () = () })
+
+ let inline byVal (keyf:'T->'Key) (source:ISeq<'T>) =
+ delay (fun () -> impl HashIdentity.Structural<'Key> keyf id source)
+
+ let inline byRef (keyf:'T->'Key) (source:ISeq<'T>) =
+ delay (fun () -> impl (valueComparer<'Key> ()) (keyf >> Value) (fun v -> v._1) source)
+
+ []
+ let inline groupByVal<'T,'Key when 'Key : equality and 'Key : struct> (keyf:'T->'Key) (source:ISeq<'T>) =
+ GroupBy.byVal keyf source
+
+ []
+ let inline groupByRef<'T,'Key when 'Key : equality and 'Key : not struct> (keyf:'T->'Key) (source:ISeq<'T>) =
+ GroupBy.byRef keyf source
+
+ module CountBy =
+ let inline private impl (comparer:IEqualityComparer<'SafeKey>) (keyf:'T->'SafeKey) (getKey:'SafeKey->'Key) (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,ISeq<'Key*int>,_>(Unchecked.defaultof<_>,Dictionary comparer) with
+ override this.ProcessNext v =
+ let safeKey = keyf v
+ this.State.[safeKey] <-
+ match this.State.TryGetValue safeKey with
+ | true, prev -> prev + 1
+ | false, _ -> 1
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+
+ override this.OnComplete _ =
+ this.Result <-
+ this.State
+ |> ofSeq
+ |> map (fun group -> getKey group.Key, group.Value)
+
+ override this.OnDispose () = () })
+
+ let inline byVal (keyf:'T->'Key) (source:ISeq<'T>) =
+ delay (fun () -> impl HashIdentity.Structural<'Key> keyf id source)
+
+ let inline byRef (keyf:'T->'Key) (source:ISeq<'T>) =
+ delay (fun () -> impl (valueComparer<'Key> ()) (keyf >> Value) (fun v -> v._1) source)
+
+ []
+ let inline countByVal<'T,'Key when 'Key : equality and 'Key : struct> (projection:'T -> 'Key) (source:ISeq<'T>) =
+ CountBy.byVal projection source
+
+ []
+ let inline countByRef<'T,'Key when 'Key : equality and 'Key : not struct> (projection:'T -> 'Key) (source:ISeq<'T>) =
+ CountBy.byRef projection source
+
+ []
+ let length (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new Folder<'T,int,NoValue>(0,Unchecked.defaultof<_>) with
+ override this.ProcessNext v =
+ this.Result <- this.Result + 1
+ Unchecked.defaultof<_> (* return value unused in Fold context *) })
+
+ []
+ let toArray (source:ISeq<'T>) =
+ source.Fold (fun _ ->
+ upcast { new FolderWithPostProcessing<'T,array<'T>,_>(Unchecked.defaultof<_>,ResizeArray ()) with
+ override this.ProcessNext v =
+ this.State.Add v
+ Unchecked.defaultof<_> (* return value unused in Fold context *)
+ override this.OnComplete _ =
+ this.Result <- this.State.ToArray ()
+ override this.OnDispose () = () })
+
+ []
+ let sortBy keyf source =
+ delay (fun () ->
+ let array = source |> toArray
+ Array.stableSortInPlaceBy keyf array
+ ofArray array)
+
+ []
+ let sort source =
+ delay (fun () ->
+ let array = source |> toArray
+ Array.stableSortInPlace array
+ ofArray array)
+
+ []
+ let sortWith f source =
+ delay (fun () ->
+ let array = source |> toArray
+ Array.stableSortInPlaceWith f array
+ ofArray array)
+
+ []
+ let rev source =
+ delay (fun () ->
+ let array = source |> toArray
+ Array.Reverse array
+ ofArray array)
+
+ []
+ let permute f (source:ISeq<_>) =
+ delay (fun () ->
+ source
+ |> toArray
+ |> Array.permute f
+ |> ofArray)
+
+ []
+ let scanBack<'T,'State> f (source:ISeq<'T>) (acc:'State) : ISeq<'State> =
+ delay (fun () ->
+ let array = source |> toArray
+ Array.scanSubRight f array 0 (array.Length - 1) acc
+ |> ofArray)
+
+ let inline foldArraySubRight f (arr: 'T[]) start fin acc =
+ let mutable state = acc
+ for i = fin downto start do
+ state <- f arr.[i] state
+ state
+
+ []
+ let inline foldBack<'T,'State> f (source: ISeq<'T>) (x:'State) =
+ let arr = toArray source
+ let len = arr.Length
+ foldArraySubRight f arr 0 (len - 1) x
+
+ []
+ let zip source1 source2 =
+ map2 (fun x y -> x,y) source1 source2
+
+ []
+ let inline foldBack2<'T1,'T2,'State> f (source1:ISeq<'T1>) (source2:ISeq<'T2>) (x:'State) =
+ let zipped = zip source1 source2
+ foldBack ((<||) f) zipped x
+
+ []
+ let inline reduceBack f (source:ISeq<'T>) =
+ let arr = toArray source
+ match arr.Length with
+ | 0 -> invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString
+ | len -> foldArraySubRight f arr 0 (len - 2) arr.[len - 1]
diff --git a/src/fsharp/FSharp.Core/iseq.fsi b/src/fsharp/FSharp.Core/iseq.fsi
new file mode 100644
index 00000000000..8f030782f15
--- /dev/null
+++ b/src/fsharp/FSharp.Core/iseq.fsi
@@ -0,0 +1,362 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace Microsoft.FSharp.Collections
+
+ open System
+ open System.Collections
+ open System.Collections.Generic
+ open Microsoft.FSharp.Core
+ open Microsoft.FSharp.Collections
+
+ []
+ module ISeq =
+ module Core =
+ []
+ type NoValue = struct end
+
+ /// Values is a mutable struct. It can be embedded within the folder type
+ /// if two values are required for the calculation.
+ []
+ type Value<'a> =
+ new : a:'a -> Value<'a>
+ val mutable _1: 'a
+
+ /// Values is a mutable struct. It can be embedded within the folder type
+ /// if two values are required for the calculation.
+ []
+ type Values<'a,'b> =
+ new : a:'a * b:'b -> Values<'a,'b>
+ val mutable _1: 'a
+ val mutable _2: 'b
+
+ /// Values is a mutable struct. It can be embedded within the folder type
+ /// if three values are required for the calculation.
+ []
+ type Values<'a,'b,'c> =
+ new : a:'a * b:'b * c:'c -> Values<'a,'b,'c>
+ val mutable _1: 'a
+ val mutable _2: 'b
+ val mutable _3: 'c
+
+ /// PipeIdx denotes the index of the element within the pipeline. 0 denotes the
+ /// source of the chain.
+ type PipeIdx = int
+
+ type IOutOfBand =
+ abstract StopFurtherProcessing : PipeIdx -> unit
+
+ /// Activity is the root class for chains of activities. It is in a non-generic
+ /// form so that it can be used by subsequent activities
+ []
+ type Activity =
+ /// OnComplete is used to determine if the object has been processed correctly,
+ /// and possibly throw exceptions to denote incorrect application (i.e. such as a Take
+ /// operation which didn't have a source at least as large as was required). It is
+ /// not called in the case of an exception being thrown whilst the stream is still
+ /// being processed.
+ abstract ChainComplete : stopTailCall:byref*PipeIdx -> unit
+ /// OnDispose is used to cleanup the stream. It is always called at the last operation
+ /// after the enumeration has completed.
+ abstract ChainDispose : stopTailCall:byref -> unit
+
+ /// Activity is the base class of all elements within the pipeline
+ []
+ type Activity<'T,'U> =
+ inherit Activity
+ new : unit -> Activity<'T,'U>
+ abstract member ProcessNext : input:'T -> bool
+
+ []
+ type Transform<'T,'U,'State> =
+ inherit Activity<'T,'U>
+ new : next:Activity * 'State -> Transform<'T,'U,'State>
+ val mutable State : 'State
+ val private Next : Activity
+
+ []
+ type TransformWithPostProcessing<'T,'U,'State> =
+ inherit Transform<'T,'U,'State>
+ new : next:Activity * 'State -> TransformWithPostProcessing<'T,'U,'State>
+ abstract OnComplete : PipeIdx -> unit
+ abstract OnDispose : unit -> unit
+
+ /// Folder is a base class to assist with fold-like operations. It's intended usage
+ /// is as a base class for an object expression that will be used from within
+ /// the Fold function.
+ []
+ type Folder<'T,'Result,'State> =
+ inherit Activity<'T,'T>
+ new : 'Result*'State -> Folder<'T,'Result,'State>
+ interface IOutOfBand
+ val mutable State : 'State
+ val mutable Result : 'Result
+ val mutable HaltedIdx : int
+ member StopFurtherProcessing : PipeIdx -> unit
+
+ []
+ type FolderWithPostProcessing<'T,'Result,'State> =
+ inherit Folder<'T,'Result,'State>
+ new : 'Result*'State -> FolderWithPostProcessing<'T,'Result,'State>
+ abstract OnDispose : unit -> unit
+ abstract OnComplete : PipeIdx -> unit
+
+ []
+ type TransformFactory<'T,'U> =
+ new : unit -> TransformFactory<'T,'U>
+ abstract member Compose : IOutOfBand -> PipeIdx -> Activity<'U,'V> -> Activity<'T,'V>
+
+ type ISeq<'T> =
+ inherit System.Collections.Generic.IEnumerable<'T>
+ abstract member PushTransform : TransformFactory<'T,'U> -> ISeq<'U>
+ abstract member Fold<'Result,'State> : f:(PipeIdx->Folder<'T,'Result,'State>) -> 'Result
+
+ open Core
+
+ []
+ val ofResizeArrayUnchecked : ResizeArray<'T> -> ISeq<'T>
+
+ []
+ val ofList : list<'T> -> ISeq<'T>
+
+ []
+ val ofArray : array<'T> -> ISeq<'T>
+
+ []
+ val ofSeq : seq<'T> -> ISeq<'T>
+
+ []
+ val inline average : source: ISeq< ^T> -> ^T
+ when 'T:(static member Zero : ^T)
+ and 'T:(static member (+) : ^T * ^T -> ^T)
+ and ^T:(static member DivideByInt : ^T * int -> ^T)
+
+ []
+ val inline averageBy : f:('T -> ^U) -> source:ISeq< 'T > -> ^U
+ when ^U:(static member Zero : ^U)
+ and ^U:(static member (+) : ^U * ^U -> ^U)
+ and ^U:(static member DivideByInt : ^U * int -> ^U)
+
+ []
+ val empty<'T> : ISeq<'T>
+
+ []
+ val exactlyOne : ISeq<'T> -> 'T
+
+ []
+ val inline fold<'T,'State> : f:('State->'T->'State) -> seed:'State -> source:ISeq<'T> -> 'State
+
+ []
+ val inline fold2<'T1,'T2,'State> : folder:('State->'T1->'T2->'State) -> state:'State -> source1: ISeq<'T1> -> source2: ISeq<'T2> -> 'State
+
+ []
+ val unfold : generator:('State -> option<'T*'State>) -> state:'State -> ISeq<'T>
+
+ []
+ val initInfinite : f:(int -> 'T) -> ISeq<'T>
+
+ []
+ val init : count:int -> f:(int -> 'T) -> ISeq<'T>
+
+ []
+ val inline iter : f:('T -> unit) -> source:ISeq<'T> -> unit
+
+ []
+ val inline iter2 : f:('T->'U->unit) -> source1 : ISeq<'T> -> source2 : ISeq<'U> -> unit
+
+ []
+ val inline iteri2 : f:(int->'T->'U->unit) -> source1:ISeq<'T> -> source2:ISeq<'U> -> unit
+
+ []
+ val tryHead : ISeq<'T> -> option<'T>
+
+ []
+ val head: source:ISeq<'T> -> 'T
+
+ []
+ val inline iteri : f:(int -> 'T -> unit) -> source:ISeq<'T> -> unit
+
+ []
+ val inline except : itemsToExclude:seq<'T> -> source:ISeq<'T> -> ISeq<'T> when 'T:equality
+
+ []
+ val inline exists : f:('T -> bool) -> source:ISeq<'T> -> bool
+
+ []
+ val inline exists2 : predicate:('T->'U->bool) -> source1:ISeq<'T> -> source2:ISeq<'U> -> bool
+
+ []
+ val inline contains : element:'T -> source:ISeq<'T> -> bool when 'T : equality
+
+ []
+ val inline forall : f:('T -> bool) -> source:ISeq<'T> -> bool
+
+ []
+ val inline forall2 : predicate:('T->'U->bool) -> source1:ISeq<'T> -> source2:ISeq<'U> -> bool
+
+ []
+ val inline filter : f:('T -> bool) -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val inline map : f:('T -> 'U) -> source:ISeq<'T> -> ISeq<'U>
+
+ []
+ val inline mapi : f:(int->'a->'b) -> source: ISeq<'a> -> ISeq<'b>
+
+ []
+ val inline map2<'T,'U,'V> : map:('T->'U->'V) -> source1:ISeq<'T> -> source2:ISeq<'U> -> ISeq<'V>
+
+ []
+ val inline mapi2<'T,'U,'V> : map:(int -> 'T->'U->'V) -> source1:ISeq<'T> -> source2:ISeq<'U> -> ISeq<'V>
+
+ []
+ val inline map3<'T,'U,'V,'W> : map:('T->'U->'V->'W) -> source1:ISeq<'T> -> source2:ISeq<'U> -> source3:ISeq<'V> -> ISeq<'W>
+
+ []
+ val inline compareWith : f:('T->'T->int) -> source1 :ISeq<'T> -> source2:ISeq<'T> -> int
+
+ []
+ val inline choose : f:('a->option<'b>) -> source: ISeq<'a> -> ISeq<'b>
+
+ []
+ val inline distinct : source:ISeq<'T> -> ISeq<'T> when 'T:equality
+
+ []
+ val inline distinctBy : keyf:('T->'Key) -> source:ISeq<'T> -> ISeq<'T> when 'Key:equality
+
+ []
+ val inline max : source:ISeq<'T> -> 'T when 'T:comparison
+
+ []
+ val inline maxBy : f:('T->'U) -> source:ISeq<'T> -> 'T when 'U:comparison
+
+ []
+ val inline min : source:ISeq<'T> -> 'T when 'T:comparison
+
+ []
+ val inline minBy : f:('T->'U) -> source:ISeq<'T> -> 'T when 'U:comparison
+
+ []
+ val pairwise : source:ISeq<'T> -> ISeq<'T * 'T>
+
+ []
+ val inline reduce : f:('T->'T->'T) -> source:ISeq<'T> -> 'T
+
+ []
+ val inline scan : folder:('State->'T->'State) -> initialState:'State -> source:ISeq<'T> -> ISeq<'State>
+
+ []
+ val skip : skipCount:int -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val inline skipWhile : predicate:('T->bool) -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val inline sum : source:ISeq<'T> -> 'T
+ when 'T:(static member Zero : ^T)
+ and 'T:(static member (+) : ^T * ^T -> ^T)
+
+ []
+ val inline sumBy : f :('T -> ^U) -> source:ISeq<'T> -> ^U
+ when ^U:(static member Zero : ^U)
+ and ^U:(static member (+) : ^U * ^U -> ^U)
+
+ []
+ val take : takeCount:int -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val inline takeWhile : predicate:('T->bool) -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val tail : source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val truncate : truncateCount:int -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val indexed : source: ISeq<'a> -> ISeq
+
+ []
+ val tryItem : index:int -> source:ISeq<'T> -> option<'T>
+
+ []
+ val inline tryPick : f:('T -> option<'U>) -> source:ISeq<'T> -> option<'U>
+
+ []
+ val inline tryFind : f:('T -> bool) -> source:ISeq<'T> -> option<'T>
+
+ []
+ val inline tryFindIndex: predicate:('T->bool) -> source:ISeq<'T> -> option
+
+ []
+ val last: source:ISeq<'T> -> 'T
+
+ []
+ val tryLast : source:ISeq<'T> -> option<'T>
+
+ []
+ val windowed : windowSize:int -> source:ISeq<'T> -> ISeq>
+
+ []
+ val concat : sources:ISeq<'Collection> -> ISeq<'T> when 'Collection :> ISeq<'T>
+
+ []
+ val append: source1:ISeq<'T> -> source2:ISeq<'T> -> ISeq<'T>
+
+ []
+ val delay : (unit -> ISeq<'T>) -> ISeq<'T>
+
+ []
+ val inline groupByVal : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * ISeq<'T>> when 'Key : equality and 'Key : struct
+
+ []
+ val inline groupByRef : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * ISeq<'T>> when 'Key : equality and 'Key : not struct
+
+ []
+ val inline countByVal : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * int> when 'Key : equality and 'Key : struct
+
+ []
+ val inline countByRef : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * int> when 'Key : equality and 'Key : not struct
+
+ []
+ val length: source:ISeq<'T> -> int
+
+ []
+ val toArray: source:ISeq<'T> -> array<'T>
+
+ []
+ val sortBy : projection:('T->'Key) -> source:ISeq<'T> -> ISeq<'T> when 'Key : comparison
+
+ []
+ val sort : source:ISeq<'T> -> ISeq<'T> when 'T : comparison
+
+ []
+ val sortWith : comparer:('T->'T->int) -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val rev: source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val permute: indexMap:(int->int) -> source:ISeq<'T> -> ISeq<'T>
+
+ []
+ val scanBack<'T,'State> : folder:('T->'State->'State) -> source:ISeq<'T> -> state:'State -> ISeq<'State>
+
+ []
+ val zip: source1:ISeq<'T1> -> source2:ISeq<'T2> -> ISeq<'T1 * 'T2>
+
+ []
+ val inline reduceBack: reduction:('T->'T->'T) -> source:ISeq<'T> -> 'T
+
+ []
+ val inline foldBack<'T,'State> : folder:('T->'State->'State) -> source:ISeq<'T> -> state:'State -> 'State
+
+ []
+ val inline foldBack2<'T1,'T2,'State> : folder:('T1->'T2->'State->'State) -> source1:ISeq<'T1> -> source2:ISeq<'T2> -> state:'State -> 'State
+
+ module internal GroupBy =
+ val inline byVal : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * ISeq<'T>> when 'Key : equality
+ val inline byRef : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * ISeq<'T>> when 'Key : equality
+
+ module internal CountBy =
+ val inline byVal : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * int> when 'Key : equality
+ val inline byRef : projection:('T -> 'Key) -> source:ISeq<'T> -> ISeq<'Key * int> when 'Key : equality
From 3173bdcaa003148c9d1ce900ebda6422affcf91f Mon Sep 17 00:00:00 2001
From: Paul Westcott
Date: Tue, 14 Mar 2017 19:21:52 +1100
Subject: [PATCH 002/120] Updated remaining SurfaceArea files
---
.../SurfaceArea.coreclr.fs | 193 +++++++++++++++++
.../fsharpqa/Source/Misc/LongSourceFile01.fs | 194 ++++++++++++++++++
2 files changed, 387 insertions(+)
diff --git a/src/fsharp/FSharp.Core.Unittests/SurfaceArea.coreclr.fs b/src/fsharp/FSharp.Core.Unittests/SurfaceArea.coreclr.fs
index c762979fd6f..60e3528c6c7 100644
--- a/src/fsharp/FSharp.Core.Unittests/SurfaceArea.coreclr.fs
+++ b/src/fsharp/FSharp.Core.Unittests/SurfaceArea.coreclr.fs
@@ -293,6 +293,199 @@ Microsoft.FSharp.Collections.HashIdentity: System.Collections.Generic.IEqualityC
Microsoft.FSharp.Collections.HashIdentity: System.Collections.Generic.IEqualityComparer`1[T] Structural[T]()
Microsoft.FSharp.Collections.HashIdentity: System.String ToString()
Microsoft.FSharp.Collections.HashIdentity: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void .ctor()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Int32 HaltedIdx
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: TResult Result
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void .ctor(TResult, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void OnComplete(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void OnDispose()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Int32 HaltedIdx
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: TResult Result
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void .ctor(TResult, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+IOutOfBand: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]: ISeq`1 PushTransform[TResult](TransformFactory`2)
+Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]: TResult Fold[TResult,TState](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]])
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Activity`2 Compose[V](IOutOfBand, Int32, Activity`2)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Void .ctor()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void .ctor(Activity, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void OnComplete(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void OnDispose()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void .ctor(Activity, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Void .ctor(a)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Void .ctor(a, b)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: b _2
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Void .ctor(a, b, c)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: b _2
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: c _3
+Microsoft.FSharp.Collections.ISeqModule+Core: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Activity
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+IOutOfBand
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+NoValue
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]
+Microsoft.FSharp.Collections.ISeqModule+Core: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule: Boolean Contains[T](T, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Exists2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,System.Boolean]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Exists[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean ForAll2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,System.Boolean]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean ForAll[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Append[T](ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Choose[a,b](Microsoft.FSharp.Core.FSharpFunc`2[a,Microsoft.FSharp.Core.FSharpOption`1[b]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Concat[TCollection,T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 CountByRef[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 CountByVal[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Delay[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 DistinctBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Distinct[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Empty[T]()
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Except[T](System.Collections.Generic.IEnumerable`1[T], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Filter[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 GroupByRef[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 GroupByVal[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Indexed[a](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 InitializeInfinite[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Initialize[T](Int32, Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map2[T,TResult,V](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,V]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map3[T,TResult,V,W](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.FSharpFunc`2[V,W]]], ISeq`1, ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 MapIndexed2[T,TResult,V](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,V]]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 MapIndexed[a,b](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[a,b]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfArray[T](T[])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfList[T](Microsoft.FSharp.Collections.FSharpList`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfResizeArrayUnchecked[T](System.Collections.Generic.List`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfSeq[T](System.Collections.Generic.IEnumerable`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Pairwise[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Permute[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,System.Int32], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Reverse[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 ScanBack[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]], ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Scan[TState,T](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T,TState]], TState, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SkipWhile[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Skip[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SortBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SortWith[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,System.Int32]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Sort[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Tail[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 TakeWhile[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Take[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Truncate[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Unfold[TState,T](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[T,TState]]], TState)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Windowed[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Zip[T1,T2](ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Int32 CompareWith[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,System.Int32]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule: Int32 Length[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Collections.ISeqModule+Core
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[System.Int32] TryFindIndex[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[TResult] TryPick[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpOption`1[TResult]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryFind[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryHead[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryItem[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule: T Average[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T ExactlyOne[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Head[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Last[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T MaxBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Max[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T MinBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Min[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T ReduceBack[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,T]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Reduce[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,T]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Sum[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TResult AverageBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TResult SumBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TState Fold2[T1,T2,TState](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,TState]]], TState, ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TState FoldBack2[T1,T2,TState](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]]], ISeq`1, ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: TState FoldBack[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]], ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: TState Fold[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T,TState]], TState, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T[] ToArray[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void Iterate2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.Unit]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void IterateIndexed2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.Unit]]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void IterateIndexed[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.Unit]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void Iterate[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.Unit], ISeq`1)
Microsoft.FSharp.Collections.ListModule: Boolean Contains[T](T, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Boolean Equals(System.Object)
Microsoft.FSharp.Collections.ListModule: Boolean Exists2[T1,T2](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,System.Boolean]], Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
diff --git a/tests/fsharpqa/Source/Misc/LongSourceFile01.fs b/tests/fsharpqa/Source/Misc/LongSourceFile01.fs
index 970a5f77ff6..5cffea80004 100644
--- a/tests/fsharpqa/Source/Misc/LongSourceFile01.fs
+++ b/tests/fsharpqa/Source/Misc/LongSourceFile01.fs
@@ -247,6 +247,200 @@ Microsoft.FSharp.Collections.HashIdentity: System.Collections.Generic.IEqualityC
Microsoft.FSharp.Collections.HashIdentity: System.Collections.Generic.IEqualityComparer`1[T] Structural[T]()
Microsoft.FSharp.Collections.HashIdentity: System.String ToString()
Microsoft.FSharp.Collections.HashIdentity: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void .ctor()
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Int32 HaltedIdx
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: TResult Result
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void .ctor(TResult, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void OnComplete(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void OnDispose()
+Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Int32 HaltedIdx
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: TResult Result
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void .ctor(TResult, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+IOutOfBand: Void StopFurtherProcessing(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]: ISeq`1 PushTransform[TResult](TransformFactory`2)
+Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]: TResult Fold[TResult,TState](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]])
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+NoValue: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Activity`2 Compose[V](IOutOfBand, Int32, Activity`2)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]: Void .ctor()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void .ctor(Activity, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void OnComplete(Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]: Void OnDispose()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Boolean ProcessNext(T)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: TState State
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void .ctor(Activity, TState)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void ChainComplete(Microsoft.FSharp.Core.Unit ByRef, Int32)
+Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]: Void ChainDispose(Microsoft.FSharp.Core.Unit ByRef)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: Void .ctor(a)
+Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: Void .ctor(a, b)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]: b _2
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: Void .ctor(a, b, c)
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: a _1
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: b _2
+Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]: c _3
+Microsoft.FSharp.Collections.ISeqModule+Core: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule+Core: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Activity
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Activity`2[T,TResult]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+FolderWithPostProcessing`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Folder`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+IOutOfBand
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+NoValue
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+TransformFactory`2[T,TResult]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+TransformWithPostProcessing`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Transform`3[T,TResult,TState]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Value`1[a]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Values`2[a,b]
+Microsoft.FSharp.Collections.ISeqModule+Core: Microsoft.FSharp.Collections.ISeqModule+Core+Values`3[a,b,c]
+Microsoft.FSharp.Collections.ISeqModule+Core: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule+Core: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule: Boolean Contains[T](T, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Equals(System.Object)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Exists2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,System.Boolean]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean Exists[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean ForAll2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,System.Boolean]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Boolean ForAll[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Append[T](ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Choose[a,b](Microsoft.FSharp.Core.FSharpFunc`2[a,Microsoft.FSharp.Core.FSharpOption`1[b]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Concat[TCollection,T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 CountByRef[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 CountByVal[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Delay[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.ISeqModule+Core+ISeq`1[T]])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 DistinctBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Distinct[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Empty[T]()
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Except[T](System.Collections.Generic.IEnumerable`1[T], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Filter[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 GroupByRef[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 GroupByVal[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Indexed[a](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 InitializeInfinite[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Initialize[T](Int32, Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map2[T,TResult,V](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,V]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map3[T,TResult,V,W](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.FSharpFunc`2[V,W]]], ISeq`1, ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 MapIndexed2[T,TResult,V](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,V]]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 MapIndexed[a,b](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[a,b]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Map[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfArray[T](T[])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfList[T](Microsoft.FSharp.Collections.FSharpList`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfResizeArrayUnchecked[T](System.Collections.Generic.List`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 OfSeq[T](System.Collections.Generic.IEnumerable`1[T])
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Pairwise[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Permute[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,System.Int32], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Reverse[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 ScanBack[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]], ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Scan[TState,T](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T,TState]], TState, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SkipWhile[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Skip[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SortBy[T,TKey](Microsoft.FSharp.Core.FSharpFunc`2[T,TKey], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 SortWith[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,System.Int32]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Sort[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Tail[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 TakeWhile[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Take[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Truncate[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Unfold[TState,T](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[T,TState]]], TState)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Windowed[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: ISeq`1 Zip[T1,T2](ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Int32 CompareWith[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,System.Int32]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Int32 GetHashCode()
+Microsoft.FSharp.Collections.ISeqModule: Int32 Length[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Collections.ISeqModule+Core
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[System.Int32] TryFindIndex[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[TResult] TryPick[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpOption`1[TResult]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryFind[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryHead[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryItem[T](Int32, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Microsoft.FSharp.Core.FSharpOption`1[T] TryLast[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: System.String ToString()
+Microsoft.FSharp.Collections.ISeqModule: System.Type GetType()
+Microsoft.FSharp.Collections.ISeqModule: T Average[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T ExactlyOne[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Head[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Last[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T MaxBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Max[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T MinBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Min[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T ReduceBack[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,T]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Reduce[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[T,T]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T Sum[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TResult AverageBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TResult SumBy[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,TResult], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TState Fold2[T1,T2,TState](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,TState]]], TState, ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: TState FoldBack2[T1,T2,TState](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]]], ISeq`1, ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: TState FoldBack[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TState,TState]], ISeq`1, TState)
+Microsoft.FSharp.Collections.ISeqModule: TState Fold[T,TState](Microsoft.FSharp.Core.FSharpFunc`2[TState,Microsoft.FSharp.Core.FSharpFunc`2[T,TState]], TState, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: T[] ToArray[T](ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void Iterate2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.Unit]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void IterateIndexed2[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpFunc`2[TResult,Microsoft.FSharp.Core.Unit]]], ISeq`1, ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void IterateIndexed[T](Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.Unit]], ISeq`1)
+Microsoft.FSharp.Collections.ISeqModule: Void Iterate[T](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.Unit], ISeq`1)
+Microsoft.FSharp.Collections.ListModule: Boolean Contains[T](T, Microsoft.FSharp.Collections.FSharpList`1[T])
Microsoft.FSharp.Collections.ListModule: Boolean Equals(System.Object)
Microsoft.FSharp.Collections.ListModule: Boolean Exists2[T1,T2](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,System.Boolean]], Microsoft.FSharp.Collections.FSharpList`1[T1], Microsoft.FSharp.Collections.FSharpList`1[T2])
Microsoft.FSharp.Collections.ListModule: Boolean Exists[T](Microsoft.FSharp.Core.FSharpFunc`2[T,System.Boolean], Microsoft.FSharp.Collections.FSharpList`1[T])
From 960d6ff7793b99100885b39d3943c7ea24e51706 Mon Sep 17 00:00:00 2001
From: Paul Westcott
Date: Wed, 15 Mar 2017 20:38:33 +1100
Subject: [PATCH 003/120] Copied Seq tests and converted to ISeq
Due to missing functionality, this process will probably be done again
some time, but this is just a rough sketch to get some tests up and
running
---
.../FSharp.Core.Unittests.fsproj | 5 +
.../ISeqModule.fs | 1165 +++++++++++
.../ISeqModule2.fs | 1839 +++++++++++++++++
.../ISeqProperties.fs | 39 +
4 files changed, 3048 insertions(+)
create mode 100644 src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ISeqModule.fs
create mode 100644 src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ISeqModule2.fs
create mode 100644 src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ISeqProperties.fs
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
index 379990b793b..8ae4897387b 100644
--- a/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj
@@ -93,6 +93,11 @@
+
+
+
+
+
diff --git a/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ISeqModule.fs b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ISeqModule.fs
new file mode 100644
index 00000000000..02866848084
--- /dev/null
+++ b/src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Collections/ISeqModule.fs
@@ -0,0 +1,1165 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace FSharp.Core.Unittests.FSharp_Core.Microsoft_FSharp_Collections
+
+open System
+open NUnit.Framework
+
+open FSharp.Core.Unittests.LibraryTestFx
+
+// Various tests for the:
+// Microsoft.FSharp.Collections.seq type
+
+(*
+[Test Strategy]
+Make sure each method works on:
+* Integer ISeq (value type)
+* String ISeq (reference type)
+* Empty ISeq (0 elements)
+* Null ISeq (null)
+*)
+
+[]
+type ISeqModule() =
+
+ []
+ member this.AllPairs() =
+
+ // integer ISeq
+ let resultInt = Seq.allPairs (seq [1..7]) (seq [11..17])
+ let expectedInt =
+ seq { for i in 1..7 do
+ for j in 11..17 do
+ yield i, j }
+ VerifySeqsEqual expectedInt resultInt
+
+ // string ISeq
+ let resultStr = Seq.allPairs (seq ["str3";"str4"]) (seq ["str1";"str2"])
+ let expectedStr = seq ["str3","str1";"str3","str2";"str4","str1";"str4","str2"]
+ VerifySeqsEqual expectedStr resultStr
+
+ // empty ISeq
+ VerifySeqsEqual ISeq.empty <| Seq.allPairs ISeq.empty ISeq.empty
+ VerifySeqsEqual ISeq.empty <| Seq.allPairs { 1..7 } ISeq.empty
+ VerifySeqsEqual ISeq.empty <| Seq.allPairs ISeq.empty { 1..7 }
+
+ // null ISeq
+ CheckThrowsArgumentNullException(fun() -> Seq.allPairs null null |> ignore)
+ CheckThrowsArgumentNullException(fun() -> Seq.allPairs null (seq [1..7]) |> ignore)
+ CheckThrowsArgumentNullException(fun() -> Seq.allPairs (seq [1..7]) null |> ignore)
+ ()
+
+ []
+ member this.CachedSeq_Clear() =
+
+ let evaluatedItems : int list ref = ref []
+ let cachedSeq =
+ ISeq.initInfinite (fun i -> evaluatedItems := i :: !evaluatedItems; i)
+ |> Seq.cache
+ |> ISeq.ofSeq
+
+ // Verify no items have been evaluated from the ISeq yet
+ Assert.AreEqual(List.length !evaluatedItems, 0)
+
+ // Force evaluation of 10 elements
+ ISeq.take 10 cachedSeq
+ |> Seq.toList
+ |> ignore
+
+ // verify ref clear switch length
+ Assert.AreEqual(List.length !evaluatedItems, 10)
+
+ // Force evaluation of 10 elements
+ ISeq.take 10 cachedSeq
+ |> Seq.toList
+ |> ignore
+
+ // Verify ref clear switch length (should be cached)
+ Assert.AreEqual(List.length !evaluatedItems, 10)
+
+
+ // Clear
+ (box cachedSeq :?> System.IDisposable) .Dispose()
+
+ // Force evaluation of 10 elements
+ ISeq.take 10 cachedSeq
+ |> Seq.toList
+ |> ignore
+
+ // Verify length of evaluatedItemList is 20
+ Assert.AreEqual(List.length !evaluatedItems, 20)
+ ()
+
+ []
+ member this.Append() =
+
+ // empty ISeq
+ let emptySeq1 = ISeq.empty
+ let emptySeq2 = ISeq.empty
+ let appendEmptySeq = ISeq.append emptySeq1 emptySeq2
+ let expectResultEmpty = ISeq.empty
+
+ VerifySeqsEqual expectResultEmpty appendEmptySeq
+
+ // Integer ISeq
+ let integerSeq1 = seq [0..4] |> ISeq.ofSeq
+ let integerSeq2 = seq [5..9] |> ISeq.ofSeq
+
+ let appendIntergerSeq = ISeq.append integerSeq1 integerSeq2
+
+ let expectResultInteger = seq { for i in 0..9 -> i}
+
+ VerifySeqsEqual expectResultInteger appendIntergerSeq
+
+
+ // String ISeq
+ let stringSeq1 = seq ["1";"2"] |> ISeq.ofSeq
+ let stringSeq2 = seq ["3";"4"] |> ISeq.ofSeq
+
+ let appendStringSeq = ISeq.append stringSeq1 stringSeq2
+
+ let expectedResultString = seq ["1";"2";"3";"4"]
+
+ VerifySeqsEqual expectedResultString appendStringSeq
+
+ // null ISeq
+ let nullSeq1 = seq [null;null] |> ISeq.ofSeq
+ let nullSeq2 = seq [null;null] |> ISeq.ofSeq
+
+ let appendNullSeq = ISeq.append nullSeq1 nullSeq2
+
+ let expectedResultNull = seq [ null;null;null;null]
+
+ VerifySeqsEqual expectedResultNull appendNullSeq
+
+ ()
+
+ []
+ member this.replicate() =
+ // replicate should create multiple copies of the given value
+ Assert.IsTrue(Seq.isEmpty <| Seq.replicate 0 null)
+ Assert.IsTrue(Seq.isEmpty <| Seq.replicate 0 1)
+ Assert.AreEqual(null, ISeq.head <| (Seq.replicate 1 null |> ISeq.ofSeq))
+ Assert.AreEqual(["1";"1"],Seq.replicate 2 "1" |> Seq.toList)
+
+ CheckThrowsArgumentException (fun () -> Seq.replicate -1 null |> ignore)
+
+
+ []
+ member this.Average() =
+ // empty ISeq
+ let emptySeq = ISeq.empty
+
+ CheckThrowsArgumentException (fun () -> ISeq.average emptySeq |> ignore)
+
+
+ // double ISeq
+ let doubleSeq = seq [1.0;2.2;2.5;4.3] |> ISeq.ofSeq
+
+ let averageDouble = ISeq.average doubleSeq
+
+ Assert.IsFalse( averageDouble <> 2.5)
+
+ // float32 ISeq
+ let floatSeq = seq [ 2.0f;4.4f;5.0f;8.6f] |> ISeq.ofSeq
+
+ let averageFloat = ISeq.average floatSeq
+
+ Assert.IsFalse( averageFloat <> 5.0f)
+
+ // decimal ISeq
+ let decimalSeq = seq [ 0M;19M;19.03M] |> ISeq.ofSeq
+
+ let averageDecimal = ISeq.average decimalSeq
+
+ Assert.IsFalse( averageDecimal <> 12.676666666666666666666666667M )
+
+ // null ISeq
+ //let nullSeq : ISeq.Core.ISeq = null
+
+ //CheckThrowsArgumentNullException (fun () -> ISeq.average nullSeq |> ignore)
+ ()
+
+
+ []
+ member this.AverageBy() =
+ // empty ISeq
+ let emptySeq = ISeq.empty
+
+ CheckThrowsArgumentException (fun () -> ISeq.averageBy (fun x -> x+1.0) emptySeq |> ignore)
+
+ // double ISeq
+ let doubleSeq = seq [1.0;2.2;2.5;4.3] |> ISeq.ofSeq
+
+ let averageDouble = ISeq.averageBy (fun x -> x-2.0) doubleSeq
+
+ Assert.IsFalse( averageDouble <> 0.5 )
+
+ // float32 ISeq
+ let floatSeq = seq [ 2.0f;4.4f;5.0f;8.6f] |> ISeq.ofSeq
+
+ let averageFloat = ISeq.averageBy (fun x -> x*3.3f) floatSeq
+
+ Assert.IsFalse( averageFloat <> 16.5f )
+
+ // decimal ISeq
+ let decimalSeq = seq [ 0M;19M;19.03M] |> ISeq.ofSeq
+
+ let averageDecimal = ISeq.averageBy (fun x -> x/10.7M) decimalSeq
+
+ Assert.IsFalse( averageDecimal <> 1.1847352024922118380062305296M )
+
+ //// null ISeq
+ //let nullSeq = null
+
+ //CheckThrowsArgumentNullException (fun () -> ISeq.averageBy (fun (x:double)->x+4.0) nullSeq |> ignore)
+ ()
+
+ []
+ member this.Cache() =
+ // empty ISeq
+ let emptySeq = ISeq.empty
+
+ let cacheEmpty = Seq.cache emptySeq
+
+ let expectedResultEmpty = ISeq.empty
+
+ VerifySeqsEqual expectedResultEmpty cacheEmpty
+
+ // double ISeq
+ let doubleSeq = seq [1.0;2.2;2.5;4.3] |> ISeq.ofSeq
+
+ let cacheDouble = Seq.cache doubleSeq
+
+ VerifySeqsEqual doubleSeq cacheDouble
+
+
+ // float32 ISeq
+ let floatSeq = seq [ 2.0f;4.4f;5.0f;8.6f]
+
+ let cacheFloat = Seq.cache floatSeq
+
+ VerifySeqsEqual floatSeq cacheFloat
+
+ // decimal ISeq
+ let decimalSeq = seq [ 0M; 19M; 19.03M]
+
+ let cacheDecimal = Seq.cache decimalSeq
+
+ VerifySeqsEqual decimalSeq cacheDecimal
+
+ // null ISeq
+ let nullSeq = seq [null]
+
+ let cacheNull = Seq.cache nullSeq
+
+ VerifySeqsEqual nullSeq cacheNull
+ ()
+
+ []
+ member this.Case() =
+
+ // integer ISeq
+ let integerArray = [|1;2|]
+ let integerSeq = Seq.cast integerArray
+
+ let expectedIntegerSeq = seq [1;2]
+
+ VerifySeqsEqual expectedIntegerSeq integerSeq
+
+ // string ISeq
+ let stringArray = [|"a";"b"|]
+ let stringSeq = Seq.cast stringArray
+
+ let expectedStringSeq = seq["a";"b"]
+
+ VerifySeqsEqual expectedStringSeq stringSeq
+
+ // empty ISeq
+ let emptySeq = Seq.cast ISeq.empty
+ let expectedEmptySeq = ISeq.empty
+
+ VerifySeqsEqual expectedEmptySeq ISeq.empty
+
+ // null ISeq
+ let nullArray = [|null;null|]
+ let NullSeq = Seq.cast nullArray
+ let expectedNullSeq = seq [null;null]
+
+ VerifySeqsEqual expectedNullSeq NullSeq
+
+ CheckThrowsExn(fun () ->
+ let strings =
+ integerArray
+ |> Seq.cast
+ for o in strings do ())
+
+ CheckThrowsExn(fun () ->
+ let strings =
+ integerArray
+ |> Seq.cast
+ :> System.Collections.IEnumerable // without this upcast the for loop throws, so it should with this upcast too
+ for o in strings do ())
+
+ ()
+
+ []
+ member this.Choose() =
+
+ // int ISeq
+ let intSeq = seq [1..20] |> ISeq.ofSeq
+ let funcInt x = if (x%5=0) then Some x else None
+ let intChoosed = ISeq.choose funcInt intSeq
+ let expectedIntChoosed = seq { for i = 1 to 4 do yield i*5}
+
+
+
+ VerifySeqsEqual expectedIntChoosed intChoosed
+
+ // string ISeq
+ let stringSrc = seq ["list";"List"] |> ISeq.ofSeq
+ let funcString x = match x with
+ | "list"-> Some x
+ | "List" -> Some x
+ | _ -> None
+ let strChoosed = ISeq.choose funcString stringSrc
+ let expectedStrChoose = seq ["list";"List"]
+
+ VerifySeqsEqual expectedStrChoose strChoosed
+
+ // empty ISeq
+ let emptySeq = ISeq.empty
+ let emptyChoosed = ISeq.choose funcInt emptySeq
+
+ let expectedEmptyChoose = ISeq.empty
+
+ VerifySeqsEqual expectedEmptyChoose emptySeq
+
+
+ // null ISeq
+ //let nullSeq = null
+
+ //CheckThrowsArgumentNullException (fun () -> ISeq.choose funcInt nullSeq |> ignore)
+ ()
+
+ []
+ member this.ChunkBySize() =
+
+ let verify expected actual =
+ ISeq.zip (expected |> ISeq.ofSeq) (actual |> ISeq.ofSeq)
+ |> ISeq.iter ((<||) VerifySeqsEqual)
+
+ // int ISeq
+ verify [[1..4];[5..8]] <| Seq.chunkBySize 4 {1..8}
+ verify [[1..4];[5..8];[9..10]] <| Seq.chunkBySize 4 {1..10}
+ verify [[1]; [2]; [3]; [4]] <| Seq.chunkBySize 1 {1..4}
+
+ Seq.chunkBySize 2 (ISeq.initInfinite id)
+ |> ISeq.ofSeq
+ |> ISeq.take 3
+ |> verify [[0;1];[2;3];[4;5]]
+
+ Seq.chunkBySize 1 (ISeq.initInfinite id)
+ |> ISeq.ofSeq
+ |> ISeq.take 5
+ |> verify [[0];[1];[2];[3];[4]]
+
+ // string ISeq
+ verify [["a"; "b"];["c";"d"];["e"]] <| Seq.chunkBySize 2 ["a";"b";"c";"d";"e"]
+
+ // empty ISeq
+ verify ISeq.empty <| Seq.chunkBySize 3 ISeq.empty
+
+ // null ISeq
+ let nullSeq:seq<_> = null
+ CheckThrowsArgumentNullException (fun () -> Seq.chunkBySize 3 nullSeq |> ignore)
+
+ // invalidArg
+ CheckThrowsArgumentException (fun () -> Seq.chunkBySize 0 {1..10} |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.chunkBySize -1 {1..10} |> ignore)
+
+ ()
+
+ []
+ member this.SplitInto() =
+
+ let verify expected actual =
+ ISeq.zip (expected |> ISeq.ofSeq) (actual |> ISeq.ofSeq)
+ |> ISeq.iter ((<||) VerifySeqsEqual)
+
+ // int ISeq
+ Seq.splitInto 3 {1..10} |> verify (seq [ {1..4}; {5..7}; {8..10} ])
+ Seq.splitInto 3 {1..11} |> verify (seq [ {1..4}; {5..8}; {9..11} ])
+ Seq.splitInto 3 {1..12} |> verify (seq [ {1..4}; {5..8}; {9..12} ])
+
+ Seq.splitInto 4 {1..5} |> verify (seq [ [1..2]; [3]; [4]; [5] ])
+ Seq.splitInto 20 {1..4} |> verify (seq [ [1]; [2]; [3]; [4] ])
+
+ // string ISeq
+ Seq.splitInto 3 ["a";"b";"c";"d";"e"] |> verify ([ ["a"; "b"]; ["c";"d"]; ["e"] ])
+
+ // empty ISeq
+ VerifySeqsEqual [] <| Seq.splitInto 3 []
+
+ // null ISeq
+ let nullSeq:seq<_> = null
+ CheckThrowsArgumentNullException (fun () -> Seq.splitInto 3 nullSeq |> ignore)
+
+ // invalidArg
+ CheckThrowsArgumentException (fun () -> Seq.splitInto 0 [1..10] |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.splitInto -1 [1..10] |> ignore)
+
+ ()
+
+ []
+ member this.Compare() =
+
+ // int ISeq
+ let intSeq1 = seq [1;3;7;9] |> ISeq.ofSeq
+ let intSeq2 = seq [2;4;6;8] |> ISeq.ofSeq
+ let funcInt x y = if (x>y) then x else 0
+ let intcompared = ISeq.compareWith funcInt intSeq1 intSeq2
+
+ Assert.IsFalse( intcompared <> 7 )
+
+ // string ISeq
+ let stringSeq1 = seq ["a"; "b"] |> ISeq.ofSeq
+ let stringSeq2 = seq ["c"; "d"] |> ISeq.ofSeq
+ let funcString x y = match (x,y) with
+ | "a", "c" -> 0
+ | "b", "d" -> 1
+ |_ -> -1
+ let strcompared = ISeq.compareWith funcString stringSeq1 stringSeq2
+ Assert.IsFalse( strcompared <> 1 )
+
+ // empty ISeq
+ let emptySeq = ISeq.empty
+ let emptycompared = ISeq.compareWith funcInt emptySeq emptySeq
+
+ Assert.IsFalse( emptycompared <> 0 )
+
+ // null ISeq
+ //let nullSeq = null
+
+ //CheckThrowsArgumentNullException (fun () -> ISeq.compareWith funcInt nullSeq emptySeq |> ignore)
+ //CheckThrowsArgumentNullException (fun () -> ISeq.compareWith funcInt emptySeq nullSeq |> ignore)
+ //CheckThrowsArgumentNullException (fun () -> ISeq.compareWith funcInt nullSeq nullSeq |> ignore)
+
+ ()
+
+ []
+ member this.Concat() =
+ // integer ISeq
+ let seqInt =
+ seq { for i in 0..9 do
+ yield seq {for j in 0..9 do
+ yield i*10+j} |> ISeq.ofSeq } |> ISeq.ofSeq
+ let conIntSeq = ISeq.concat seqInt
+ let expectedIntSeq = seq { for i in 0..99 do yield i}
+
+ VerifySeqsEqual expectedIntSeq conIntSeq
+
+ // string ISeq
+ let strSeq =
+ seq { for a in 'a' .. 'b' do
+ for b in 'a' .. 'b' do
+ yield seq [a; b] |> ISeq.ofSeq }|> ISeq.ofSeq
+
+ let conStrSeq = ISeq.concat strSeq
+ let expectedStrSeq = seq ['a';'a';'a';'b';'b';'a';'b';'b';]
+ VerifySeqsEqual expectedStrSeq conStrSeq
+
+ // Empty ISeq
+ let emptySeqs = seq [seq[ ISeq.empty;ISeq.empty]|> ISeq.ofSeq;seq[ ISeq.empty;ISeq.empty]|> ISeq.ofSeq]|> ISeq.ofSeq
+ let conEmptySeq = ISeq.concat emptySeqs
+ let expectedEmptySeq =seq { for i in 1..4 do yield ISeq.empty}
+
+ VerifySeqsEqual expectedEmptySeq conEmptySeq
+
+ //// null ISeq
+ //let nullSeq = null
+
+ //CheckThrowsArgumentNullException (fun () -> ISeq.concat nullSeq |> ignore)
+
+ ()
+
+ [