wende / elchemy

Write Elixir code using statically-typed Elm-like syntax (compatible with Elm tooling)

Home Page:https://wende.github.io/elchemy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing Elm Issue (Medium First Tutorial)

kexoth opened this issue · comments

I tried the first tutorial on Medium and once I add any piece of additional code, any kind of function, the sum function in the given context:

{-| Returns the sum of every integer in the function

    Hello.sum [ 1, 2, 3, 4, 5 ] == 15
    Hello.sum [ 10 ] == 10
    Hello.sum [] == 0

-}
sum : List Int -> Int
sum list =
    case list of
        first :: rest ->
            first + (sum rest)

        [] ->
            0

I get this output on mix test:

iMac:article_example_elchemy kex$ mix test
warning: redefining module ElchemyInit (current version defined in memory)
  elchemy.exs:1

-- Copying Elixir native files --
-- Compiling Elm files --
----------
Type Checking elm/Hello.elm
Success! Compiled 1 module.
Successfully generated .elchemy/output_tmp.js
#1
-- Linking files --
Number of files: 2
Parsing 1/2 # : "elm/Hello.elm"
Parsing 2/2 # : ""
Compiling 2/2 # : "elm/Hello.elm"
/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:583
                throw new Error(
                ^

Error: Ran into a `Debug.crash` in module `ExStatement` on line 213
The message provided by the code author is:

    To be able to export it, you need to provide function type for `sum` function in module "Hello"
    at /Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:583:9
    at Function.func (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:19365:10)
    at A2 (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:92:11)
    at Function.func (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:19752:13)
    at A2 (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:92:11)
    at Function.func (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:1232:12)
    at A3 (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:98:11)
    at Function.func (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:19857:11)
    at A2 (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:92:11)
    at compileWithIndex (/Users/kex/.asdf/installs/nodejs/6.11.4/.npm/lib/node_modules/elchemy/elchemy.js:20025:10)
** (Mix) Compilation error

I've tested the same code in the online editor & it works as expected, but not in any of my projects, either created via mix new & then elchemy init nor elchemy new.

Any other piece of setup which this tutorial has is the project function in mix.exs which looks like this on my side:

  def project do
    [
      app: :article_example_elchemy,
      version: "0.1.0",
      elixir: "~> 1.6",
      start_permanent: Mix.env == :prod,
      deps: deps()
    ]
    |> Code.eval_file("elchemy.exs").init
  end

I also provided my project here on Github.

@kexoth
Yes, it'd appear that there was a bug that sneaked in with version 6.4.
I will try to find and fix it, until then use previous version with:

npm install -g elchemy@0.6.3

And repeat elchemy init in your project

Ok so it seems that the fix to #290 (PR #291) by mistake didn't make it to the version 0.6.4
It's fixed and on master but not released yet. I'll try to release it when I get more stable internet access later this week

Fixed with 0.6.6

Everything works now, great job!
I had a look at your commits, didn't understood the issue at this point, but I hope in future I could 🤓

So the problem was fixed some time ago. It was a problem of favoring cached files over modified files (obviously an error)
But for some reason I didn't include it in a latest release. It's there now 👍