0
votes

I'm just starting to learn Elm today, and I'm just trying to run a simple 'hello, world!' tutorial which I found online. I'm using a Mac with OS10.12 and I'm sure I've updated Node correctly but I keep getting the following error:

module Main exposing (..)

import Html exposing (text)


main =
    text "Hello, World!"

    parse error on input ‘exposing’
  |
1 | module Main exposing (..)
  |             ^^^^^^^^
[Finished in 0.3s with exit code 1]

I'm using Sublime text editor and I'm pretty sure I read all the install and setup instructions properly, the problem I'm having is that if I don't include that top line 'module Main exposing (..)' then the build command automatically includes that line and then throws this parsing error. How do I fix this, and why does the builder automatically add a line it doesn't like?

1
What version of Elm compiler are you using? - Emmanuel Rosa
@EmmanuelRosa 0.18.0 - Michael Vannucci
That syntax is correct. What command are you using to compile the program? - Emmanuel Rosa

1 Answers

0
votes

If you don't add a module declaration, Elm will use this one instead:

module Main exposing (..)

Elm expects this module to be in a file called Main.elm. Are you sure that your file is named Main.elm. Make sure you capitalize the name of the file: Main.elm not main.elm.

You can call it however you want...

module Hello exposing (..)

... but then this declaration should be in a file Hello.elm

It could help us, if you could post the contents of your elm-package.json file and the folder structure of the directory you started working in.

If you just want to get started, it might be a good idea to write your first Elm program in the online editor

It takes away a bit of the hassle of setting up a development environment if all you want to do is get to know Elm and decide if you like it.

There is another online editor for Elm. This instance already has the program you were trying to compile inside: https://ellie-app.com/3LBvgqYfGa1/0