Giter VIP home page Giter VIP logo

erlex's Introduction

Hex version badge License badge Build status badge Code coverage badge

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.

Changelog

Check out the Changelog.

Installation

The package can be installed from Hex by adding erlex to your list of dependencies in mix.exs:

def deps do
  [
    {:erlex, "~> 0.2"},
  ]
end

Usage

Invoke Erlex.pretty_print/1 with the input string.

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.

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.

Code of Conduct

Be sure to read and follow the code of conduct.

erlex's People

Contributors

asummers avatar barthez avatar evnu avatar jeremyjh avatar pragtob avatar smaximov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.