diff --git a/Vector.Test/TestVector.fs b/Vector.Test/TestVector.fs index 1616b3d..cd08a5f 100644 --- a/Vector.Test/TestVector.fs +++ b/Vector.Test/TestVector.fs @@ -15,20 +15,17 @@ module TestVector = |> Vector.cons 6 v1 |> Vector.toList |> shouldEqual [6 ; 5 ; 3] - let v2 = Vector.empty |> Vector.cons "hi" |> Vector.cons "bye" + let v2 = "bye" ** "hi" ** -() v2 |> Vector.toList |> shouldEqual ["bye" ; "hi"] [] let ``Pattern matching`` () = - match Vector.empty with + match -() with | Empty () -> () //| Vec (a, b) -> failwith "" -- doesn't compile let v1 = - Vector.empty - |> Vector.cons 3 - |> Vector.cons 5 - |> Vector.cons 6 + 6 ** 5 ** 3 ** -() match v1 with | Vec (a , b) -> @@ -45,10 +42,7 @@ module TestVector = [] let ``Vector concatenation`` () = let v1 = - Vector.empty - |> Vector.cons 3 - |> Vector.cons 5 - |> Vector.cons 6 + 6 ** 5 ** 3 ** -() let twice = Vector.append v1 v1 let otherTwice = diff --git a/Vector/Vector.fs b/Vector/Vector.fs index 3675cb8..03720e1 100644 --- a/Vector/Vector.fs +++ b/Vector/Vector.fs @@ -74,4 +74,7 @@ module Patterns = let (|Vec|) (Vector v : Vector<'a, S<'n>>) : 'a * Vector<'a, 'n> = List.head v, Vector (List.tail v) - let (|Empty|) (_ : Vector<'a, Z>) = () \ No newline at end of file + let (|Empty|) (_ : Vector<'a, Z>) = () + + let ( ~- ) () : Vector<'a, Z> = Vector.empty<'a> + let ( ** ) (x : 'a) (v : Vector<'a, 'n>) = Vector.cons x v