10
votes

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

Is there not an Elm compiler written in Elm?

4
I don't know how to prove a negative. The few documents I have found suggest that the compiler is written in Haskell. - Malvolio
github.com/elm-in-elm/compiler Original compiler was haskell. Now there is an elm compiler in elm. - Brenn

4 Answers

21
votes

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.

5
votes

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

4
votes

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.

1
votes

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