Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type equality of monomorphic and polymorphic Char.char vectors exposed #46

Open
MatthewFluet opened this issue Feb 7, 2014 · 2 comments

Comments

@MatthewFluet
Copy link
Member

MLton exposes the type equality of monomorphic and polymorphic Char.char vectors:

fun 'a id (x: 'a) : 'a = x

val _ : CharVector.vector -> Char.char Vector.vector = id
val _ : CharVectorSlice.slice -> Char.char VectorSlice.slice = id

For portability with other SML implementations, the type equality of monomorphic and polymorphic Char.char vectors should not be exposed.

@MatthewFluet
Copy link
Member Author

Unlike the fixes for #45 and #47, which could be handled by some simply applications of opaque signature matching in the Basis Library implementation, hiding the type equality of monomorphic and polymorphic Char.char vectors is more difficult. This is because string constants must have the type CharVector.vector (equivalent to String.string) and the compiler elaborates string constants as Char.char vector.

Hiding these type equalities would be a more substantial refactoring of the treatment of constants in the compiler and Basis Library implementation. In particular, we might need to introduce a new form of overloading (e.g., _overload_const) to indicate the Basis Library (possibly opaque) types at which a constant could be elaborated.

@MatthewFluet
Copy link
Member Author

An alternative approach might be to reuse the existing _overload extension and take a cue from Haskell's treatment of constants. That is, treat a string constant as an implicit application of the form:

  (_fromStringConst "string")

for an overloaded _fromStringConst function. (We choose a lexically invalid identifier to avoid conflicting with user code.) Any opaque type that should be denotable by a constant can simply provide an appropriate _fromStringConst identity function that will be added to the overload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant