[racket] Projectional Editors

From: Tony Clark (t.n.clark at mdx.ac.uk)
Date: Fri Jul 5 09:42:09 EDT 2013

Thanks for getting back to me on this.

The kind of thing I had in mind was to be able to type:

(iU (i n) (Person (index name i)))

as source code into Dr Racket. Once the closing parenthesis on the form was typed, the editor would recognise the form as special and redisplay it as $\bigcup_{i\in[0,n]} (Person (index name i))$. In principle, the format of the input could be flexible, for example:

!(i n) (Person (index name i)))

Could have the same effect if it would be more convenient to get the processing done via some character macro in the reader.

In a super-duper ideal world, once recognised and displayed in the math-style with subscripts, the identifier names used in the subscript would be editable in-place (via some form of selection and/or mouse navigation). However, I think it would be acceptable for the projected form to revert to the AST text-representation when it is selected for editing.

Regarding macro-expansion: I am not certain, but assume that the macro expansion occurs after the forms in a DrRacket pane have been fully read. Projectional Editors should ideally recognise the input and perform the conversion to the 'projected' output format in-place as the text is typed. I guess I could be completely wrong on that, in which case macro-expansion could help 'catch' the input form and convert to the output form (but would need to grab access to the underlying graphics for the editor surely?).

I don't think that a separate window<%> object would be acceptable, it needs to integrate with the 'normal' editor as presented in DrRacket.

-- Tony

From: Robby Findler <robby at eecs.northwestern.edu<mailto:robby at eecs.northwestern.edu>>
Date: Friday, 5 July 2013 14:26
To: Tony Clark <t.n.clark at mdx.ac.uk<mailto:t.n.clark at mdx.ac.uk>>
Cc: "users at racket-lang.org<mailto:users at racket-lang.org>" <users at racket-lang.org<mailto:users at racket-lang.org>>
Subject: Re: [racket] Projectional Editors

I think DrRacket has all of the tools necessary to do what you're asking, but there is no convenient API for putting it all together. Depending on how you wanted it to look, I'd offer different suggestions on how to get started, I guess. For example, if you're happy with the projections being in a separate window<%> object, that'd be the easiest thing, I guess (and much of the work you'd do could be re-used if you wanted a different way to draw it, with a little bit of planning).

Are you thinking of using the raw source code to get the projection, or are you planning to involve macro expansion?

Robby


On Fri, Jul 5, 2013 at 2:52 AM, Tony Clark <t.n.clark at mdx.ac.uk<mailto:t.n.clark at mdx.ac.uk>> wrote:
Dear All,

I am implementing a language that involves patterns over sets. I am experimenting with an 'indexed set' pattern of the form:

(iU (index-var limit-var) pattern …)

Where pattern can include constants, (indexed) variables, (indexed) sets and terms. For example:

(iU (i n) (Person (index name i)))

Matches a set of terms:

'((Person fred) (Person bert) (Person sally))

To produce a binding environment:

'((n . 2) (name-0 . fred) (name-1 . bert) (name-2 . sally))

My question is whether DrRacket can be extended with 'projectional editing' features so that:

(iU (i n) (Person (index name i)))

When entered, is displayed using the equivalent of latex:

$\bigcup_{i\in[0,n]} (Person (index name i))$

A projectional editor (http://martinfowler.com/bliki/ProjectionalEditing.html) works by representing the AST of a language and then providing the user with a view of the AST, thereby allowing fancy representations. Whether the user can interact with the fancy representation or has to work at the AST level depends on the projectional editor.

I think DrRacket ought to be ideal for this kind of thing since: (a) we are essentially working on an AST already; (2) the editor appears to be programmable; (3) the GUI libraries allow easy dynamic creation of images that can be inserted into the editor.

I looked at the reference for DrRacket Plugins, but encountered a large interface that I am unsure how to navigate.

Thanks for any pointers.

-- Tony



---------------------------------------------------------------------------


Please note that Middlesex University's preferred way of receiving all correspondence is via email in line with our Environmental Policy. All incoming post to Middlesex University is opened and scanned by our digital document handler, CDS, and then emailed to the recipient.

If you do not want your correspondence to Middlesex University processed in this way please email the recipient directly. Parcels, couriered items and recorded delivery items will not be opened or scanned by CDS.  There are items which are "exceptions" which will be opened by CDS but will not be scanned a full list of these can be obtained by contacting the University.


____________________
  Racket Users list:
  http://lists.racket-lang.org/users




---------------------------------------------------------------------------


Please note that Middlesex University's preferred way of receiving all correspondence is via email in line with our Environmental Policy. All incoming post to Middlesex University is opened and scanned by our digital document handler, CDS, and then emailed to the recipient.
 
If you do not want your correspondence to Middlesex University processed in this way please email the recipient directly. Parcels, couriered items and recorded delivery items will not be opened or scanned by CDS.  There are items which are "exceptions" which will be opened by CDS but will not be scanned a full list of these can be obtained by contacting the University.



Posted on the users mailing list.