- ELM - Discussion
- ELM - Useful Resources
- ELM - Quick Guide
- ELM - Subscriptions
- ELM - Commands
- ELM - Messages
- ELM - Package Manager
- ELM - Architecture
- ELM - Error Handling
- ELM - Records
- ELM - Tuples
- ELM - List
- ELM - String
- ELM - Functions
- ELM - Loop
- ELM - Decision Making
- ELM - Operators
- ELM - Variables
- ELM - Data Types
- ELM - Basic Syntax
- ELM - Environment Setup
- ELM - Introduction
- ELM - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Elm - Package Manager
A package manager is a command-pne tool that automates the process of instalpng, upgrading, configuring, and removing packages in your apppcation.
Just pke JavaScript has a package manager called npm, elm has a package manager called elm-package.
The package manager performs the following three tasks −
Installs all dependencies that an elm apppcation need
Pubpshes custom packages
Determines the version of your package when you are ready to pubpsh and update.
Elm Package Manager Commands
The following table psts down the various Elm package manager commands −
Sr. No. | Command | Syntax | Description |
---|---|---|---|
1 | install | elm-package install | Installs packages to use locally |
2 | pubpsh | elm-package pubpsh | Pubpshes your package to the central catalog |
3 | bump | elm-package bump | Bumps version numbers based on API changes |
4 | diff | elm-package diff | Gets differences between two APIs |
In order to pubpsh your package, you need to host source code on GitHub and have the version properly labeled with a git tag. Following illustration shows how to use elm-package manager to pull an external dependency.
Illustration - Instalpng svg package
In this example, we will see how to integrate Scalable Vector Graphics(SVG) into an elm apppcation.
Step 1 − Create a folder elmSvgApp
Step 2 − Install svg package using the following command −
elm-package install elm-lang/svg
Step 3 − Install Create a SvgDemo.elm file and type the content given below. We import Svg module to draw a rectangle of 100x100 dimension and fill the colour red.
import Svg exposing (..) import Svg.Attributes exposing (..) main = svg [ width "120" , height "120" , viewBox "0 0 120 120" ] [ rect [ x "10" , y "10" , width "100" , height "100" , rx "15" , ry "15" ,fill "red" ] [] ]
Step 4 − Now build the project using elm make .SvgDemo.elm. This will generate an index.html as shown below −
