jcollard / elm-mode

Elm mode for emacs
GNU General Public License v3.0
375 stars 67 forks source link

load-elm-repl fails if there is no module declaration #29

Closed bremner closed 9 years ago

bremner commented 9 years ago

in some simple examples, e.g.

http://elm-lang.org/examples/hello-html

there is no module declaration, which makes elm--get-module-name fail

jcollard commented 9 years ago

Is this also the case if you try and load it from the command line?

bremner commented 9 years ago

Hmm. So maybe it's not reasonable to expect elm-mode to load the file, but a better error message would be good:

> import Hello
The module name is messed up for ././Hello.elm
  According to the file's name it should be Hello
  According to the source code it should be Main
 Which is it?
jcollard commented 9 years ago

Should be fixed. Let us know if there are any issues.

dyba commented 7 years ago

@jcollard I'm using version 0.20.3 of elm-mode and I'm encountering the same issue. Perhaps there was a regression? I've cloned the elm-architecture-tutorial, opened up a random file in the examples folder, attempted to load the file in a repl and got the error "Module declaration not found".

dyba commented 7 years ago

I went ahead and declared a module at the top of the file:

module Main

-- The rest of 02-fields.elm...

And I got this error:

---- elm-repl 0.18.0 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> :reset
Environment Reset
> import Main exposing (..) 
I cannot find module 'Main'.

Module 'Repl' is trying to import it.

Potential problems could be:
  * Misspelled the module name
  * Need to add a source directory or new dependency to elm-package.json

> 

I also tried renaming the file to Main.elm to match the name of the module but still no luck. I even tried

module Main exposing (..)

as mentioned in https://guide.elm-lang.org/reuse/modules.html, but still no luck getting the REPL to import my file for an interactive session.

achikin commented 6 years ago

I got the same error then trying to play with elm-architecture-tutorial

subfusc commented 6 years ago

Got the same when trying to load the repl standing in the first example from the introduction guide on elm-lang.org (https://guide.elm-lang.org/)