I’ve been continuing to work on this for the past two days, and I’ve
managed to get a lot more working. I figured I’d write a (somewhat
shorter) summary of what I have and haven’t solved.

  1. The issue with module language imports still seems hopeless.

  2. I managed to solve the submodule issue! The solution involved a
     change to splicing-syntax-parameterize[1] that improves how it
     handles submodules, plus using make-syntax-delta-introducer instead
     of make-syntax-introducer to preserve the scope across module
     instantiations (thanks to Matthew for that).

  3. Scribble is going to be hard. Hackett builds and the tests pass
     (though the code isn’t the prettiest), and I can even get the docs
     to render, but all the cross-references are broken for types.

     This is hard, because in Hackett, there is a syntactic distinction
     between which pieces of syntax need to be in which namespace.
     Consider expanding the type annotation form:

       (: <expr> <type>)

     It’s obvious that <expr> should be in the value namespace and
     <type> should be in the type namespace. When expanding code, this
     makes things easy, but Scribble doesn’t expand its code examples,
     it merely looks at the lexical information of the source syntax.
     If a `Tuple` type has a data constructor that is also named
     `Tuple`, there is no way for Scribble to know which binding to use.

     I don’t know that this is fixable, not without actually performing
     expansion as part of rendering documentation, and that isn’t
     possible in general because not every piece of typeset code is a
     self-contained program. It seems that the simple solution, to avoid
     needing to reinvent half of Scribble right now, is to annotate
     which bindings are types.

     I’ve managed to get *almost* there by prefixing all the type
     imports with `t:` and binding them to an element transformer
     produced by `make-element-id-transformer` that typesets them
     without the prefix. The trouble is that this doesn’t work with
     scribble/example, since, as far as I can tell, there are not any
     “eval/example transformers” that allow me to tell scribble/example
     to use a symbol without the prefix for evaluation. I’m not sure if
     there’s a better way, and if there isn’t, I’m not sure how hard
     that would be to add.

Those issues aside, multi-namespace Hackett works decently. Again, there
are some unsolved subtleties around the user interface for
hiding/renaming types, but I think those are entirely solvable with
custom require transformers. Check Syntax has no trouble understanding
the more complex binding structure of multi-namespace programs. Interop
with Racket is awkward, since Racket requires flattening the two
namespaces, but this is also solvable by prefixing types when importing
them into a Racket module (and I imagine this will be much less of a
problem once Hackett has a real FFI, so less needs to be done in Racket
to wire the two sides together).

Those interested in the guts of how this works can check out the
“namespaces” branch of the Hackett repo[2]. Of course, that branch will
eventually go away, so that link will eventually break, but my hope is
that it will go away because it has been be merged into Hackett, not
because I’ve given up. In the meantime, any thoughts are appreciated,
especially if you have any suggestions on solving the Scribble problem.

Alexis


[1]: 
https://github.com/racket/racket/commit/1e38918aa9719d212534d2027aa1a3a8b46462dd
[2]: https://github.com/lexi-lambda/hackett/tree/namespaces

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to