elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
174 stars 17 forks source link

Missing module error message #50

Open dasch opened 9 years ago

dasch commented 9 years ago

This is something I ran into when doing the Elm architecture tutorial. I've removed all extraneous code, but this is something that actually took me a while to figure out.

  1. You start writing your app: echo "import Html" > Main.elm.
  2. You try to compile elm make Main.elm.
  3. You become sad:

    $ elm make Main.elm
    Error when searching for modules imported by module 'Main':
       Could not find module 'Html'
    
    Potential problems could be:
     * Misspelled the module name
     * Need to add a source directory or new dependency to elm-package.json

Suggesting that I do elm package install evancz/elm-html would have saved me quite some time. I initially assumed that the Html module would be part of the standard library (maybe it should?) and didn't know about the package system, nor that evancz/elm-html was the HTML library referenced in the tutorial.

Things that would've made me happy:

  1. Having more stuff in the stdlib.
  2. Searching the available packages automatically and suggesting ones that expose the missing module. Maybe rank by popularity.
jvoigtlaender commented 9 years ago

Would you have been saved that trouble if you had first read http://elm-lang.org/get-started?

dasch commented 9 years ago

Nope. I was specifically drawn to the Elm Architecture Tutorial.

jvoigtlaender commented 9 years ago

I understand that. My question was meant as: If you had read that page first (specifically the first few sections of it, describing the Elm tools), for example if the Elm Architecture Tutorial had pointed you to that part (which it currently doesn't), would you still have struggled so much?

For example, you wrote you didn't know about the package system. The get-started page would have introduced it to you.

I'm just trying to find out whether the get-started page would have helped you, not admonishing you for not having read it. :smile:

dasch commented 9 years ago

I think maybe the tutorial should be more specific about the level of proficiency expected of the reader – from the tutorial:

If you are new to reading Elm code, check out the language docs which covers everything from syntax to getting into a “functional mindset”. The first two sections of the complete guide will get you up to speed!

I read the syntax stuff (and having written a bit of Haskell that wasn't much of a problem) but there were no references to the packaging stuff. When doing a tutorial I prefer typing everything myself rather than cloning some pre-made repo, so including the steps required to get started using the "Architecture" toolset would be nice. Since they're not part of the language, but very much seem to be part of the architecture (at least as sane defaults) it makes sense to me to include that information directly in the tutorial.

jvoigtlaender commented 9 years ago

Yeah, the "first two sections of the complete guide" do not give that information about packages, so that seems to claim too much. If the get-started page (or the part of it that speaks about the Elm tools and how they cooperate) were included in the "complete guide", that might become different.

But even then, what you say makes sense: The tutorial itself could be made self-contained in that regard. Maybe it's time for a pull request to https://github.com/evancz/elm-architecture-tutorial/?

And that isn't to say that what you suggest in the issue here could not also be useful: to give the programmer a suitable hint concerning elm package install in that error message.

dasch commented 9 years ago

Yeah, both would be nice. There doesn't seem to be much consistency in how module and package names relate to each other – a package is essentially a Github repo namespaced with a username, right? In Ruby, I'm used to package names corresponding with the module name, even to the degree that there's a convention that a package foo-bar should be included as foo/bar, i.e. have the module Foo::Bar. This is all based on convention and the fact that package names are global.

Cypher1 commented 7 years ago

We should at the very least have the package name needed for installation listed (and document deprecation)

I'm was just trying to import Text and forgetting that it was deprecated (its still in the examples but not in the elm-lang packages).

Please let me know if this is not the case.