Elm-format: List of other projects that are interested in using an Elm AST

Created on 23 Sep 2016  路  9Comments  路  Source: avh4/elm-format

As discussed here https://groups.google.com/d/topic/elm-dev/QPLPd8q1Od0/discussion

If you are working on a project that could benefit from elm-format producing / consuming a JSON-formatted AST, please comment on this issue to let others know about it.

Known projects (feel free to comment below with more details):

  • elm-lighttable
  • sketch-n-sketch
  • atom-elmjutsu
  • elm-tracing-interpreter
  • atomist
discussion public AST

Most helpful comment

Hello everyone, just wanted to introduce myself. I'm Christoph Hegemann and spend most of my free time working on tooling for the PureScript community.

I'm not really active in the Elm scene, but all the work you are doing on language tooling is very exciting to me and I think some of my ideas could be implemented in Elm (especially because you have the pretty printer I yearn for in PS :smile:).

One neat application of having an AST format that editors can consume is that you can stop using Regexes to highlight source code and instead use the semantics a compiler can gather about your code.

The best example of this I know about is the Idris compiler. As Idris is a dependently typed language, values and types can appear interchangeably and you can't actually discern between the two from "just" parsing the source code. So extracting the highlighting _after_ type checking allows to discern between types and values in the editors.

Elm and PureScript are not as extreme in this regard, but it would definitely be nice to apply semantic highlighting. Regexes have tendencies to be very fragile and fail on edge cases.

All 9 comments

tl;dr an AST could enable the creation of editor plugins for generating decoders and encoders from types.


Things like http://noredink.github.io/json-to-elm/ and editor-embedded versions of it could make great use of a public AST. There are two user experiences I can imagine here:

  • The user wants to generate decoders and encoders for all their types in a particular file when possible
  • The user has highlighted a particular type or type alias and wants to generate a decoder or encoder inline underneath that declaration

The first case it seems pretty straightforward, just get the AST for the file and walk through it, keeping track of where you are and generating an additional AST for decoders and encoders along side the found types.

The second case requires knowledge of where the cursor is or maybe what part of the AST is bounded by the user's selection.

And then for both cases it would be great to be able to figure out if the user has already generated a decoder for a particular type so that it can be updated in place rather than having a new one appended and leaving the wrong one still hanging around. Having detailed structured knowledge of the user's Elm code could be great for making guesses at how a user wants to write decoders and encoders for complicated things like union types, too.

Hello everyone, just wanted to introduce myself. I'm Christoph Hegemann and spend most of my free time working on tooling for the PureScript community.

I'm not really active in the Elm scene, but all the work you are doing on language tooling is very exciting to me and I think some of my ideas could be implemented in Elm (especially because you have the pretty printer I yearn for in PS :smile:).

One neat application of having an AST format that editors can consume is that you can stop using Regexes to highlight source code and instead use the semantics a compiler can gather about your code.

The best example of this I know about is the Idris compiler. As Idris is a dependently typed language, values and types can appear interchangeably and you can't actually discern between the two from "just" parsing the source code. So extracting the highlighting _after_ type checking allows to discern between types and values in the editors.

Elm and PureScript are not as extreme in this regard, but it would definitely be nice to apply semantic highlighting. Regexes have tendencies to be very fragile and fail on edge cases.

Another addition to this list:

I'm working on a project that will generate Programs to visualize values in the best possible way based on their type, and having an AST would make detecting types more robust than writing my own thing based on text parsing

I just deleted a few unused functions in a codebase and I thought it would be great if there was a tool that would go threw your code base and let you flag all the functions (and types) that you define and never use. I even know how to write it

@zkessin I'm working on such a tool. I hope to make it public in a week or two.

I'm looking into writing a graphical tool for creating/editing elm-style-animations (which would need to read/write your current Elm code, of course.)

I would like to create an Elm plugin for a particular popular IDE. This kind of tool would be very valuable.

Just as valuable would be a formal language syntax spec.

BTW is there any intention of this becoming Elm's version of HIE

@zkessin Released my tool as elm-analyse. Let me know what you think (ping me on slack)

I am using elm-css because of its support for using a union type as CSS classes and ids. Now that I have a large amount of CSS in elm-css, I would like to reuse those selectors for the non javascript version so my site has a consistent theme. I use Rust to render the webpage, and I would like to export the Elm union types for classes and ids into Rust code so that my selectors are synchronized (and checked by the compiler).

Ideally I would have Elm code be the source of truth for CSS selectors, because the designers are the ones in control of the selectors. Instead, because only the rust compiler has the ability to output the its ast representation as JSON rustc -Z ast-json, we must go from Rust ADTs into Elm ADTs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabrielflorit picture gabrielflorit  路  7Comments

rtfeldman picture rtfeldman  路  5Comments

sporto picture sporto  路  7Comments

avh4 picture avh4  路  4Comments

yonigibbs picture yonigibbs  路  7Comments