npm install -g elchemy
Elchemy lets you write simple, fast and quality type safe code while leveraging both the Elm's safety and Elixir's ecosystem
CAVEAT: Web version does not do any type checking. It only parses syntax. For full type and syntax checking run the CLI version
- Type inference: Powerful type inference means you rarely have to annotate types. Everything gets checked for you by the compiler
- Easy and type-safe interop: You can call Elixir/Erlang without any extra boiler-plate. All the calls you make are checked in terms of type-safety as thoroughly as possible
- All the best of Elm and Elixir: Elchemy inherits what's best in Elm - type safety, inference and extreme expressiveness, but also what's best in Elixir - Doc-tests, tooling and obviously the entire BEAM platform.
- Nearly No runtime errors - Elchemy's type system eliminates almost all runtime errors. With a shrinking set of edge cases, your entire app will be as safe as the parts written in Elixir are.
- Beatiful and fully readable output - All of the code produced by Elchemy can be easily read and analyzed without taking a single look at the source code
- Numerous output code quality and performance improvements
- Functions can be shadowed (Elm behaviour over Elixir's behaviour)
- Support for Elixir 1.5
- Elchemy can compile itself without any parsing or compiling errors. (2 out of 3 steps complete)
- New name
Elchemy
(without 'm')- New repository and std lib name
- New compile tools commands (All commands can be still called with an old name and it will be supported for next couple of versions)
- Native modules
- Imported types and type aliases
- Type polimorhpism
- Advanced syntax and bugfixes
- node@5+
- elm-lang@0.18
- elm-github-install@0.1.2 - Compiler will install it automatically for you, if you don't have it yet
Install elchemy
globally with
npm install -g elchemy
Then in root of your project do:
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 specifing elixirc_paths
.
npm install -g elchemy
Usage
elchemy compile source_dir output_dir
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 demo
- 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, Firefox
- 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
If anything doesn't work, try
npm install -g elchemy
elchemy clean
elchemy init
mix test
first
- 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 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 it's done
Definitely. Yes. Please do.
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 "Fourty two" Error
in Elchemy equals to {:my_type, 42, "Fourty Two", :error}
in Elixir.
As long as they don't use any Native modules, Ports or Elm runtime they can be safely imported and used
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 readbility it's advised no to use ffi
calls if not necessary and always document and doctest them.
Unfortunatelly 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:
{- ex
code_here
-}
But it's a last resort solution and shouldn't ever be abused.
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?
Elchemy uses Elm to typecheck your program. Although it is possible to use it without Elm on your machine it's not advised.
- Parser - 98% of Elm's syntax
- Compiler - 97% (still needs some nicer solutions of code generation plus we might come out with some new nice ideas)
- Elchemy-core - 93 ( We have Basics, Debug, Char, String, List, Result, Tuple, Set, Bitwise, Dict and Maybe)
- Interop with Elixir - 90% - All of the interop is mature and type-safe-verified based on specs
- Ideology - 60% - We've got a pretty solid idea of where Elchemy is going
- Documentation - 50% - There's couple of tutorials online and example projects. Nothing fancy yet, though
- Elchemy-effects - 15% - 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
- Elchemy-core for Erlang VM - 5% (Everything for os related tasks like filesystem, OTP goodies etc has to be done)