Questions tagged [elm]
Elm is a functional programming language for writing web applications that can fully replace, or interoperate with, HTML/CSS/JavaScript.
1,890
questions
2
votes
1
answer
28
views
This is not a record, so it has no fields to access?
I have a problem regarding my Elm project. I have this function here, but I have a problem at interval.start and interval.end yielding the error "This is not a record, so it has no fields to ...
1
vote
2
answers
71
views
Html object tag for svg find width
I have
<object
data="${content}"
type="image/svg+xml"
></object>
Where content is a svg.
Currently I am trying to figure this on elm.
object
[ Attr....
1
vote
0
answers
17
views
How can I make WebAudio.param work in Elm?
I'm just getting started with WebAudio in Elm, using hayleigh-dot-dev/elm-web-audio/1.1.1. I got the setup right, have sound, and things seems to work as intended. However, when I started using ...
1
vote
1
answer
50
views
Is there an equivalent "Window: beforeunload event" that can be used in elm programming?
I want to trigger a Browser dialog when the user is about to close the tab or navigate from the current page. I cant find an equivalent "Window: beforeunload event" in elm. The Browser....
2
votes
1
answer
56
views
Decoding a nested list (list of lists with arbitrary depth) recursively
Consider this recursive type definition:
type NestedList a
= Elem a
| SubList (List (NestedList a))
How can I write a decoder in order to decode a JSON list (e.g [1, [[2, [3, 4]], 5], 6, [7, ...
0
votes
1
answer
36
views
dillonkearns/elm-form Library
I started using the dillonkearns/elm-form library in elm. It works well. Is it possible to create a dropdown where you can select multiple options using this library?
Thanks.
I tried modifying the ...
3
votes
1
answer
33
views
For testing update functions in Elm that use Files in their Msg, how can I create a File value to pass in test? Can you somehow create a File fuzzer?
For example, I have this model:
import File exposing (File)
type alias Model =
{ selectedFiles : Dict String File
, fileUploadInfoList : List FileUploadInfo
, modalSelectedFile : Maybe File
...
}
...
1
vote
2
answers
51
views
How to integrate OpenLayers with Elm.Land
I'm using ElmLand's web component example as a guide to building a web component for OpenLayers having created a project using the site's introduction.
The app runs in localhost with a silent console ...
0
votes
1
answer
41
views
Can I test a view function in Elm program that returns a Html.Styled msg instead of Html msg? Using Test.Html gives me an error
I am testing an Elm application and in its view functions, the Html module is replaced by Accessibility.Styled module. This is an example of a module and its view function:
import Accessibility....
3
votes
2
answers
50
views
Can elm form submission go to a relative URL path?
From my understanding (which could be wrong), the Elm way of doing HTML form submission is to send a Msg via the onClick event of the submit button, and then do an HTTP request to the server. The only ...
3
votes
1
answer
56
views
`Html.select` displaying wrong value when changing the options
I have a Model with options and a selected item.
type alias Model =
{ options : List String
, selected : String
}
The Model's initial value is given by Model ["aaa","bbb&...
2
votes
1
answer
113
views
elm reactor http://localhost:8000/ is empty
I am just starting with Elm locally.
I did
elm init
Hello! Elm projects always start with an elm.json file. I can create them!
...
Check out <https://elm-lang.org/0.19.1/init> for all the ...
1
vote
1
answer
163
views
Embedding mathematical equations in an Elm Spa
I want to put mathematical equations in a single page app written in elm.
I would like the equations to be rendered in the app and not being embedded as prerendered images.
I tried to realize this ...
1
vote
1
answer
73
views
How to modify Html.Node in Elm
How would I go about modifying an existing Html.Node in Elm?
I would like to create a function with the following signature that would add an extra attribute to the input node.
addAttribute : Html ...
2
votes
1
answer
78
views
Decode a tuple using Json.Decode.andThen
Using Elm 0.19.1, I have the following two functions:
criteriaDecoder : List Field -> List Operator -> Int -> List (Cmd Msg) -> ( Decoder Criterion, List (Cmd Msg) )
criteriaDecoder fields ...
0
votes
0
answers
74
views
Is there an easy way to draw in Elm using the L-system?
I found little information about drawing using the L-system in Elm. There is an L-system library but it is not up do date really, all I have found that could be useful is a turtle graphics library (...
5
votes
1
answer
94
views
In Elm 0.19.1, is it possible to make an http-get request within a decoder for the initial model?
I have a component created in Elm where users can create a list of different criteria. For this component, users should be able to create criteria to search for contacts. These contacts will be shown ...
0
votes
1
answer
77
views
Are there line breaks in Elm?
I'm calling a function in Elm and some of the variable names I'm passing as parameters are kind of long, so I'd rather not put it all on 1 line. But I'm having trouble figuring out how to do that.
...
1
vote
2
answers
78
views
How can I use Cmd.map within a update-function using multiple arguments?
In Elm 0.19.1, I have the following Msg (among others):
type Msg
= Yay Multiselect.Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Yay sub ->
...
2
votes
2
answers
46
views
install elm 0.16 and its dependenices
I need to get acquainted specifically with elm 0.16.XX because some project I am working on is using it, and long story short,e.g. the version cannot be changed. Also, as you guys know there is a ...
2
votes
1
answer
77
views
Elm Parser loop does not terminate
I am running into a parser recursion problem I can't figure out. Any advice on what is causing the issue would be appreciated.
The following code works fine when the function rawData is defined with ...
2
votes
2
answers
84
views
How to modify an item in a list?
I'm a bit confused how to modify an item in a list. This is my structure:
type alias Player =
{ id : Int
, name : String
, isActive : Bool
}
type alias Model =
{ players : List ...
2
votes
1
answer
163
views
Struggling to apply CSS styles to Elm application
I’ve been having issues figuring out the best approach to style Elm 19 applications. Here is what I’ve been trying but to no avail:
module Main exposing (..)
import Browser
import Html exposing (..)
...
0
votes
1
answer
80
views
Access values from top level model
I am creating my first elm application. It is a website with multiple pages, and a side bar/ top bar to navigate to the available pages. I have a top level model that looks like this:
top level model ....
0
votes
1
answer
38
views
Tests stop running when elm.json file is changed from application to package
I'm having an issue with the https://github.com/Martouta/elm-emojis-converter. When I run the tests (In CircleCI, with cd /root/project/tests && elm-test), they work fine with the elm.json ...
2
votes
1
answer
47
views
What does Uppercased term inside union means in Elm?
I'm reading Elm documentation related to syntax, and stumbled upon this snippet:
type User
= Regular String Int
| Visitor String
what type Regular and Visitor is? another type that never defined ...
2
votes
1
answer
64
views
Canvas not rendering the image in Elm through a port to use a JavasScript image-filtering library (based on rfeldmans elm-in-action book)
**
here is the view function:**
view : Model -> Html Msg
view model =
div [ class "content" ]
[ h1 [] [ text "Islamic art patterns" ]
, button
[ ...
2
votes
2
answers
82
views
In ELM, a GET request can't have a body, or is it?
Http.request seems to ignore body when the method is GET
init : () -> ( Model, Cmd Msg )
init _ =
( Loading
, Http.request
{ method = "GET"
, headers = []
,...
2
votes
2
answers
192
views
How to create a function groupBy, which groups elements of a list into tuples of lists and a value based on a function given as input?
I have to implement a method named groupBy which has the following signature:
groupBy : (a -> b) -> List a -> List ( b, List a ).
The method takes as input a function and a list of items and ...
3
votes
2
answers
290
views
Elm not allowing html `script` node in virtual DOM
I try to integrate to my ELM page a "login with" widget (the one from Telegram https://core.telegram.org/widgets/login)
I try to build the appropriate node, which is of type <script>, ...
1
vote
0
answers
52
views
Decoding a JSON field containing backslash underscore or adding backslash underscore in a string in Elm
So i have a JSON to decode in Elm and one of the fields is html\_url
Obviously I get an error if i try like this cause of "\_":
Decoder.field "html\_url" Decoder.string
I tried
...
1
vote
1
answer
84
views
Loop through the elements of a set in elm
Can I loop through elements of a Set in Elm? Or at least convert the Set to a List?
There exists Set.fromList, but I don't find any List.fromSet or something similar.
I know there is no for loop in ...
0
votes
1
answer
59
views
How do i get the a value from Decoder type in Elm
I'm currently trying to update an old project someone else has made from 0.18.
I have the types Msg and Mouse
type Msg =
SelectElement Int
| ApplyTool (Maybe Int) Mouse
type alias Mouse =
{
x: ...
1
vote
1
answer
62
views
How to collect and map values of custom types of a record to a string
How could I simplify the code of display more:
Here is my beginner code:
type Symbol = Cherry | Seven | Bar | Grapes
type alias Model =
{ one : Symbol
, two : Symbol
, three : Symbol
}
-- ...
2
votes
1
answer
60
views
How to write fuzz tests for List.partition function in ELM?
I don't have much experience with elm and I am trying to understand how fuzz tests work. For example how can I write a fuzz test for the List.partition function?
It is defined like:
partition : ...
1
vote
1
answer
108
views
How do I set my elm package as deprecated?
I would like to know, if there is anyway to mark my elm package as deprecated. I did some search on elm discourse and there was a solution proposed to package deprecations using @deprecated flag.
Is ...
2
votes
2
answers
58
views
How do I unpublish an elm package?
Is there any way to unpublish my old elm package and publish a new one?
I could not find any way or command for that.
0
votes
1
answer
148
views
Remove only the first occurrence of an item from a list in elm
Let's say I have a list of characters
letters = ['B','A', 'M', 'B', 'A']
I want a function that will remove the first instance a given character
removeSingleItem letters 'A'
-- ['B','M', 'B', 'A']
I ...
0
votes
1
answer
116
views
Have an elm function run 2 commands and return the last one [duplicate]
The elm person at our company has left and we now have an elm codebase and we just have to learn it. I think I got most of this ticket done but I need to add This code to the Update.elm:
update : ...
-1
votes
1
answer
80
views
Trying to Understand this function and Im completely lost
I have been trying to understand the following function and I think i am interpreting it incorrectly. I am trying to convert it to Python3
type UITreeNodeChild
= UITreeNodeChild UITreeNode
...
1
vote
1
answer
87
views
KaTeX and dynamic content
I have an HTML document with dynamic content including mathematical formulas. I would like to render the dynamically generated mathematics using KaTeX. Following various suggestions online, my current ...
1
vote
0
answers
132
views
How do I use the custom prelude from NoRedInk with stack?
I'm trying to write a desktop program using an elm frontend with haskell backend.
To make writing the backend code idiomatically similar to the front end code (and make sending data between them ...
2
votes
2
answers
113
views
How do you model 5 dice values with Elm Custom Types?
I am trying to produce a simple dice game in Elm. I will have a "dice cup" that contains 5, 6 sided dice. When you "roll" the dice, you get 5 random dice values. Lastly, a "1&...
0
votes
1
answer
99
views
ELM language Just trying to get the package install command to work to bring in html
I am in windows, when I go to the command prompt and type elm package install elm-lang/html I get the message "There is no package command" I have no idea why, my other elm commands ...
3
votes
1
answer
138
views
Destructuring records in Elm with "as" word
I'm doing the Elm exercises in Exercism again and there's a thing unclear to me so far. How does the "as" destructuring work? In the beginning I didn't understand anything. After read Yang ...
4
votes
1
answer
92
views
Is there a way to filter a list of union types in Elm without explict case/pattern matching?
I've got a list of things and I want to filter based on a Union type. simplified, it might be something like this:
type Groceries =
Apples
| Cheese
| Widgets
shoppingList = [Apples, Cheese, ...
5
votes
4
answers
397
views
What's the purpose of Just in Elm?
So, I have been doing the Elm track on Exercism.org and I just finished the exercise about the Maybe concept, but one thing is not clear to me yet. What is the purpose of the Just in the definition of ...
2
votes
1
answer
664
views
elm language server does not work with neovim
I have tried to use elmls with nvim-lsp but lsp does not work. I am using nvim-lspconfig and nvim-lspinstaller. as for elmls i have the following configuration.
lspconfig.elmls.setup {
root_dir = ...
2
votes
1
answer
90
views
Assigning Int Values to a Record Containing Maybe Int Type in Elm
I'm very new to Elm so please excuse me if my question is very basic.
Please consider the following code:
-- Defining an alias type containing the type Maybe Int
type alias User = { name : String, age ...
2
votes
1
answer
150
views
Find item in list and add to other list
I have a model containing a list of items that are rendered in a select as options.
The user can select an item, enter a number and click add to add the selected item and a "quantity" to a ...