A concept for editing Haskell as an AST rather than text

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,522
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Dec 17, 2011

It's not my intention for this to be all point and click, at all, but coming up with keybindings and a means to navigate the AST via keyboard is an interesting problem somewhat separate to the problem of creating/displaying/editing as-is. As you can see I'm even confused myself when using it, and it's a lot slower with the mouse. With keyboard control it could be blindingly faster than any text editing-based language editors available now. Think paredit-mode, but for non-Lisp languages.

I've had this idea in the back of my mind for years and today thought that I might do a concept implementation to solidify the idea somewhat.

The idea is that you can't create a syntactically invalid tree, and at each point it can offer you a choice between the valid choices. That's one part, the correctness. But that's merely a nice side-effect to the idea of purely syntactical editing, rather than textual editing, so that jumping around, transposing, moving, deleting expressions will be a lot easier. Even so that there is no need to care about indentation, but rather moving things about the AST. Still merely a concept at this point. It can technically be generalized to any programming language, but Haskell is my main working language so I am targeting it specifically.

In summary I made a little DSL for describing an AST for manipulating like this. There is a "list of things" combinator, an "optional" combinator (e.g. the "module" decl is optional), there is a "choice" combinator, e.g. when adding a new top-level decl it prompts for a choice between the different types of decls, validating text inputs (e.g. module name, constructor, variable, etc.), and that is more or less enough, as far as I can tell, so far. Hopefully it won't get much more complicated than that.

If you're implementing something like this already, I'd be interested to see it. If you have some interesting ideas, feel free to comment.

Category:

Science & Technology

Tags:

License:

Creative Commons Attribution license (reuse allowed)

Link to this comment:

Share to:

Uploader Comments (ChristopherDone)

  • Looks intresting, could you put it online (or even on github) so that I could play with it? (Maybe try adding some vi-like keybinding to it ;)

  • @pawelmurias github.com/chrisdone/structura­l

  • That's exactly what I want. Do you have public code for this?

  • @Inh2l github.com/chrisdone/structura­­l

  • You can build this with Xopus. You need to create an XML Schema to describe the AST and an XSLT to display the AST. We don't have an example like this, the closest is the recipe demo.

  • @sjoerdvisscher Looks like a nice product from the videos and the demos. But this is just a concept, in a file of JS I whipped up this evening, so that I can let people try it online, to be ported to Emacs later, not something I'm willing to pay €900 for. Not that I don't love writing XML schemas and XSLT. :-)

see all

All Comments (12)

Sign In or Sign Up now to post a comment!
  • How would you do copy & paste of code segments? Nice idea btw.

  • this looks like it would be useful for writing haskell on touch-based devices

  • @whiteh12 What ideas did you come up with?

  • @mwbuksas This concept editor is just a bit of JS on Chrome. Having the DOM makes it trivial to experiment with. I thought if there was some interest I could put it online, and people could try it trivially. But yeah, the intention would be to make the real (for me) implementation in Emacs with overlays and widgets. I did something similar recently for expanding Show instances (other vids), I think it's quite feasible (albeit perhaps not so fast).

  • I like the idea of working directly with ASTs and Haskell seems like a good choice. What is your editor implemented in? It looks like it could be in emacs, using the configuration mode widgets.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more