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
19
votes
5 answers

Work with elm and select

I try to understand how elm works with a custom example. durationOption duration = option [value (toString duration) ] [ text (toString duration)] view : Model -> Html Msg view model = Html.div [] [ h2 [] [ text "Month selector"] ,…
billyJoe
  • 2,034
  • 2
  • 24
  • 37
19
votes
3 answers

Is there a way to use a javascript library in elm?

I am working with Elm. I have read about ports in Elm and how they can help in sharing data/messages between Elm and Javascript. I am intending to work with a rich datetime library like moment.js. Suggest how to port moment.js or any other…
Gaurav Agarwal
  • 14,664
  • 4
  • 29
  • 41
18
votes
1 answer

Decode Json Array with objects in Elm

I recently tried to get data from server with Elm's Http module and i'm stuck with decoding json to custom types in Elm. My JSON looks like that: [{ "id": 1, "name": "John", "address": { "city": "London", "street": "A…
rubiktubik
  • 961
  • 2
  • 12
  • 28
18
votes
2 answers

Is there a way to generate an empty Html node in Elm-Html?

I'm writing a function that displays error messages, so in my view, I have something like div [] [ displayErrors model ] in the event that there are no errors, how can I make displayErrors return something that is interpreted as an empty Html…
jz87
  • 9,199
  • 10
  • 37
  • 42
18
votes
1 answer

Elm: How to decode data from JSON API

I have this data using http://jsonapi.org/ format: { "data": [ { "type": "prospect", "id": "1", "attributes": { "provider_user_id": "1", "provider": "facebook", …
Sebastian
  • 2,249
  • 17
  • 20
18
votes
4 answers

What is the correct way of initializing an elm application

The documentation for Elm's Random module states: A good way to get an unexpected seed is to use the current time. http://package.elm-lang.org/packages/elm-lang/core/1.1.0/Random I don't see however a good example of how to perform such…
zefciu
  • 1,967
  • 2
  • 17
  • 39
18
votes
1 answer

Does Functional Reactive Programming in JavaScript cause bigger problems with listener references?

In JavaScript the observer pattern is used quite often. There is one tricky thing with it and that's the references the subject keeps of the observers. They require cleanup. For regular applications I use the following rules of thumb: If the…
EECOLOR
  • 11,184
  • 3
  • 41
  • 75
17
votes
2 answers

Elm http request returns NetworkError for successful requests

I have a fair amount of experience building web apps with React but want to learn Elm. I've been banging my head against an HTTP request issue for a couple days now. I'm running an Elm app at localhost:8080 and my supporting API at localhost:8081.…
Michael Fox
  • 491
  • 5
  • 15
17
votes
1 answer

Understanding generic union types in Elm

I'm having some trouble understanding what exactly the Html msg type is, or how it gets used. I found this line of code in VirtualDom.elm, which Html msg seems to be an alias of: type Node msg = Node This looks like a generic union type with one…
yxrkt
  • 424
  • 4
  • 12
17
votes
3 answers

How do I add a second die to this elm effects example?

I am new to Elm and have been looking at the following example (note this is under the newer 0.17 architecture, where Action is now Command): http://elm-lang.org/examples/random There is a follow up challenge to add a second die to the example, so…
TonyM
  • 236
  • 1
  • 8
17
votes
3 answers

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

I'm trying to understand the very first Elm example and it has this: import Graphics.Element exposing (..) What does exposing (..) mean?
Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61
16
votes
1 answer

Assign a value in elm

This is a really noob question, i'm sorry but my search on the internet can't find the answer. I have the following code: -- MODEL type alias Model = Int model : Model model = 0 -- UPDATE type Msg = Increment | Decrement | Reset update : Msg…
Mr Giggles
  • 2,483
  • 3
  • 22
  • 35
16
votes
3 answers

Decode JSON into Elm Maybe

Given the following JSON: [ { "id": 0, "name": "Item 1", "desc": "The first item" }, { "id": 1, "name": "Item 2" } ] How do you decode that into the following Model: type alias Model = { id : Int , name : String …
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
16
votes
1 answer

What is an opaque type in Elm and why is it valuable?

I've used types before but don't know what an opaque type is. I've seen it mentioned as well. Is it better to expose an opaque type than a type alias?
Nathan
  • 1,762
  • 1
  • 20
  • 30
16
votes
2 answers

Elm: Json decoder timestamp to Date

I'm trying to convert a timestamp (ex: "1493287973015") from a JSON to a Date type. So far I created this custom decoder: stringToDate : Decoder String -> Decoder Date stringToDate decoder = customDecoder decoder Date.fromTime But it doesn't work…
Guilhem Soulas
  • 1,975
  • 2
  • 18
  • 30