Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does `exposing (..)` mean in Elm?

Tags:

elm

I'm trying to understand the very first Elm example and it has this:

import Graphics.Element exposing (..)

What does exposing (..) mean?

like image 521
Terrence Brannon Avatar asked May 11 '15 16:05

Terrence Brannon


2 Answers

exposing (..) allows you to call all the functions in the package directly.

For example, if SamplePackage had the functions x and y, import SamplePackage would let you call SamplePackage.x and SamplePackage.y, while import SamplePackage exposing (..) would let you call x and y without specifying their containing package.

Note that import SamplePackage exposing (x) would let you call x directly, but you would still need to call y with SamplePackage.y. Likewise, import SamplePackage exposing (x, y) would let you call x and y, but not any other functions in the package.

like image 128
GreySage Avatar answered Oct 17 '22 20:10

GreySage


It means that you can access everything directly within the Graphics.Element module, without specifying the package first. Since this example only uses "show" and "Element", you could change the import line to:

import Graphics.Element exposing (Element, show)

And it will still work for this example.

like image 22
kaz Avatar answered Oct 17 '22 22:10

kaz