Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asummers/erlex
Convert Erlang style structs and error messages to equivalent Elixir.
https://github.com/asummers/erlex
dialyxir dialyzer elixir elixir-lang erlang
Last synced: about 2 months ago
JSON representation
Convert Erlang style structs and error messages to equivalent Elixir.
- Host: GitHub
- URL: https://github.com/asummers/erlex
- Owner: asummers
- License: other
- Created: 2018-07-22T02:42:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-26T15:32:49.000Z (8 months ago)
- Last Synced: 2024-10-16T01:43:43.171Z (2 months ago)
- Topics: dialyxir, dialyzer, elixir, elixir-lang, erlang
- Language: Elixir
- Size: 77.1 KB
- Stars: 34
- Watchers: 3
- Forks: 16
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
README
[![Hex version badge](https://img.shields.io/hexpm/v/erlex.svg)](https://hex.pm/packages/erlex)
[![Hex docs badge](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/erlex/)
[![Total download badge](https://img.shields.io/hexpm/dt/erlex.svg)](https://hex.pm/packages/erlex)
[![License badge](https://img.shields.io/hexpm/l/erlex.svg)](https://github.com/asummers/erlex/blob/master/LICENSE.md)
[![Build status badge](https://img.shields.io/circleci/project/github/asummers/erlex/master.svg)](https://circleci.com/gh/asummers/erlex/tree/master)
[![Code coverage badge](https://img.shields.io/codecov/c/github/asummers/erlex/master.svg)](https://codecov.io/gh/asummers/erlex/branch/master)
[![Last Updated badge](https://img.shields.io/github/last-commit/asummers/erlex.svg)](https://github.com/asummers/erlex/commits/master)# Erlex
Convert Erlang style structs and error messages to equivalent Elixir.
Useful for pretty printing things like Dialyzer errors and Observer
state. NOTE: Because this code calls the Elixir formatter, it requires
Elixir 1.6+.## Documentation
[Hex Docs](https://hexdocs.pm/erlex).## Changelog
Check out the [Changelog](https://github.com/asummers/erlex/blob/master/CHANGELOG.md).
## Installation
The package can be installed from Hex by adding `erlex` to your list
of dependencies in `mix.exs`:```elixir
def deps do
[
{:erlex, "~> 0.2"},
]
end
```## Usage
Invoke `Erlex.pretty_print/1` with the input string.
```elixir
iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(),'Elixir.Keyword':t() | map()) -> 'Elixir.Plug.Conn':t()"
iex> Erlex.pretty_print(str)
(Plug.Conn.t(), binary() | atom(), Keyword.t() | map()) :: Plug.Conn.t()
```While the lion's share of the work is done via invoking
`Erlex.pretty_print/1`, other higher order functions exist for further
formatting certain messages by running through the Elixir formatter.
Because we know the previous example is a type, we can invoke the
`Erlex.pretty_print_contract/1` function, which would format that
appropriately for very long lines.```elixir
iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(),'Elixir.Keyword':t() | map(), map() | atom(), non_neg_integer(), binary(), binary(), binary(), binary(), binary()) -> 'Elixir.Plug.Conn':t()"
iex> Erlex.pretty_print_contract(str)
(
Plug.Conn.t(),
binary() | atom(),
Keyword.t() | map(),
map() | atom(),
non_neg_integer(),
binary(),
binary(),
binary(),
binary(),
binary()
) :: Plug.Conn.t()
```## Contributing
We welcome contributions of all kinds! To get started, click [here](https://github.com/asummers/erlex/blob/master/CONTRIBUTING.md).
## Code of Conduct
Be sure to read and follow the [code of conduct](https://github.com/asummers/erlex/blob/master/code-of-conduct.md).