Code Monkey home page Code Monkey logo

elchemy's Introduction

Wende's GitHub stats

elchemy's People

Contributors

baransu avatar colinbankier avatar gitter-badger avatar justgage avatar kevgathuku avatar latachz avatar littlestudent avatar matsubara0507 avatar nathanielknight avatar shalokshalom avatar wende avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elchemy's Issues

Add support for module metacode

Example

meta = [
  "use GenServer",
  "defstruct [:something, :else]
]

->

use Genserver
defstruct [:field1, :field2, field3: "default")

Add support for function documentation

Add:

Example:

{-| my function that is awesome -}
function : Awesome
function = Awesome

->

@doc "my function that is awesome"
@spec function :: :awesome
def function(), do: :awesome

This is an AST job because elm-ast sees no difference between block and regular comments

Change defcurry to def and curry/arity

Change defcurry to something nicer like for example:

a b c d = 10

->

curry a/3
def a(b, c, d), do: 10

Or automatically generate curried functions in @before_compile macro

Add support for Elm doctests (cause they're cool)

That would make testing with Elmchemy much easier

Example:

{-| Extract the first element of a list.

    head [1,2,3] == Just 1
    head [] == Nothing
-}
head : List a -> Maybe a
head list =
  case list of
    x :: xs ->
      Just x

    [] ->
      Nothing

->

@doc """
 Extract the first element of a list.

    iex> head.([1,2,3])
    1
    iex> head.([])
    nil
"""
@spec head : List a -> Maybe a
def head([x | xs]) do
  x
end
def head([]) do
  nil
end

Support returning unfinished functions

Right now specs behave incorrectly when we define a function without taking all of the parameters

Example:

someFun : Int -> String
someFun = 
  to_string

->

@spec some_fun(integer) :: String.t
def some_fun() do
  to_string
end

While it's perfectly fine syntax used very often to make default arguments

Add support for all autoimported Elm standard functions

From https://github.com/elm-lang/core#default-imports :

  • import Basics exposing (..) #25
  • import List exposing ( List, (::) ) #60
  • import Maybe exposing ( Maybe( Just, Nothing ) ) #61
  • import Result exposing ( Result( Ok, Err ) ) #62
  • import String #63
  • import Tuple #64
  • import Debug #65
  • import Platform exposing ( Program )
  • import Platform.Cmd exposing ( Cmd, (!) )
  • import Platform.Sub exposing ( Sub )

Example:

a >> b >> c

->

fn arg -> arg |> a |> b |> c end  

Add support for receive function

How to process messages is still up to a debate:

Temporary solution:

Example:

case receive of
  Msg a -> 1

->

receive do
  {:msg, a} -> 1

But since it's impure, unidiomatic, and totally forbids a case of after block it should be discussed and redeveloped after

Smart type aliases

Add:

Example:

type State a = List a | Map a
fun : State a

->

@spec fun(list(a) | %{})

Add support for simple Structs

Add: Simple structs (more than one field is not yet support in ast parser)

Example:

point = {x = 1}
{ point | x = 2 }

->

point = %{x => 1}
%{ point | x => 2 }

Make tuples in lists work correctly

Add:

Example:

[(1,1), (1,2)]

->

[{1,1}, {1, 2}]

instead of

[1,1, {1, 2}]

The cause of that is that Lists and Tuples are implemented on binary operator , instead of being parsed as an entity

Typing failure

So, there appears to be a slight typing failure. :-)

Example:

module Stack exposing (..)

type alias TestRecord =
  { int : int
  , float : float
  }

blah : TestRecord
blah =
  42

blorp =
  blah.x

->

# Compiled using Elmchemy v0.0.17
defmodule Stack do
  use Elmchemy

  @spec blah :: %{int: any, float: any}
  curry blah/0
  def blah() do
    42
  end

  curry blorp/0
  def blorp() do
    blah.x
  end

end

As an example, my MLElixir project (which puts a strongly-typed ML face on Elixir, it is not a released project, just something I screw around with for fun, its errors are also very low level and not prettied up at all) compiles the similar code as the above Elm:

iex> import MLElixir
MLElixir
iex> defmlmodule Stack do
...>   type test_record = %{
...>     int: integer,
...>     float: float,
...>   }
...>
...>   let blah | test_record = 42
...>
...>   let blorp = blah.x
...> end

Gives this:

** (throw) {:NO_TYPE_RESOLUTION, %TypedElixir.Type.Const{const: :integer, meta: %{values: '*'}}, %TypedElixir.Type.Const{const: :integer, meta: %{values: '*'}}, %TypedElixir.Type.Record{labels: [int: %TypedElixir.Type.Const{const: :integer, meta: %{}}, float: %TypedElixir.Type.Const{const: :float, meta: %{}}], meta: %{}}}

Which is entirely expected, but currently the above elm code is working in elmchamy when it absolutely should not.

Looking forward to this being developed out. :-)

Write tests for already existing features

  • Code

    • Tuples
    • Atoms
    • Type Applications / Tuples
    • Records
    • Strings, Integers, Lists, Floats
    • Function Declarations
    • Function Applications
    • Module definition, function extraction, and elixir module meta code
    • Typespecs and type aliases ( #13 )
  • Standard Library

    • - String module
    • - Basics module
    • - List module
    • - Maybe module

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.