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

EmitML prints types with reserved words #56

Open
xrchz opened this issue Apr 2, 2012 · 4 comments
Open

EmitML prints types with reserved words #56

xrchz opened this issue Apr 2, 2012 · 4 comments

Comments

@xrchz
Copy link
Member

xrchz commented Apr 2, 2012

Emitting something like

val _ = Hol_datatype `op = Foo`
val _ = Hol_datatype `bar = Bar of op`
emitLib.eSML "bug" [DATATYPE `op = Foo`, DATATYPE `bar = Bar of op`]

generates the inconsistent and invalid

signature bugML =
sig
  datatype op_ = Foo
  datatype bar = Bar of op
end

This is not trivial to fix because EmitML uses type_pp.pp_type for arguments on the right hand side of a datatype.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@mn200
Copy link
Member

mn200 commented Apr 2, 2012

The fix would probably be to link the type pretty-printer up to a backend that knew to munge particular tokens as they were emitted.

@konrad-slind
Copy link
Contributor

Seems to me that futzing with the overload map when calling emitML would
do the trick, but I haven't thought it through. (Is there an overload
map for types?) If that doesn't work, then you could add a constant
"op_" to the type signature when calling emitML and when pp_type_as_ML
comes to prettyprint a type, recurse through the type, do the

op |-> op_

replacement. Ugly, I know, but it is prettyprinting after all.

Konrad.

On Mon, Apr 2, 2012 at 6:16 PM, Ramana Kumar
[email protected]
wrote:

Emitting something like

   val _ = Hol_datatype op = Foo
   val _ = Hol_datatype bar = Bar of op
   emitLib.eSML "bug" [DATATYPE op = Foo, DATATYPE bar = Bar of op]

generates the inconsistent and invalid

   signature bugML =
   sig
     datatype op_ = Foo
     datatype bar = Bar of op
   end

This is not trivial to fix because EmitML uses type_pp.pp_type for arguments on the right hand side of a datatype.


Reply to this email directly or view it on GitHub:
#56

@xrchz
Copy link
Member Author

xrchz commented Apr 3, 2012

My workaround is

val _ = Parse.temp_type_abbrev("op_",``:op``)

That's what you mean, right Konrad?
It's an easy workaround, but probably EmitML should be better (doing as Michael suggested I think).

@konrad-slind
Copy link
Contributor

Yes, that's it. Not very solid-feeling, as you say.

Konrad.

On Mon, Apr 2, 2012 at 7:13 PM, Ramana Kumar
[email protected]
wrote:

My workaround is

   val _ = Parse.temp_type_abbrev("op_",:op)

That's what you mean, right Konrad?
It's an easy workaround, but probably EmitML should be better (doing as Michael suggested I think).


Reply to this email directly or view it on GitHub:
#56 (comment)

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

3 participants