Home

Awesome

<p align="center"> <img src="https://github.com/wende/elchemy/blob/master/logo.png?raw=true" width="250" height="250"> </p> <p align="center"> <a href="https://join.slack.com/t/elchemy-lang/shared_invite/enQtNjMzMDI0NzM3MzQ3LWVmZDZkMzY3OWZkMzJlOGIzZjMzMjcwMDgzNDFlZDYzY2NiYzE0ZjdhOTRmMmMyMjRiOTUzNjhhNWQ1M2VlMGY"> <img src="https://img.shields.io/badge/chat-on%20slack-blueviolet.svg"> </a> <a href="http://elchemy.neontree.pl"> <img src="https://img.shields.io/badge/try%20now-online-yellow.svg"> </a> <a href="https://wende.gitbooks.io/elchemy/content/"> <img src="https://img.shields.io/badge/read-docs-informational.svg"> </a> <a href="https://medium.com/@krzysztof.wende/elmchemy-write-type-safe-elixir-code-with-elms-syntax-part-1-introduction-8968b76d721d"> <img src="https://img.shields.io/badge/getting-started-green.svg"> </a> <a href="https://travis-ci.org/wende/elchemy"> <img src="https://travis-ci.org/wende/elchemy.svg?branch=master"> </a> </p>

Quick install

npm install -g elchemy

What is it?

Elchemy lets you write simple, fast and quality type safe code while leveraging both the Elm's safety and Elixir's ecosystem

In case of any questions about the project feel free to submit them in Issues with Q&A label

Features

Maturity of the project

Usage

Prerequisites

Installation in an existing Elixir project

Install elchemy globally with:

npm install -g elchemy

Then, in the root directory 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 specifying elixirc_paths.

Installation as a standalone

npm install -g elchemy

Usage

elchemy compile source_dir output_dir

Recommended editors setup

Build from source

git clone https://github.com/wende/elchemy.git
cd elchemy
make compile
./elchemy compile source_dir output_dir

and

make dev

In order to launch and test the web demo.

Troubleshooting

If something doesn't work, try

npm install -g elchemy
elchemy clean
elchemy init
mix test

first

FAQ

Why would I want to use that?

Why wouldn't I want to use that?

Can I use it in already existing Elixir project?

You can, but nice and dandy compile tools are still on their way

Will 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?

Once it's done, so as it is supposed to be in the so called semantic versioning. :innocent:

Can I contribute?

Definitely. Yes. Please do. :two_hearts:

How are types represented?

You're a nosy one, aren't you? :smile: 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 used

Can 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:

{- ex
  *code_here*
-}

But it is 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?

Elchemy uses Elm to typecheck your program. It is possible to use it without Elm on your machine, while it's not advised.

Contributor credits:

Inspiration:

Contributing Guide

Targeted values: