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
10
votes
1 answer

Range expressions in Elm

Elm supports [1..100], but if I try ['a'..'z'], the compiler gives me a type mismatch (expects a number, gets a Char). Is there any way do make this work?
rausch
  • 3,148
  • 2
  • 18
  • 27
10
votes
2 answers

Elm "type" syntax - where is value coming from?

I am very new and currently trying to learn Elm. I am coming from JS/React and haven't had any previous RFP experience. I am in the Guide right here: http://guide.elm-lang.org/architecture/user_input/text_fields.html The part I have problems with is…
MoeSattler
  • 6,684
  • 6
  • 24
  • 44
10
votes
1 answer

Type annotations in Elm REPL

I am both an Elm and a functional programming newbie, and never worked with Java seriously. I'm working my way through Elm docs, and playing with the REPL, trying to understand type annotations. They seem pretty useful things: type alias Point = {…
Dmitri
  • 2,658
  • 2
  • 25
  • 41
10
votes
1 answer

How to link keyboard press to action

I'm getting the hang of Elm but I keep struggling with signals and keyboard presses. The code below is an example of the start-app package. I would like to have that when I press the spacebar that the counter is incremented. How is this done in the…
Stanko
  • 4,275
  • 3
  • 23
  • 51
10
votes
1 answer

How to create a Date variable in Elm

I want to hardcode a date in a record in elm. The record signature is type alias Record = { .., startDate : Date, .. } On my code I am doing record = { .., startDate = Date.fromString "2011/1/1", .. } The problem is that the Record type expects a…
Batou99
  • 869
  • 10
  • 19
10
votes
4 answers

How do you create stateful, modular, self-contained web components in Elm?

Suppose you want to create a UI which has 3 buttons. When you click in one of them, the others are released. In JavaScript, you could write: var elements = ["Foo","Bar","Tot"].map(function(name){ var element = document.getElementById(name); …
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
10
votes
4 answers

Elm compiler in Elm?

Almost every compiled language has a version of its compiler written in the language. Is there not an Elm compiler written in Elm?
Michael Lorton
  • 43,060
  • 26
  • 103
  • 144
10
votes
1 answer

How do I partially apply an infix function like Basics.+?

All of the examples I've seen so far create a "wrapper" function around Basics.+ and then partially apply that: sum x y = x + y plusOne = sum 1 However, I'm sure that there's a way to avoid the extra wrapping.
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
10
votes
3 answers

Hide a component when clicked outside

What would be the right way to handle a click outside of a single component that is supposed to hide this component? Example of such component might be a dropdown menu, a datepicker and the like. We typically expect them to hide when we click…
ave
  • 18,083
  • 9
  • 30
  • 39
10
votes
6 answers

How to remove an item at a given index from Array/List in Elm?

What is the most elegant way to remove an item at index i in a given Array? In a given List?
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
10
votes
1 answer

In Elm, why is this an Int-Float type mismatch?

I am new to elm, and functional programming in general. I was getting a puzzling type mismatch when doing division with a call to 'show'. This code produces the mismatch: import Graphics.Element exposing (..) columns = 2 main = placePiece…
Tony
  • 388
  • 3
  • 11
9
votes
2 answers

What does pipe `|` operator do in case expression of elm-lang?

I have this following code snippet in my Elm code: type alias Model = { content : String } update : Msg -> Model -> Model update msg model = case msg of Change newContent -> { model | content = newContent } What does { model |…
Saurabh kukade
  • 1,608
  • 12
  • 23
9
votes
1 answer

How to display a round image in elm with elm-ui?

I´m playing around with elm-ui and I´m trying to achieve a (in my opinion) easy task but I´m struggling. I would like to display a round image like we all know it from contact forms on iOS or several other platforms. As far as I know there are two…
JakobFerdinand
  • 1,087
  • 7
  • 20
9
votes
1 answer

Install elm package with a specifying version?

I am doing an Elm's tutorial. By that, the package elm/http is version 1.0.0. But when I installed, the current version is 2.0.0. And I don't how to install the package with a specifying version(here is elm/http 1.0.0). I tried to modify the version…
bird
  • 1,872
  • 1
  • 15
  • 32
9
votes
2 answers

Is it possible to show Elm's Debugger while using elm reactor?

When using elm reactor, it works great but doesn't seem to provide a way to show the Debugger, to explicitly see the state of the model after each update. elm reactor --debug doesn't work, I don't see an option in the UI, and didn't see it mentioned…
Robert K. Bell
  • 9,350
  • 2
  • 35
  • 50