10

Almost every compiled language has a version of its compiler written in the language.

Is there not an Elm compiler written in Elm?

ben rudgers
  • 3,647
  • 2
  • 20
  • 32
Michael Lorton
  • 43,060
  • 26
  • 103
  • 144
  • *ahem* downvote for "does not show any research effort" beckons ... [what-can-i-do-when-getting-it-does-not-meet-our-quality-standards](http://meta.stackexchange.com/questions/92074/what-can-i-do-when-getting-it-does-not-meet-our-quality-standards) [is-my-question-not-clear-enough](http://meta.stackoverflow.com/questions/299469/is-my-question-not-clear-enough), [what-can-i-do-when-getting-it-does-not-meet-our-quality-standards](http://meta.stackexchange.com/questions/92074/what-can-i-do-when-getting-it-does-not-meet-our-quality-standards) – TessellatingHeckler Nov 26 '15 at 23:00
  • I don't know how to prove a negative. The few documents I have found suggest that the compiler is written in Haskell. – Michael Lorton Nov 26 '15 at 23:15
  • https://github.com/elm-in-elm/compiler Original compiler was haskell. Now there is an elm compiler in elm. – Brenn Sep 24 '19 at 04:52

4 Answers4

21

At the moment the only complete Elm compiler is the "official" one, therefore not named, and it's written in Haskell. I don't know of any implementation of an Elm compiler in Elm.

Over the years that I've read the Elm mailing list(s) I've seen this question come up. Some people expressed interest in having the compiler written in Elm so it can be compiled to JavaScript, and therefore there would be a compiler for Elm in the browser. But so far that's the only compelling argument that's been brought up (IIRC). Which is not enough to make porting the Elm compiler to Elm a priority, the cost-benefit ratio is skewed by the huge effort it would take to port even half of the Haskell libraries that are currently used by elm-compiler.

Apanatshka
  • 5,958
  • 27
  • 38
  • 1
    Besides the advantages of being able to run it in a browser or other Javascript environments (which is what I want), it would demonstrate that writing serious programs in Elm is not a huge effort. – Michael Lorton Nov 27 '15 at 20:25
  • 12
    @Malvolio Elm is a full functional programming language, so it should lend itself just fine for compilers (this is a traditional claim of functional languages). But Elm is a language that focusses on GUIs, so right now the focus for libraries is just not in the right place for it to be a great compiler language. It could become that in the future... – Apanatshka Nov 27 '15 at 20:50
5

There is a start in that direction, with an Elm parser written in Elm (although not updated yet to 0.18)

zaboco
  • 2,798
  • 1
  • 20
  • 16
4

As of 2017, although the official compiler remains the only complete Elm compiler as far as I know, this has been converted to JavaScript, meaning it can now be run from Elm and in the browser. This means the major advantage described above of writing the Elm compiler in Elm now seems less relevant. You can see an example of how this has been used to compile Elm in the browser here.

Bob Whitelock
  • 167
  • 3
  • 12
3

Today in 2019 there is a non official Elm compiler written in Elm in construction. It currently targets Elm 0.19.

Pascal Le Merrer
  • 5,883
  • 20
  • 35