diff --git a/src/Visp.Runtime.Library/Value.fs b/src/Visp.Runtime.Library/Value.fs index 085fb7d..1152e1e 100644 --- a/src/Visp.Runtime.Library/Value.fs +++ b/src/Visp.Runtime.Library/Value.fs @@ -32,15 +32,33 @@ type Value = | HashSet of HashSet | Pair of Pair + member this.TypeName = + match this with + | Nil -> "Value.Nil" + | Unit -> "Value.Unit" + | String _ -> "Value.String" + | Symbol _ -> "Value.Symbol" + | Keyword _ -> "Value.Keyword" + | Number _ -> "Value.Number" + | Char _ -> "Value.Char" + | Bool _ -> "Value.Bool" + | Any _ -> "Value.Any" + | Atom _ -> "Value.Atom" + | List _ -> "Value.List" + | Vector _ -> "Value.Vector" + | HashMap _ -> "Value.HashMap" + | HashSet _ -> "Value.HashSet" + | Pair _ -> "Value.Pair" + override this.GetHashCode() = System.HashCode.Combine( this.GetType(), match this with | Vector v -> v.GetHashCode() | List v -> v.GetHashCode() - | String v -> HashCode.Combine("string", v.GetHashCode()) - | Symbol v -> HashCode.Combine("symbol", v.GetHashCode()) - | Keyword v -> HashCode.Combine("keyword", v.GetHashCode()) + | String v -> HashCode.Combine("string", v) + | Symbol v -> HashCode.Combine("symbol", v) + | Keyword v -> HashCode.Combine("keyword", v) | Number v -> v.GetHashCode() | Char v -> v.GetHashCode() | Bool v -> v.GetHashCode() @@ -105,9 +123,7 @@ type Value = | (HashMap lhs, HashMap rhs) -> lhs.CompareTo(rhs) | (HashSet lhs, HashSet rhs) -> lhs.CompareTo(rhs) | (Pair lhs, Pair rhs) -> lhs.CompareTo(rhs) - | (lhs, rhs) -> - (lhs.GetType().GetHashCode() :> IComparable<_>) - .CompareTo(rhs.GetType().GetHashCode()) + | (lhs, rhs) -> lhs.TypeName.CompareTo(rhs.TypeName) static member list(it: Value seq) = List(ValueList(List.ofSeq it)) diff --git a/tests/Visp.ExecutionTests/snapshots/tests_hashmap_hashmap-0.can execute.verified.txt b/tests/Visp.ExecutionTests/snapshots/tests_hashmap_hashmap-0.can execute.verified.txt index d660846..350e0be 100644 --- a/tests/Visp.ExecutionTests/snapshots/tests_hashmap_hashmap-0.can execute.verified.txt +++ b/tests/Visp.ExecutionTests/snapshots/tests_hashmap_hashmap-0.can execute.verified.txt @@ -1,4 +1,4 @@ -{:this-is-a-key "value" "string as key" "string value" 0 "int as key"} +{:this-is-a-key "value" 0 "int as key" "string as key" "string value"} "string value" "value" () diff --git a/tests/Visp.ExecutionTests/snapshots/tests_hashset_hashset-0.can execute.verified.txt b/tests/Visp.ExecutionTests/snapshots/tests_hashset_hashset-0.can execute.verified.txt index 8b95b30..aad623c 100644 --- a/tests/Visp.ExecutionTests/snapshots/tests_hashset_hashset-0.can execute.verified.txt +++ b/tests/Visp.ExecutionTests/snapshots/tests_hashset_hashset-0.can execute.verified.txt @@ -1,4 +1,4 @@ -#{:this-is-a-key "int as key" "string as key" "string value" "value" 0} +#{:this-is-a-key 0 "int as key" "string as key" "string value" "value"} () ExitCode: 0