diff --git a/src/FSharpPlus.TypeLevel/Data/Matrix.fs b/src/FSharpPlus.TypeLevel/Data/Matrix.fs index db998c072..d826d4938 100644 --- a/src/FSharpPlus.TypeLevel/Data/Matrix.fs +++ b/src/FSharpPlus.TypeLevel/Data/Matrix.fs @@ -16,7 +16,7 @@ type Matrix< 'Item, 'Row, 'Column > = private { Items: 'Item[,] } with [] static member UnsafeCreate (_row: 'm, _column: 'n, items: _[,]) : Matrix<_, 'm, 'n> = { Items = items } - (* + interface System.Collections.Generic.IReadOnlyCollection<'Item> with member this.Count = this.Items.Length member this.GetEnumerator() = this.Items.GetEnumerator() @@ -27,7 +27,7 @@ type Matrix< 'Item, 'Row, 'Column > = private { Items: 'Item[,] } with for j = 0 to (items |> Array2D.length2) - 1 do yield items.[i,j] }).GetEnumerator() - *) + [] type Vector<'Item, 'Length> = private { Items: 'Item[] } with @@ -36,13 +36,13 @@ type Vector<'Item, 'Length> = private { Items: 'Item[] } with [] static member UnsafeCreate (_length: 'n, items: _[]) : Vector<_, 'n> = { Items = items } - (* + interface System.Collections.Generic.IReadOnlyList<'Item> with member this.Count = this.Items.Length member this.Item with get i = this.Items.[i] member this.GetEnumerator() = this.Items.GetEnumerator() member this.GetEnumerator() = (this.Items :> seq<_>).GetEnumerator() - *) + module Vector = [] diff --git a/tests/FSharpPlus.Tests/TypeLevel.fs b/tests/FSharpPlus.Tests/TypeLevel.fs index 9a0272e54..f5aa68482 100644 --- a/tests/FSharpPlus.Tests/TypeLevel.fs +++ b/tests/FSharpPlus.Tests/TypeLevel.fs @@ -206,3 +206,23 @@ module TypeProviderTests = Assert (Matrix.colLength row1 =^ (Z |> S |> S |> S)) areEqual 5 (Matrix.get Z (S Z) row1) areEqual [3; 6; 9] (Vector.toList col2) + +module TestFunctors1 = + [] + let applicativeOperatorWorks() = + let v = vector ((fun i -> i + 1), (fun i -> i * 2)) + let u = vector (2, 3) + let vu = v <*> u + NUnit.Framework.Assert.IsInstanceOf>>>> (Some vu) + CollectionAssert.AreEqual ([|3; 6|], Vector.toArray vu) + +module TestFunctors2 = + open FSharpPlus + + [] + let applicativeWorksWithoutSubsumption() = + let v = vector ((fun i -> i + 1), (fun i -> i * 2)) + let u = vector (2, 3) + let vu = v <*> u + NUnit.Framework.Assert.IsInstanceOf>>>> (Some vu) + CollectionAssert.AreEqual ([|3; 6|], Vector.toArray vu) \ No newline at end of file