Questions tagged [elm]

Elm is a functional programming language for writing web applications that can fully replace, or interoperate with, HTML/CSS/JavaScript.

Elm is a functional programming language that is interoperable with HTML/CSS/JavaScript. It is optimized for creating web UIs, supporting complex user input without using callbacks.

Key features

  • Static types with type inference, with the best compiler errors ever
  • No runtime exceptions
  • No null or undefined in the language
  • Enforces semver for all Elm packages (you must update version number if you make a breaking change)

Resources:

Elm Books

1885 questions
11
votes
2 answers

Is the signal system of Elm available as a Haskell library?

For the task I'm working on, the signal system of the Elm programming language seems to be an appropriate solution. But my pure computational functions are implemented in Haskell. Is there a Haskell library that would allow me to construct a signal…
imz -- Ivan Zakharyaschev
  • 4,921
  • 6
  • 53
  • 104
10
votes
2 answers

How to exit the elm repl?

I am learning Elm, and need to be able to exit the elm repl. I tried exit() like python, \q like postgres, typing just exit like MySQL, even :q like Haskell. The only thing I can do is close the terminal to exit, there has to be a better way.
james-see
  • 12,210
  • 6
  • 40
  • 47
10
votes
2 answers

Elm: attribute "onerror" adds "data-onerror" attribute instead

In Elm I have a simple image, and I want it to be replaced by some 'missing' image onerror. So I added an "onerror" attribute: img [ src "broken-link.png" , attribute "onerror" "this.onerror=null;this.src='missing.png';" ] [] However,…
The Oddler
  • 6,314
  • 7
  • 51
  • 94
10
votes
1 answer

Dict vs Record in elm

While implementing a simple app I ran into the problem of trying to update a nested record. I found a solution online but it really seems like a whole lot of bloated code. As I was looking for alternatives I found Dictionaries. This seem like a…
Nicola Pedretti
  • 4,831
  • 3
  • 36
  • 42
10
votes
2 answers

Converting List (Maybe a) to Maybe (List a) in Elm

What's a good way to convert List (Maybe a) to Maybe (List a) in Elm? The logic is simple: return Just (List a) if all items are Just a otherwise, return Nothing. Example 1: input: [ Just 1, Just 2, Just 3 ] output: Just [ 1, 2, 3 ] Example…
Alex
  • 1,574
  • 17
  • 36
10
votes
3 answers

How can I get window.location.href in Elm?

I have an index.html which contains my Elm app. The Elm app uses various GETs to an API served by the same server as the one that serves the index.html. Rather than hardcode the URLs in my Elm code for the GETs, e.g.: url = …
Robert
  • 1,530
  • 1
  • 16
  • 24
10
votes
1 answer

Load external data into Elm test suite

I am writing an Elm test suite and want to check a function's output using a list of known good input/output pairs, stored in an external file. I can choose the format of the external file, so I could use JSON for example, but I need to keep it…
spookylukey
  • 6,380
  • 1
  • 31
  • 34
10
votes
1 answer

Permission denied error while attempting to install elm with sudo on ubuntu

I am attempting to install elm on my machine (Ubuntu 16.04.2 LTS). Running $ npm install -g elm as per the instructions at that link, I get a permission error. So I try again with sudo, i.e. $ sudo npm install -g elm. This gives another permission…
mherzl
  • 5,624
  • 6
  • 34
  • 75
10
votes
1 answer

Elm: How does Debug.log work?

I'm logging the a and b values of a foldl. words = ["mate", "bro", "bruv"] sum2 = List.foldl (\a b -> Debug.log(toString <| a) Debug.log(toString <| b) a ) "guv" words It works as expected, but I can't understand…
Rich
  • 5,603
  • 9
  • 39
  • 61
10
votes
0 answers

Access Jupyter code-cell metadata in a kernel

I'm developing a Jupyter kernel for Elm, and I would like users to be able to split their code over multiple code cells. To do this, I plan to let the kernel accumulate code from multiple cells without compiling it. Once it has received all of the…
abingham
  • 1,294
  • 1
  • 10
  • 17
10
votes
1 answer

elm: define subscription port with no parameters

Is there a way to define a subscription port with no parameters in Elm? Something like: port updateTime : () -> Sub msg With this code, I'm getting the error that "Port 'updateTime' has an invalid type" With the code: port updateTime : (String ->…
Buda Gavril
  • 21,409
  • 40
  • 127
  • 196
10
votes
2 answers

Confused about "Html msg"

Consider this snippet: type alias Model = { x : Int } testFunc : Model -> Html String testFunc model = div [] [] I am very confused here. div is a function that returns a Html msg. But testFunc returns Html String. How does this compile?…
user3282666
  • 640
  • 1
  • 7
  • 21
10
votes
3 answers

Elm Http Request on Init

I'm pretty new to Elm, but slowly getting familiar with it. I'm doing some simple Http Requests, which are successful in every aspect (I get the data to display, etc.) For the moment I can only get my fetchData to trigger onClick, I would like to…
mmmaceo
  • 151
  • 1
  • 9
10
votes
2 answers

Passing multiple arguments to Javascript via port

I need to pass a few parameters to Javascript, but for a strange reason it does not compile. I started with: port check : String -> Cmd msg this works fine (as taken directly from JavaScript Interop). But when I am adding another parameter port…
Lukasz Guminski
  • 862
  • 7
  • 20
10
votes
1 answer

how to embedded video in elm application

I am embedding you tube videos in my elm sample application.So to implement i have write the elm video code [ embed [ attribute "-video" "", attribute "api" "1", attribute "height" "100%", href "//vimeo.com/111690998", attribute "iframe-id"…
Manu Chawla
  • 327
  • 1
  • 12