Write Elixir code using Elm-inspired syntax (elm-make compatible)
npm install elmchemy
#### Quick install
``shell`
npm install -g elchemy
)
- elm-github-install@0.1.2 - Compiler will install it automatically for you, if you don't have it yet$3
Install elchemy globally with`shell
npm install -g elchemy
`Then in root of your project do:
`shell
elchemy init
`And follow the instructions
elchemy will find all .elm files specified in elchemy_path and compile it into corresponding .ex files in lib directory.You can override output directory specifying
elixirc_paths.$3
`shell
npm install -g elchemy
`
Usage
`
elchemy compile source_dir output_dir
`$3
- Atom with elixir-language and atom-elixir or elixir-ide for Elixir; and language-elm + elmjutsu for Elchemy.
- Visual Studio Code with vscode-elixir, vscode-elixir-ls and vscode-elm$3
`
git clone https://github.com/wende/elchemy.git
cd elchemy
make compile
./elchemy compile source_dir output_dir
`
and
`
make dev
`
To launch and test the web demoContributing Guide
- Everyone is welcome to contribute
- Refer to http://bogdanp.github.io/elm-ast/example/ to have better understanding of parsed tokens.
- Refer to https://wende.github.io/elchemy/stable/ to know the latest development version of the parser
- For project management we use ZenHub. You can see the Kanban board, card estimates and all the reports by installing a browser extension here: Opera/Chrome, FirefoxTargeted values:
- Fully readable and indented elixir code generated from compilation
- Seamless and stress less interop with existing Elixir code, preferably with magically working type safety
- Full integration with entire elm syntax for editors and compilers magicTroubleshooting
If something doesn't work, try
`
npm install -g elchemy
elchemy clean
elchemy init
mix test
`
firstFAQ
Why would I want to use that?
- You like types
- But even more you prefer compile-time errors over run-time error
- You prefer add b c = b + c over defp add(a, b), do: b + c
- You like curry
- You think failing fast is cool, but not as cool as not failing at allWhy wouldn't I want to use that?
- Your project relies on die-hard battle tested libraries, and you despise any versions starting with 0
- You're afraid that when you learn what Monad is your mustache will grow, and eyesight weakenCan I use it in already existing Elixir project?
You can, but nice and dandy compile tools are still on their wayWill my employer notice I'm having an affair with Elchemy?
The output files of Elchemy treat the code readability as a first class citizen. The code is meant to be properly indented, the comments aren't omitted, and the code is optimized as hard as it can ( f.i case clauses reduce to function overloads)When will Elchemy become 1.0.0?
When it's doneCan I contribute?
Definitely. Yes. Please do.How are types represented?
You're a nosy one, aren't you?
Elchemy represents all type constructors as snake cased atoms, and all type applications as tuples.
Which means that MyType 42 "Forty two" Error in Elchemy equals to {:my_type, 42, "Forty Two", :error} in Elixir.Can I use already existing Elm libraries with Elchemy?
As long as they don't use any Native modules, Ports or Elm runtime they can be safely imported and usedCan I use already existing Elixir libraries with Elchemy?
Yes. You can do an ffi call to any function in any module. Whether it's Elixir module, Erlang module, or even a macro you can include it in your code. Ffi calls are a treated specially in Elchemy, and they get generated test to analyze the types based on @specs, so that you don't compromise type safety for using Elixir code.
In order to increase readability it's advised not to use ffi calls if not necessary and always document and doctest them.But what about out of function macros? Like tests and
use Module?
Unfortunately you can't write any macros with do..end blocks yet. You can write any out of function code using an elixir inline code with:
`elm
{- ex
code_here
-}
`
But it's a last resort solution and shouldn't ever be abused.Can I define an Elixir macro in Elchemy?
So you want to write an Elm-like code, that will manipulate Elixir code, which generates an Elixir code that manipulates Elixir code? How about no?Do I need to have Elm installed to compile my
.elm` files with Elchemy?- Parser - 99% of Elm's syntax (see elm-ast)
- Compiler - 90% (Sophisticated incremental compilation. No support for Windows yet though (#287) also big reliance on unix tools (#288)
- Elchemy-core - 95% ( Everything covered except side effects and JSON Decoders)
- Interop with Elixir - 90% - Purity tests (#162) and handling of macro-heavy libraries (#276) to go
- Ideology - 70% - We've got a pretty solid idea of where Elchemy is going
- Documentation - 80% - There are two tutorials and a complete Gitbook documentation. Few entrance level tutorials though
- Elchemy-effects - 20% - You can't and shouldn't write anything with side-effects in Elchemy yet. We're working on finding the best solution for effects that would fit both Elm's and Elixir's community (see #297 for more info)
- Elchemy-core for Erlang VM - 5% (Everything for os related tasks like filesystem, OTP goodies etc are yet to be done)
- Tomasz Cichociński - @baransu
- Colin Bankier - @colinbankier
- Nathaniel Knight - @neganp