workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
yeah, it does feel weird, I was thinking with the `as <var name>` syntax it would work because then you have a single value, but I guess that style syntax isn’t supported
2019-05-02T14:48:40.479900
Alicia
elmlang
general
Even if it did work, that isn't a type annotation?
2019-05-02T14:50:03.480100
Jae
elmlang
general
sorry, I left out a line, I was thinking it would be ``` val: (Int, Int) (( a, b ) as val) = ( 3, 4 ) ```
2019-05-02T14:56:08.480300
Alicia
elmlang
general
Ah, gotcha
2019-05-02T14:56:45.480500
Jae
elmlang
general
and it would know `a` and `b` were ints since it was destructuring of `val`
2019-05-02T14:56:47.480700
Alicia
elmlang
general
For now, you can have something like: ``` app |_ elm.json (application with source_directories=["lib/src"] |_ lib |_ elm.json (package with exposed_modules set for documented modules and same dependencies as the app) |_ src ``` You can then run `edp` on `./lib` to get the application documentation. And use `elm mak...
2019-05-02T15:04:55.480900
Velia
elmlang
general
Depends! I mean,there are some nice parts - you get to have docs, doctests, a readme, tests, and a guarantee that this module does not depend on other parts of your application. It you do decide to some day publish it, that becomes excessively easy. The downside is overhead in directory structures, the need to manually...
2019-05-02T15:04:57.481100
Huong
elmlang
general
Yeah, that's never been supported even in 0.18 where you could destructure at the top-level, not only in let-bindings. I haven't found a satisfactory way to deal with this yet :(
2019-05-02T15:06:56.481300
Huong
elmlang
general
There is an article (in Japanese unfortunately, Google translate) that explains that: <https://qiita.com/arowM/items/98f47202aa92394d483c>
2019-05-02T15:07:21.481500
Velia
elmlang
general
Not sure about ports :thinking_face: never tested, it depends of `elm make` good will. Can unpublished packages have ports? I doubt it (can't check now, on mobile).
2019-05-02T15:08:44.481800
Velia
elmlang
general
I suppose a follow up question is, why does the function name even have to be included in the type annotation? Why not just this ``` let (Int, Int) (a, b) = (4, 5) in ``` or ``` Int -&gt; Int -&gt; Int myFunction a b = a + b ```
2019-05-02T15:14:02.482400
Jae
elmlang
general
only guessing but I’d think for ease of parsing, I like how they line up personally
2019-05-02T15:24:47.484700
Alicia
elmlang
general
Myeah, I too like it, tho I guess it's mostly familiarity for me. I think that's also the reason for the syntax: it's how it works in SML and Haskell (albeit with `::` in the latter), and Evan decided he liked it.
2019-05-02T15:53:38.484900
Huong
elmlang
general
Hi! Anyone here has some experience using Elm with Cordova?
2019-05-02T16:52:27.485800
Dayle
elmlang
general
Do ports mess with the order that data gets sent back to elm? I have a stream of data coming through a websocket and it seems to get to elm out of order
2019-05-02T17:00:54.486500
Isaiah
elmlang
general
Hey <@Sofia>, it's also possible to publish a package that depends on ports by documenting how to set up the required ports and hook them up to the package code - see <https://package.elm-lang.org/packages/xarvh/elm-gamepad/latest/> for a good example
2019-05-02T17:11:06.488400
Janiece
elmlang
general
So you could publish a package and document it as normal, with any port setup stuff described in the README or in whatever module makes the most sense
2019-05-02T17:12:04.488500
Janiece
elmlang
general
That's really interesting! This might be worth pursuing then
2019-05-02T17:13:51.488700
Sofia
elmlang
general
You could also go this route even if you don't actually publish the package...setting up a proper package structure should allow you to use `elm-doc-preview`, and then you can just add the package source directory to your application's source directories
2019-05-02T17:13:55.488900
Janiece
elmlang
general
I don’t have any kind of source for this, but I seem to recall seeing them be stacked (in the datastructure sense) between animation frames
2019-05-02T18:22:46.489100
Lorilee
elmlang
general
Are they coming in exactly backwards per animation frame? That would look somewhat in order and somewhat jumbled I suppose
2019-05-02T18:23:25.489300
Lorilee
elmlang
general
<@Dayle> Yep I'm using it with Cordova right now! Well I switched to Capacitor actually, but same diff
2019-05-02T19:02:25.490600
Erin
elmlang
general
Yeah port order is never guaranteed. Recently had an issue with localstorage giving me old data because of a race condition where I'd set the localstorage from elm and then immediately set it again - apparently the second time was hitting the port first for some reason, meaning the older request was overriding the newe...
2019-05-02T19:05:32.490700
Erin
elmlang
general
Is it possible to run `update` on first launch of an `application`? If not, how am I supposed to parse the initial URL? The docs talk about parsing URL query parameters being used for, e.g., search terms. I get that `onUrlChange` would have fired if someone appended `?search=monkey` to the URL, and then my `update` get...
2019-05-02T19:40:12.496100
Erin
elmlang
general
`init` only lets you affect the model (and by extension, the view), But I guess I could have it spit out a model that's already been run through the update function? Like so: ``` init : flags -&gt; Url.Url -&gt; Nav.Key -&gt; ( Model, Cmd Msg ) init flags url key = update (UrlChanged url) startingModel ```
2019-05-02T19:42:14.496200
Erin
elmlang
general
Just pull out the UrlChanged branch into a function and call it from both update &amp; init.
2019-05-02T19:54:23.496600
Earnest
elmlang
general
<@Janiece> do you know why `Time.now` is a task, not a cmd, if it cannot fail?
2019-05-02T20:10:34.497600
Isaias
elmlang
general
<@Huong> then why is random a cmd if it can guarantee a result?
2019-05-02T20:13:56.497700
Isaias
elmlang
general
<@Earlean> cant you sequence cmds if the callback takes a `Maybe Msg`?
2019-05-02T20:16:05.497900
Isaias
elmlang
general
The fact that it cannot fail has nothing to do with that
2019-05-02T20:23:15.498500
Kris
elmlang
general
:thinking_face: i was mislead. What is the reason <@Kris>
2019-05-02T20:24:42.499100
Isaias
elmlang
general
Well, tasks are strictly more powerful than commands
2019-05-02T20:25:56.499700
Kris
elmlang
general
So you should ask why some command is not a task in any case (like Random)
2019-05-02T20:26:30.000600
Kris
elmlang
general
Ive been asking both, yeah
2019-05-02T20:31:01.000900
Isaias
elmlang
general
Why even differentiate the two?
2019-05-02T20:31:11.001300
Isaias
elmlang
general
Yeah I asked the same some months ago
2019-05-02T20:36:22.001800
Kris
elmlang
general
I believe the answer is that tasks are “guaranteed” to produce results, eventually
2019-05-02T20:36:45.002700
Kris
elmlang
general
While commands are not
2019-05-02T20:36:50.002900
Kris
elmlang
general
Oh.. i think i understand now, i just needed to hear it enough times :upside_down_face:
2019-05-02T20:38:23.003700
Isaias
elmlang
general
Or but i still dont know why random isnt a tadk
2019-05-02T20:39:53.004200
Isaias
elmlang
general
Well, a Cmd is opaque. At that point we can’t really do anything with it except hand it to the runtime. Tasks are different, we have andThen and Sequence. So maybe Task is chosen when it’s possible you’d use it with andThen or Sequence. So I’d suggest there is a limitation on random being a Cmd.
2019-05-02T21:10:52.008600
Leoma
elmlang
general
You can sequence Cmds by going through `update`. Eg. A Cmd produces a msg, the runtime calls `update` with that msg and `update` returns the next Cmd to be run
2019-05-02T22:02:33.009000
Earlean
elmlang
general
alright! I’m having trouble getting my elm application to run. I’ve tried the basic example with the counter in the elm guide in it runs fine but when I try to run my SPA it just stops on `Elm.Main.init`. It works fine in the Cordova browser but not on iOS or Android. Maybe you have some hard earned insight into what c...
2019-05-03T03:02:34.009600
Dayle
elmlang
general
I think there's no need for a Random Task, because `Random.Generator` basically does the same job as a `Task` :thinking_face:
2019-05-03T03:25:36.010700
Nana
elmlang
general
Not really, `Random.Generator` can only be sequenced with other generators, so you can't generate a random value and sequence that with sending that random value on a http request
2019-05-03T03:30:12.012100
Earlean
elmlang
general
You can create a Task that does calls to `Random.step`, but you need to manage the seed yourself so the result of the sequence of tasks needs to include the new seed so you can storage it for the next time you want to generate a random value.
2019-05-03T03:31:46.013700
Earlean
elmlang
general
A Task version of `Random.generate` would have the runtime manage the random seed value so you wouldn't have to
2019-05-03T03:32:38.014600
Earlean
elmlang
general
I think this is the main reason that it isn’t built in - this would require kernel code in `elm/random`, which is currently pure Elm (+ an effect manager, which can only do commands, not tasks)
2019-05-03T03:37:28.014800
Huong
elmlang
general
any idea why Elm doesn't see a change event on a dropdown when I use selenium?
2019-05-03T06:09:54.015700
Chin
elmlang
general
What worked for me was to use `selectByVisibleText`
2019-05-03T06:27:02.015800
Walton
elmlang
general
Did you try this one <@Chin>?
2019-05-03T06:27:27.016000
Walton
elmlang
general
What I mean is that the dropdown selection does change. But Elm doesn't receive the event.
2019-05-03T06:27:52.016300
Chin
elmlang
general
Haven't tried that.
2019-05-03T06:27:57.016500
Chin
elmlang
general
I had the same issue…the dropdown changed, but the event in Elm didn’t fire. This method worked correctly.
2019-05-03T06:29:08.016700
Walton
elmlang
general
who has that method?
2019-05-03T06:29:55.016900
Chin
elmlang
general
it looks like it’s WebdriverIO specific
2019-05-03T06:30:34.017200
Walton
elmlang
general
I don’t know if I can help then
2019-05-03T06:30:51.017400
Walton
elmlang
general
but I found it here: <https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html>
2019-05-03T06:31:35.017600
Walton
elmlang
general
<@Chin> what selenium version are you using?
2019-05-03T06:34:50.017800
Walton
elmlang
general
I'm actually using Capybara
2019-05-03T06:47:24.018000
Chin
elmlang
general
Hello. elm-analyse identifies unused imports. Is there a tool to remove them automatically?
2019-05-03T09:54:26.019400
Allyn
elmlang
general
elm-analyse has a fix mode that can do it (part of the web UI for it), but it can only fix them one at a time. I’m working on adding that to <https://github.com/elm-tooling/elm-language-server> so that you can get quickfix actions in the editor
2019-05-03T10:02:39.020600
Alicia
elmlang
general
I was looking for a CLI based solution. I generate some code using openAPI generator, which write some code with useless imports. So I’d like to clean it automatically every time we generate some code.
2019-05-03T10:39:29.023400
Allyn
elmlang
general
That would be the implementation of this issue: <https://github.com/stil4m/elm-analyse/issues/116>
2019-05-03T11:25:11.023600
Millie
elmlang
general
A workaround for now could be to ignore the directory in `elm-analyse` because it's generated code, which is not maintained by you.
2019-05-03T11:25:57.023800
Millie
elmlang
general
`excludePaths` <https://stil4m.github.io/elm-analyse/#/configuration>
2019-05-03T11:26:36.024000
Millie
elmlang
general
I had not seen it was possible to configure it!
2019-05-03T11:27:30.024200
Allyn
elmlang
general
Thank you very much <@Millie>, it will be very useful
2019-05-03T11:27:48.024400
Allyn
elmlang
general
So, I think Elm’s `view` function needs to have the signature `view : Model -&gt; (Html Msg, Cmd Msg)` Reason is as follows: 1. if/when you break your app into ’components/pages/whatever you call them` then each component will have a Model. This model represents the history of messages that the component triggered. I...
2019-05-03T15:43:37.030200
Leoma
elmlang
general
I think that might not work with how elm uses requestAnimationFrame right now, if view is only called every 16ms there may be times in that 16ms window when the `view: Model -&gt; (Html Msg, Cmd Msg)` would have produced messages
2019-05-03T16:08:02.033600
Alicia
elmlang
general
it’s not very Elm-y but we’ve been using custom elements where we set properties on the HTML from the Elm side, then then JS side looks at those attributes and makes the magic happen, stuff like `TextInput.view { autofocus = True, placeholder = "Testing" }` which gets rendered out as our custom input field like `node "...
2019-05-03T16:10:27.036800
Alicia
elmlang
general
<@Leoma> how would view know which element to focus without access to the previous model?
2019-05-03T16:12:17.039400
Jake
elmlang
general
and then in the custom element it is like ``` class extends HTMLElement { connectedCallback() { requestAnimationFrame(() =&gt; const elem = this.querySelector["input[autofocus]"]; if (elem) elem.focus(); } } } ```
2019-05-03T16:12:18.039500
Alicia
elmlang
general
What/when are you trying to focus an element? Does `Html.Attributes.autoFocus True` not work for you?
2019-05-03T16:14:13.042300
Chae
elmlang
general
autofocus only works on initial page load
2019-05-03T16:14:22.042700
Alicia
elmlang
general
Autofocus only works on the first render
2019-05-03T16:14:26.043000
Leoma
elmlang
general
I left out some there, we also have a `setTimeout(() =&gt; &lt;focus code&gt;, 0)` inside the `requestAnimationFrame` because we’ve seen times when it wasn’t actually rendered when the animation frame fired
2019-05-03T16:15:06.045600
Alicia
elmlang
general
You'd still need a declarative autofocus ("focus this node when it's first rendered"), not an effect ("focus this node after (each) render")
2019-05-03T16:15:51.048300
Jake
elmlang
general
I'm developing with elm-live and at each save of my file, elm-live take about 4 plain seconds to serve the new compiled js (after it has been compiled!). My elm file is quite small : 180-lines... Did you already encounter this issue?
2019-05-03T16:15:52.048400
Loralee
elmlang
general
here is the log of elm-live
2019-05-03T16:16:31.049800
Loralee
elmlang
general
<@Jake> the code runs in the `connectedCallback` in the custom element, as long as it is a leaf node elm will not re-render it
2019-05-03T16:16:48.050700
Alicia
elmlang
general
so it only runs once
2019-05-03T16:16:52.050900
Alicia
elmlang
general
Threading this
2019-05-03T16:16:56.051100
Leoma
elmlang
general
So here’s the problem. I want to add a field and focus it. That field is added by calling to an async DB function in javascript, and when that slot propagates into the Elm model, render it. This is async, so I can’t , in an update do `({model | fields = newFields}, focus newField)` because the field isn’t ready.
2019-05-03T16:16:58.051300
Leoma
elmlang
general
Could you do something like `Html.Keyed.input (changeKeyHereIfShouldFocus) ...`? That should re-render the input and trigger the autofocus, no?
2019-05-03T16:17:24.052000
Chae
elmlang
general
I’ve started a thread
2019-05-03T16:17:46.052300
Leoma
elmlang
general
Thread here RE `view : Model -&gt; (Html Msg, Cmd Msg)`
2019-05-03T16:18:09.052500
Leoma
elmlang
general
I was writing about the "send Cmd from view" idea, I see your approach as the right one.
2019-05-03T16:19:00.052800
Jake
elmlang
general
How do you know when it’s ready?
2019-05-03T16:19:29.053000
Chae
elmlang
general
Further, the code waiting to focus the element is a component with it’s own `view/update/Model` tuple. Of course, the data to be rendered is passed into `view`. So the component’s update isn’t aware that the field is ready to be focused.
2019-05-03T16:19:29.053200
Leoma
elmlang
general
we could but I don’t like it as much as using custom elements for it
2019-05-03T16:20:16.053400
Alicia
elmlang
general
I would use a custom element, the `connectedCallback` fires when the element is in the DOM and you can focus it
2019-05-03T16:20:49.053600
Alicia
elmlang
general
So, when the component’s view is called, I have: `view : ExternalData -&gt; InternalModel -&gt; Html Msg` The external data represents knowledge of the new data slot to render. The internal model has knowledge that we asked for the slot, and would like to focus it. The place the knowledge naturally comes together is ...
2019-05-03T16:21:07.053800
Leoma
elmlang
general
granted if you don’t already have the polyfills and everything in for them it is a pain
2019-05-03T16:21:09.054000
Alicia
elmlang
general
So my point #4, “It is now actually possible to do the above with a small hack AND it fixes otherwise not easily fixed issues.” hinted at the fact that is is how I fix it.
2019-05-03T16:21:44.054200
Leoma
elmlang
general
And it works exactly as expected.
2019-05-03T16:21:57.054400
Leoma
elmlang
general
Oh, that feels like you have merged view and update
2019-05-03T16:21:59.054600
Jake
elmlang
general
No
2019-05-03T16:22:19.054900
Leoma
elmlang
general
In your view are you “calculating” the readiness of the input by something like `if xValue &amp;&amp; yValue then ready else notReady`?
2019-05-03T16:23:10.055100
Chae
elmlang
general
Consider a component’s model/update. A component’s update is called when the component triggers a message. So a component’s model is a history of that component’s events. It is NOT a history of that component’s views.
2019-05-03T16:23:17.055300
Leoma