add_strliteral_form : {inj:term, ldelim:string} -> unit
If the given ld-rd pair is already associated with an injector, then the parsing process will resolve the ambiguity with the standard overloading resolution method. In particular, note that the standard double quotation mark (ASCII character 34, ") is associated with the “null” injector, which takes string literals into the string type. Other injectors can be associated with this delimiter pair.
The other valid delimiter pairs are double guillemets («...», U+00AB and U+00BB) and single guillemets (‹...›, U+2039 and U+203A).
Datatype`tm = V string | Cst string | App tm tm`;
> add_strliteral_form {inj=``V``, ldelim="\""}; > ``App (V "foo") (App "bar" "baz")``; val it = “App "foo" (App "bar" "baz")”: term
We can further choose to have constants printed with enclosing «...» by:
> add_strliteral_form {inj=``Cst``, ldelim="«"}; > ``App "foo" (Cst "bar")``; val it = “App "foo" «bar»”: term
Note that in this situation, use of the double guillemets is unambiguous, but a bare string literal is strictly ambiguous (the default is to prefer the core string type):
> type_of “«foo»”; val it = “:tm”: hol_type > type_of “"foo"”; <<HOL message: more than one resolution of overloading was possible>> val it = “:string”: hol_type