Elm 0.16
Warning: This page concerns Elm version 0.16. The information here is no longer correct for the current version of Elm.
For general questions about the current version see the main FAQ page.
Contents
Why does elm-repl (or elm-make) report “cannot find module ‘Html’”?
You need to install the Html module:
elm package install evancz/elm-html
Several modules are available by default in the base Elm tools but other common modules like Html have to be installed in the working directory before they can be used in elm-make, elm-repl, and elm-reactor.
How do I generate an Action as an Effect?
Effects.task (Task.succeed SomeAction)
Why isn’t my StartApp-based program running any tasks?
You need to set app.port
.
port tasks : Signal (Task.Task Never ())
port tasks =
app.tasks
Why doesn’t the <~
operator work?
It was removed in Elm version 0.16. You can still get it (or the equivalent andMap
) from
Signal.Extra
instead.
Why doesn’t my application get the initial value of Window.dimensions?
For example, given this:
modelInit = { window = (-1,-1) }
main = Signal.map Element.show model
model = Signal.foldp (\d s -> {s | window = d}) modelInit Window.dimensions
the displayed value will remain at “{ window = (-1,-1) }” until the window is resized, at which time the display tracks all changes.
This arises because Signal.foldp
does not use the initial value of its input signal (Window.dimensions
in this case).
One solution is to use the foldp'
function from the Apanatshka/elm-signal-extra package, as follows:
model = Signal.Extra.foldp' (\d s -> {s | window = d}) (\d -> { window = d }) Window.dimensions
Whereas foldp
takes an initial value parameter, foldp'
takes instead a function from the initial value of the input signal to the initial value returned by foldp'
.
Since StartApp uses foldp
this problem with initial values can arise when it is used. Also, the problem is not specific to Window.dimensions; it can arise for any input signal whose initial value is of interest.
Why is my app failing immediately saying “Cannot read property ‘make’ of undefined”?
That can happen if you write custom Javascript code to call Elm.embed()
or Elm.fullscreen()
and the application name used there (the first parameter) does not match the main module name.
For example, if Foo.elm contains the main
function for your app then your Javascript code should call it like this:
app = Elm.embed(Elm.Foo, ...)
If you use a name other than Elm.Foo
there you will likely get that “Cannot read property” error.