Skip to content

wende/scalixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scalixir

Scala syntax in Elixir!

image

On the left hand side Scalixir On the righthand Elixir equivalent

Features

  • { and } instead of do and end - No more tedious block separators!
  • ( and ) instead of { and } for tuples. Just because. And also for easier implementation of the feature above
  • Single line defs declarations with =

Incoming features

  • Lambda expressions { _ * 2 }
    • No more Enum.map fn a -> a * 2 end. Now its time for Enum.map {_ * 2}
    • Imagine a world where |> (&(&1 * &2)).() becomes |> {_ * _}.()

Instalation

Install Scalixir globally with

mix archive.install https://github.com/wende/scalixir/releases/download/v0.1/scalixir-0.0.1.ez

Then add it yo your project by adding these two lines to your Mix.exs file

def project do
    [app: :my_app,
     ...
     compilers: [:scalixir, :yecc, :leex, :erlang, :elixir, :app],
     elixirc_paths: ["lib", ".sex"]
    ]
  end

Now you can create *.sex files anywhere in your project and have fun with Scalixir

Example file

# Brackets instead of do/end blocks
defmodule MyModule {
  def somefunction(a, b \\ 10)
  def somefunction(a, b){
    case File.read("somefile"){
      # Parenthesis for tuples
      (:ok, content) -> content
      _ -> :not_ok
    }
  }
  def somefunction(a, 5){
    # Nothing yet here. But it will look like Enum.map a, { _ * 5 }
    Enum.map(a, fn b -> b * 5 end)
  }

  defmacro something(a, b){
    IO.puts "hey"
  }

  defmacrop deffun(){
    quote{
      def yo(){
        :yo
      }
    }
  }

  # Single line defs declarations with `=`
  defp two() = 2
}

About

Pet project of Scala syntax atop of Elixir

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages