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
2 answers

Type error in the update function in Elm

I'm new to elm (0.17) and I try to understand how it works. In this case, I try to develop a kind of project estimation. This is what I did: import Html exposing (..) import Html.App as Html import Html.Attributes exposing (..) import Html.Events…
billyJoe
  • 2,034
  • 2
  • 24
  • 37
1
vote
1 answer

How can I share some values among different models in elm

Update 2016-05-14 I'm sorry that I may have failed to explain my problem clearly because of my bad English. This time I've abstracted the question and demonstrated it in a counter example. There are two sub-modules(CounterPair and CounterTriplet),…
Nandin Borjigin
  • 2,094
  • 1
  • 16
  • 37
1
vote
1 answer

Effects.tick replacement for elm 0.17

As it's stated in the upgrade guide, Effects is being replaced by this new Applicative Functor-like thing Cmd. I don't see any trace of a clue as to where Effects.tick might be hiding, or how it could be reimplemented. From the looks of things,…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
1
vote
1 answer

elm - executing multiple lines in a function

In elm, is something like the below possible foo : Int -> Html foo inputNum = addToNumHistory inputNum ; display inputNum where the aim of the above is to execute multiple lines of code? If not, is this because the above is an example of a side…
category
  • 2,113
  • 2
  • 22
  • 46
1
vote
3 answers

How to write a generic function that updates fields of a Record

Consider type alias Rec = { a: Int, b: Int, c:Int } updateRec r aVal = { r|a = aVal } updateRec2 r aVal bVal = { r|a = aVal, b= bVal } updateRec3 r aVal bVal cVal = ... How to generalize updateRec and updateRec2... into one…
lifebalance
  • 1,846
  • 3
  • 25
  • 57
1
vote
3 answers

Reversing a string using a Stack ADT in Elm

import Html exposing (..) import String type alias Stack = List String push : String -> Stack -> Stack push tok stack = (tok :: stack) pop : Stack -> (Maybe String, Maybe Stack) pop stack = let top = List.head stack in (top,…
lifebalance
  • 1,846
  • 3
  • 25
  • 57
1
vote
1 answer

elm how to set path to elm-stuf folder from main distribution

I can start elm-make elm-reactor and so on from any place because I included the path to Elm_Platform binaries into my $PATH env variable But I still have to copy all libs (elm-stuff folder) for any project, anytime when I started it in some new…
Ston17
  • 115
  • 1
  • 7
1
vote
1 answer

elm - union types and the model

The following code from this guide employs a union type to hold all possible widget types, then render a view: type Widget = ScatterPlot (List (Int, Int)) | LogData (List String) | TimePlot (List (Time, Int)) view : Widget ->…
category
  • 2,113
  • 2
  • 22
  • 46
1
vote
1 answer

StartApp's Model and Effects in Elm

Say I have some model, action set, and update function as follows: type alias Model = Int type Action = Succ update : Action -> Model -> (Model, Effects Action) update action model = case action of Succ -> ( model+1 ,…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
1
vote
2 answers

Map List onto shifted self

I have finally found an excellent entry point into functional programming with elm, and boy, do I like it, yet I still lack some probably fundamental elegance concerning a few concepts. I often find myself writing code similar to the one below,…
mindandmedia
  • 6,800
  • 1
  • 24
  • 33
1
vote
1 answer

elm - historic value of a signal

Given a Signal, how does one get its historical values? Something like --current value Signal.pastValue(0, Mouse.x) --previous value Signal.pastValue(1, Mouse.x) --previous nth value Signal.pastValue(n, Mouse.x) I've tried using Signal.foldp, but…
category
  • 2,113
  • 2
  • 22
  • 46
1
vote
1 answer

Elm output port is not working with a signal derived from StartApp

We're learning Elm basics and building a simple application with some audio output with the following setup: We are using Elm's StartApp. We have ports/audio.js with some POC audio logic (and console.log). ATM we are using elm-live to run the…
Touko
  • 11,359
  • 16
  • 75
  • 105
1
vote
1 answer

Elm - open ended types in a contract

Given the pseudo-contract: condy: Int -> Int -> a -> b condy n m a b = if n == m then a else b how can one define the above contract correctly such that the types of a and b are equal but can be any type? Effectively the above removes the need…
category
  • 2,113
  • 2
  • 22
  • 46
1
vote
1 answer

Webpack watching not working

I'm using webpack with Elm, and find that the watch only survives one set of changes (in fact it will keep on watching as long as the compile phase is successful, but only survives one failed compilation). I've already tried OldWatchPlugin and…
Simon H
  • 20,332
  • 14
  • 71
  • 128
1
vote
2 answers

Constructor function for Elm's extensible records / Json.Decoding of object hierarchies

Let's say I have the following sort of type definitions: type alias EntityBase = { id: Int , name : String } -- Derived types type alias PersonSpecfic entityBase = { entityBase | age: Int , address : String …
Gabor
  • 1,656
  • 1
  • 16
  • 28
1 2 3
99
100