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
1
vote
1 answer

Restrict Values of Type in Elm

I'd like to define a type that represents a unit vector. This is what I have currently: type UVec = UVec Float Float unit : Float -> Float -> UVec unit a b = let norm = sqrt (a^2 + b^2) in UVec (a/norm) (b/norm) While unit yields what…
user38602
  • 45
  • 3
1
vote
1 answer

how to create dynamic http body in elm

I am implementing the service where i have to create the dynamic http post request and my code is below. postRequest: Int -> Http.Request postRequest catId = let body = …
Manu Chawla
  • 327
  • 1
  • 12
1
vote
4 answers

import HTML.App as Html

The elm tutorial at http://guide.elm-lang.org/architecture/user_input/buttons.html has these lines: import Html exposing (Html, button, div, text) import Html.App as Html I do not understand what the name Html references as the result of these…
akonsu
  • 28,824
  • 33
  • 119
  • 194
1
vote
1 answer

How to make http request and decode response to concrete type in Elm 0.17?

I want to create a function that will make a request to the server and returns decoded value. I have custom headers within my request so I have to use Http.send function. So far I was able to create task getCurrentUser userId authToken err ok = …
ondrej
  • 967
  • 7
  • 26
1
vote
1 answer

getting failure Http.error while in browser network shows response

I am exploring ELM and trying to access web api. I followed the this link. I am able to hit my service and getting the response (Showing in browser network tab), but failure code portion is executing from elm update. Implementation ---Model type…
Manu Chawla
  • 327
  • 1
  • 12
1
vote
1 answer

Elm: making successive network requests

I am trying to learn elm from the past week and want build a simple Hacker News client by calling the official Hacker News API. I'm calling https: //hacker-news.firebaseio.com/v0/topstories.json to get the top stories which would return an array of…
dq-charlie
  • 227
  • 2
  • 7
1
vote
1 answer

How to get the value of a string in a case statement in elm

Consider the following. Why does it not work. And how could I make it work? type IntOrString = String | Int getInt : IntOrString -> String getInt intOrString = case intOrString of String -> intOrString Int -> toString…
Prabhjot
  • 39
  • 1
  • 4
1
vote
1 answer

How to use onWithOptions in Elm 0.17?

I have an application where I'm selecting some statuses. Initially, I had a code like this div [ classList [ onClick (SelectStatus (Just status)) ] But at some moment, I need to stop event propagation. I found that there is an onWithOptions…
ondrej
  • 967
  • 7
  • 26
1
vote
1 answer

Syntax Highlighting with Elm

I am writing a simple app that puts a syntax-highlighted block of code. For now I am using highlightjs do to the syntax highlighting for me. Why doesn't my call to highlightBlock work here? For careful readers: my choice of Model and Msg are…
john mangual
  • 7,718
  • 13
  • 56
  • 95
1
vote
1 answer

Stencil Buffering in elm-webgl

I'm trying to make a simple OpenGL program in elm-webgl. I took one of the examples that has a box that rotates around, and I wanted to use stencil testing to only render one row of pixels at a time. I was able to achieve drawing the line I wanted,…
emptyflash
  • 1,289
  • 9
  • 16
1
vote
1 answer

Strange compiler error in Elm

Given the code such as (imports are stripped for brevity): fn: List a -> List a -> Bool fn x y = x < y main = text (toString(fn [1,1] [1,2])) I got quite a strange error: The type annotation for `fn` does not match its definition. 15| fn:…
Tomas Kulich
  • 14,388
  • 4
  • 30
  • 35
1
vote
1 answer

Testing elm lib with local Native directory

How do we organize our test directory when developing some libraries that uses Native js code? I tried to work this out, but I'm blocked here, with this error at runtime when running test/test.sh: Elm.Native.Mylib = {}; ^ TypeError: Cannot read…
Cavet
  • 152
  • 8
1
vote
1 answer

Why is elm so picky about whitespace but only in certain cases?

Why does this code fail type SectionedItems s i = SectionedItems{ section : s, items : List i, subsections: List (SectionedItems s i) } si1 : SectionedItems String String si1 = SectionedItems{ section = "", items = [ "1", "2" …
michaelmesser
  • 3,601
  • 2
  • 19
  • 42
1
vote
0 answers

Elm language documentation inside Atom editor like in LightTable

Is it possible to get documentation for Elm language like in this screencast, which uses LightTable? Specifically: panel for language documenation documentation for single function
rofrol
  • 14,438
  • 7
  • 79
  • 77
1
vote
2 answers

How to fill in several dropdowns subsequently from JSON in Elm?

We are stuck with filling in form from JSON data and need help. The component is about selecting the ward in the district of the given city. The data structure is a tree of Cities, Districts, and Wards with approximately following structure…
lessless
  • 866
  • 10
  • 27