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

List of other projects that are interested in using an Elm AST #236

Open
avh4 opened this issue Sep 23, 2016 · 9 comments
Open

List of other projects that are interested in using an Elm AST #236

avh4 opened this issue Sep 23, 2016 · 9 comments

Comments

@avh4
Copy link
Owner

avh4 commented Sep 23, 2016

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
@avh4 avh4 added this to the 2.0.0 public AST milestone Sep 23, 2016
@lukewestby
Copy link

lukewestby commented Sep 27, 2016

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.

@kritzcreek
Copy link

kritzcreek commented Sep 28, 2016

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 😄).

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.

@lukewestby
Copy link

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

@zkessin
Copy link

zkessin commented Feb 9, 2017

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

@stil4m
Copy link

stil4m commented Feb 9, 2017

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

@mdgriffith
Copy link

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.)

@JohnMcGuinness
Copy link

JohnMcGuinness commented Mar 5, 2017

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

@stil4m
Copy link

stil4m commented Mar 5, 2017

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

@YetAnotherMinion
Copy link

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.

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

8 participants