There is another way if you want the key to be a specific type (i.e.), and not just another string. You can simply create a StringID type and also wrap it further in an expression:
type StringId = Sid of string type Expression = | StringId of StringId | BooleanConstant of bool | StringConstant of string | IntegerConstant of int | Vector of Expression list
This will allow you to create a map in one of the following ways:
let x = Sid "x" [StringId x ,BooleanConstant true] |> Map.ofList //val it : Map<Expression,Expression> = map [(StringId (Sid "x"), BooleanConstant true)] [x,BooleanConstant true] |> Map.ofList //val it : Map<StringId,Expression> = map [(Sid "x", BooleanConstant true)]
However, saving the key as a simple string is certainly less difficult.
source share