Write Elixir code using Elm-inspired syntax (elm-make compatible)
Elmchemy is a project with one idea in mind: Seamless acommodation of Elm-like language on Erlang VM.
You can test elmchemy
online at:
https://wende.github.io/elmchemy/stable/
CAVEAT: Web version does not do any type checking. It only parses syntax. For full type and syntax checking run the CLI version
Install elmchemy
globally with
npm install -g elmchemy
Then in root of your project do:
elmchemy init
And follow the instructions
elmchemy
will find all *.elm
files specified in elmchemy_path
and compile it into corresponding *.ex
files in lib
directory.
You can override output directory specifing elixirc_paths
.
npm install -g elmchemy
Usage
elmchemy compile source_dir output_dir
git clone https://github.com/wende/elmchemy.git
cd elmchemy
make compile
./elmchemy compile source_dir output_dir
and
make dev
To launch and test the web demo
- Everyone is welcome to contribute
- Refer to http://bogdanp.github.io/elm-ast/example/ to have better understanding of parsed tokens.
- Fully readable and indented elixir code generated from compilation
- Seamless and stressless interop with existing Elixir code, preferably with magically working type safety
- Full integration with entire elm syntax for editors and compilers magic
- Saving and reading from files
- Basic API (operators, functions, monadic types [Maybe, Just etc])
- Simple Elixir/Erlang interop
- Compiler built-in into elixir ecosystem
- You like types
- But even more you prefer compile-time errors over run-time error
- You prefer
add b c = b + c
overdefp add(a, b), do: b + c
- You like curry
- You think failing fast is cool, but not as cool as not failing at all
- 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 weaken
You can, but nice and dandy compile tools are still on their way
The output files of Elmchemy 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)
Also auto-generated typespecs are on their way.
You might need some configuration files to compile your project, but if you don't do git add --all
before every commit you'll be fine.
The answer is 42
Definitely. Yes. Please do.
You're a nosy one, aren't you?
Elmchemy represents all type constructors as snake cased atoms, and all type applications as tuples.
Which means that MyType 42 "Fourty two" Error
in Elm equals to {:my_type, 42, "Fourty Two", :error}
in Elixir.
What means there's an additional premise to have in mind that even though in Elm MyType 1 == (MyType, 1)
are two completely different things, in Elmchemy they're not. They're exactly the same. Which is {:my_type, 1}
. You shouldn't be using that in a code though since it's considered bad design
Not yet. You will be able to use Elm libraries that don't have native modules or ports
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. Just remember to wrap them in as small chunks as possible to not sacrifice any type safety.
Unfortunatelly you can't write any macros with do..end
blocks yet. You can write any out of function oneliners using Module meta feature:
meta =
[ "use GenServer" ]
So you want to write an Elm-like code, that will manipulate Elixir code, which generates and Elixir code that manipulates Elixir code? How about no?
Ironically, no, you don't. Elmchemy is written entirely in Elm, which means the compiler is in JavaScript.
But it's nice to use elm-make
to check your type safety from time to time.