Git Product home page Git Product logo

Comments (3)

Kurren123 avatar Kurren123 commented on August 18, 2024 2

+1 I struggled with this quite a bit when starting off. Only issue I'm thinking is that if you have something like

import Element
import Element.Background
import Element.Border

Is there a risk that beginners will just copy the whole thing into their module when they only need import eg Element?

from package.elm-lang.org.

rlefevre avatar rlefevre commented on August 18, 2024

I think the risk is high that beginners will copy the whole thing indeed, and because a lot of code examples assume exposing (..), particularly core libraries, this would not help much anyway.

Also, with regard to the examples above, the 4th line of elm/html documentation shows an import example:
https://package.elm-lang.org/packages/elm/html/latest/

Idem for elm-ui in the example just after the introduction:
https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/

If this did not help, why adding them again in the About page would?

In my opinion, they are better illustrated by code examples that include the import directives to show why the names are qualified, or not, or with an alias.

But to explain them at first, I think it would be better to fix the "Using Packages" link and explain how to install and import in this documentation (including as and exposing (..)).

from package.elm-lang.org.

lucamug avatar lucamug commented on August 18, 2024

Yes, sometime package authors add example that also include the imports, but it is not always the case, so I think an example generated automatically could be a safer approach.

Having begineers copying all the imports, even if not necessary, seems to me a minor issue compared to have them struggling in making their code to work. At least the code is running. They will eventually learn and most IDE now have warnings for unused imports.

About explaing about importing modules, this could be a good target: https://elm-lang.org/docs/syntax#modules

from package.elm-lang.org.

Related Issues (20)

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.