workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
I honestly don't care about any of the intermediate responses, just the last one in the queue. Alternately, I can just fire off all the original requests, ignoring their bodies, and just do a new GET at the end to get fresh data. But that still means being able to guarantee that the GET happens after all the others.
2019-04-05T09:17:28.528900
Gertrude
elmlang
general
Hence why you could/should? chain the queries as tasks imo.
2019-04-05T09:18:54.530500
Antonette
elmlang
general
Yeah. Are Tasks deterministic then? I see there is a `Task.sequence` at least
2019-04-05T09:19:20.531700
Gertrude
elmlang
general
You'd be guaranteed to send them sequentially and to get a `Msg` only at the very end.
2019-04-05T09:19:40.532400
Antonette
elmlang
general
And yes, they are :) that's why `Cmd`s are not.
2019-04-05T09:20:07.533200
Antonette
elmlang
general
You can see `Cmd`s as a way to "wrap" `Task`s in a non-sequencial batch, and of not caring about success/failure when you don't want to.
2019-04-05T09:21:32.535700
Antonette
elmlang
general
> Start with a list of tasks, and turn them into a single task that returns a list. The tasks will be run in order one-by-one and if any task fails the whole sequence fails. Hmmm. That could be messy. If one of the requests fails that could leave me with half the batch undone? Also there seems to be no `jsonResolver` for HTTP tasks.
2019-04-05T09:21:57.536400
Gertrude
elmlang
general
How do you currently handle batch failure?
2019-04-05T09:23:57.539000
Carman
elmlang
general
Good point. It kinda ... doesn't yet.
2019-04-05T09:24:30.539400
Gertrude
elmlang
general
I think this may be the point where it is just more sane to update the API.
2019-04-05T09:25:15.540100
Gertrude
elmlang
general
Sounds like the better course of action to me (if you may).
2019-04-05T09:25:56.541000
Antonette
elmlang
general
yeah, I'll have to see. The immediate endpoint is hours, but that's basically just a proxy for a third-party API
2019-04-05T09:33:08.541700
Gertrude
elmlang
general
It needs to be a function to allow it to sync. The version I posted of my model features a solution that does sync. It's just ugly.
2019-04-05T09:34:55.541800
Willodean
elmlang
general
I guess I don't understand how something goes out of sync in elm. The view should always reflect the current state of the model, no?
2019-04-05T09:39:59.542300
Sharon
elmlang
general
hmm, should i decode stuff from javascript in the subscription function or in the update function?
2019-04-05T09:39:59.542500
Emilee
elmlang
general
IMO as soon as possible.
2019-04-05T09:40:19.542800
Timika
elmlang
general
<@Emilee> keep decoders as far away from your code as you can. :slightly_smiling_face: This means, as close to the edges of your app.
2019-04-05T09:41:41.543500
Maida
elmlang
general
I prefer to interact with a module that handles every interaction with the server and is called from inside of the app with all the arguments needed to be able to reply with a `Cmd msg`.
2019-04-05T09:43:25.545000
Maida
elmlang
general
This means that, in your context, I will always decode at the subscription.
2019-04-05T09:43:56.545600
Maida
elmlang
general
that's fair
2019-04-05T09:44:18.545900
Emilee
elmlang
general
How do people handle the (incredibly common) scenario where you have several form fields which all need to hold valid values before the form can be submitted (or the submit button enabled)? I used to do something like this ``` case (field1, field2, field3, field4) of (Just v1, Just v2, Just v3, Just v4) -&gt; Just (submit v1 v2 v3 v4) _ -&gt; Nothing ``` but obviously that doesn’t work in Elm 0.19
2019-04-05T09:47:09.548900
Felisa
elmlang
general
<@Felisa> have some kind of validation
2019-04-05T09:47:54.549300
Maida
elmlang
general
you can use something like `elm-validate`
2019-04-05T09:48:34.549900
Maida
elmlang
general
Just a big stack of nested `if` statements then?
2019-04-05T09:48:34.550000
Felisa
elmlang
general
Sorry if I wasn’t clear: I’m not asking how do you validate a single field, I’m asking about how you organise multiple validations now that tuples are limited to 3 elements
2019-04-05T09:49:34.551200
Felisa
elmlang
general
`elm-validate` helps with that
2019-04-05T09:51:10.551700
Maida
elmlang
general
if you don’t want to use a library, take a look at `elm-spa-example` to see how you can easily implement a validation: <https://github.com/rtfeldman/elm-spa-example/blob/master/src/Page/Settings.elm#L356>
2019-04-05T09:51:31.552800
Maida
elmlang
general
I usually use some data structure that models valid/invalid/initial and do a `mapN` on it
2019-04-05T09:51:55.553500
Carman
elmlang
general
there's a bunch of form and validation libraries, for example <https://package.elm-lang.org/packages/hecrj/composable-form/latest/>
2019-04-05T09:51:59.553600
Emilee
elmlang
general
And if you need something stronger than `elm-validate`, there's `the-validator` <https://package.elm-lang.org/packages/Bastes/the-validator/latest/> (cue Terminator credits soundtrack)
2019-04-05T09:54:42.554500
Antonette
elmlang
general
:wink:
2019-04-05T09:54:53.554800
Antonette
elmlang
general
Cool, thanks for all the pointer! :slightly_smiling_face:
2019-04-05T09:54:55.554900
Felisa
elmlang
general
In your simplest case where you're using `Maybe` to model valid/invalid you can use a `mapN` function like: ``` Maybe.map4 (\v1 v2 v3 v4 -&gt; doSomethingWith v1 v2 v3 v4) field1 field2 field3 field4 ```
2019-04-05T09:58:13.556800
Carman
elmlang
general
This will give you `Nothing` if any of the fields are `Nothing` just like in your code snippet above
2019-04-05T09:58:45.557300
Carman
elmlang
general
and if all the fields are present it unwraps them and pass their values to the given lambda
2019-04-05T09:59:07.557800
Carman
elmlang
general
That works but is limited tp `.map5` so not that much of an improvement over tuples.
2019-04-05T10:02:06.558800
Felisa
elmlang
general
<@Felisa> if you need more you can use `Maybe.Extra.andMap`
2019-04-05T10:11:22.559300
Nana
elmlang
general
Ah, cool!
2019-04-05T10:11:51.559500
Felisa
elmlang
general
&gt; Advanced functional programmers will recognize this as the implementation of &lt;*&gt; I wouldn’t call myself an advanced functional programmer, but this is exactly what I was looking for! Thanks <@Nana>
2019-04-05T10:15:21.560300
Felisa
elmlang
general
Does this hold true even if dependencies are at different versions? Or even some on Elm 0.19, some on 0.18? If the 0.19 apps are compiled w/optimize?
2019-04-05T10:45:21.562300
Tisa
elmlang
general
As far as I can think of, that _should_ work
2019-04-05T10:46:34.562500
Huong
elmlang
general
When compiling multiple main modules into a single file with `elm make --output bundle.js Main1.elm Main2.elm`, it all uses a single elm.json and shared code is deduplicated, however, in your case, you're merging the compiled artifacts under a single `Elm` variable. As far as I can think of, those are self-contained and it shouldn't matter whether they have shared or different deps/versions/options/..
2019-04-05T10:48:45.562700
Huong
elmlang
general
Is there a `Cmd` way to open an URL in a new tab (equivalent of `target=_blank`)? Or should I just head for ports?
2019-04-05T11:29:53.563500
Florencia
elmlang
general
<@Florencia> I would head for ports if I were you and really, really needed not to just make a link with a `target="_blank"`.
2019-04-05T11:35:09.564600
Antonette
elmlang
general
(and I don't really see why you wouldn't just make a link with a `target="_blank"`, but maybe you have in which case I'd be interested in knowing the context :slightly_smiling_face:)
2019-04-05T11:35:51.565500
Antonette
elmlang
general
The current thing we do for `NavigateTo` Msgs is `Browser.Navigation.pushUrl` - so we already go the Cmd-instead-of-native-browser-behaviour route (And I need to essentially implement a `NavigateToInNewTab`, so to speak)
2019-04-05T11:37:19.566900
Florencia
elmlang
general
for ~some things~ UI links/buttons the link way is warranted, but sometimes you need to open an URL as a response to something different in `update`
2019-04-05T11:38:01.567800
Florencia
elmlang
general
(I understand link's preferable though)
2019-04-05T11:38:14.568100
Florencia
elmlang
general
it just doesn't cover all the usecases, it isn't a general solution
2019-04-05T11:38:37.568500
Florencia
elmlang
general
Ah, yes, the case where you want to open the tab from a `Cmd`, I hadn't thought of that one. My bad.
2019-04-05T11:40:26.569300
Antonette
elmlang
general
Then yes, using ports would be what makes the most amount of sense to me.
2019-04-05T11:40:46.569800
Antonette
elmlang
general
Thx for validating my reasoning on this :)
2019-04-05T11:42:22.570400
Florencia
elmlang
general
:wink:
2019-04-05T11:42:28.570600
Antonette
elmlang
general
Weird minds think alike :slightly_smiling_face:
2019-04-05T11:42:38.570900
Antonette
elmlang
general
Does anyone have experience using a date picker as a web component from Elm? I have been halfway successful with my experiments with <https://fooloomanzoo.github.io/datetime-picker/> , which is a polymer-based webcomponent, but I’m having issues binding to polymer’s property update events (don’t need anything fancy really, just want to pull the chosen value into elm’s state when component is updated)
2019-04-05T12:36:29.576200
Mardell
elmlang
general
FWIW, I’m considering the web components approach as opposed to native-elm options because not needing to handle &amp; store sub-component state/messages significantly simplifies my forms (based on hecrj/composable-form)
2019-04-05T12:41:52.579100
Mardell
elmlang
general
&gt; because not needing to handle &amp; store sub-component state/messages significantly simplifies my forms I’d kinda caution against using web-components for the express purpose of circumventing Elm’s architecture.
2019-04-05T12:47:15.580200
Theda
elmlang
general
that’s mainly what we use web components for, I’d use effect modules but they are banned
2019-04-05T12:56:36.582900
Alicia
elmlang
general
from a date picker you might want to be able to open it, close it, and get an event when a date is selected, it’s way easier to wire that up in a web component
2019-04-05T12:57:37.583600
Alicia
elmlang
general
I know I'm a little late the conversation but I use <https://www.npmjs.com/package/chokidar-cli>.
2019-04-05T13:07:19.583700
Laurena
elmlang
general
`chokidar "**/*.elm" -c "elm make src/Main.elm --output=elm.js" --initial`
2019-04-05T13:07:22.584000
Laurena
elmlang
general
Usually in my package.json scripts: ``` "scripts": { "build": "elm make src/Main.elm --output=elm.js", "watch": "chokidar \"**/*.elm\" -c \"npm run build\" --initial" }, ```
2019-04-05T13:08:29.584200
Laurena
elmlang
general
Yes, we use a web component over Flatpickr for our date/time needs
2019-04-05T13:15:54.584400
Simon
elmlang
general
Here’s a gist: <https://gist.github.com/aaronwhite/fd7c79f34ddc07cb6864fdb13b4b32c9>
2019-04-05T13:15:56.584600
Simon
elmlang
general
Flatpickr has a good chunk of functionality, and this approach greatly simplifes the model/update burden, which means my team is far more likely to make use of them when its on the margin :slightly_smiling_face:
2019-04-05T13:16:44.584800
Simon
elmlang
general
<@Theda> I’d generally agree with the sentiment of not circumventing the elm architecture, but in this case it’s a tradeoff of “where do we want to spend our dev time” — also being able to treat a datepicker in the same way we treat a plain text input, including the one-way data binding, doesn’t really strike me as circumvention. We’re just making use of the web platform to do a specialized and very compartmentalized task for us.
2019-04-05T13:29:23.591100
Mardell
elmlang
general
Thanks so much, <@Simon>, this is definitely helpful. Interesting that you did the config via one big record as opposed to individual HTML attributes of the tag itself — I’m assuming this is because of how `foundDiff` is calculated in the `set config(newValue)` function to avoid re-instantiating? In what situation were config values being updated regularly?
2019-04-05T13:46:16.591300
Mardell
elmlang
general
what’s elm 0.19 equivalent of elm-lang/color (if there’s any)?
2019-04-05T13:59:59.591900
Magdalena
elmlang
general
I believe it's <https://package.elm-lang.org/packages/avh4/elm-color/latest/>
2019-04-05T14:02:25.592300
Kimbery
elmlang
general
but it has slightly different API (for example there’s not toRgb func)
2019-04-05T14:02:58.592900
Magdalena
elmlang
general
yeah, I believe those functions got moved to another package, not sure which though
2019-04-05T14:04:08.593600
Kimbery
elmlang
general
hmm.. after fixing api, elm reactor now says “elm: thread blocked indefinitely in an MVar operation” is this known compiler issue?
2019-04-05T14:07:46.594100
Magdalena
elmlang
general
rabbit hole goes deeper and i just wanted to use line-charts library :disappointed:
2019-04-05T14:08:24.594800
Magdalena
elmlang
general
are you using `--debug`? otherwise try removing elm-stuff and a fresh compile
2019-04-05T14:09:06.595300
Virgie
elmlang
general
Good q, that is the reason but more detail escapes me at the moment
2019-04-05T14:09:46.596100
Simon
elmlang
general
nope, using elm reactor without --debug
2019-04-05T14:10:08.596500
Magdalena
elmlang
general
Definitely know how that goes. Thanks again for the help &amp; gist!
2019-04-05T14:18:00.596600
Mardell
elmlang
general
No problem! We use web components for ChartJS, algolia, and image fallback if youre looking for more
2019-04-05T14:18:50.597700
Simon
elmlang
general
I'm using JWTs to access my app's API and need to renew the token automatically if it's expired. I'm using auth0.js to renew the token so I need to use ports to call it but this means I can't just chain a request on after (using Tasks).
2019-04-05T14:31:49.600400
Kimbery
elmlang
general
One option would be to queue up Cmds that need the JWT, with something like ``` type alias Model = { jwt : Jwt } type Jwt = Ready String | Renewing (List (String -&gt; Cmd Msg)) ```
2019-04-05T14:34:41.601200
Kimbery
elmlang
general
so I could queue up any requests that need the JWT until it's ready again
2019-04-05T14:35:18.602000
Kimbery
elmlang
general
This means storing functions in the Model though...
2019-04-05T14:35:41.602400
Kimbery
elmlang
general
Another option would be to model all of the requests ``` type Request = FetchUsers | FetchUser Int ``` and then queue those up ``` type Jwt = Ready String | Renewing (List Request) ``` This seems more idiomatic, but also long winded
2019-04-05T14:37:35.603300
Kimbery
elmlang
general
never heard of that one :confused:
2019-04-05T14:40:47.604200
Nana
elmlang
general
i have an address form that i want to use on multiple pages of my single page app. is this a case for Html.map (modelling it as kind of its own small elm app) or is there a better way? i would like to avoid having to handle all the different messages for field changes on all the pages that use the form..
2019-04-05T16:09:04.606400
Daryl
elmlang
general
<@Daryl> yup sounds like it
2019-04-05T16:28:00.606700
Nana
elmlang
general
It might be worth it to reimplement auth0.js in Elm so you can use Tasks, it seems much cleaner than the other solutions you came up with. (I'm using JWT in my app and I chain Tasks.)
2019-04-05T17:29:05.607400
Kimiko
elmlang
general
Is there a way to distinguish a UrlChange generated by the browser (i.e. back/forward buttons) from one generated by Browser.Navigation.pushUrl (i.e. from the app)?
2019-04-05T17:57:41.608800
Kimiko
elmlang
general
<@Kimiko> You can make that distinction in onUrlRequest when the argument is a <https://package.elm-lang.org/packages/elm/browser/latest/Browser#UrlRequest>. By the time you are in onUrlChange that information is lost (unless you stashed it in your model somewhere.)
2019-04-05T18:30:20.609600
Dede
elmlang
general
Yeah. Just to confirm, the `state` property of the `popstate` never makes it into Elm, which makes certain things harder
2019-04-05T18:32:16.610600
Kimiko
elmlang
general
How does the vdom diff event handlers? Surely it doesn’t remove / recreate every update
2019-04-05T19:05:57.612800
Danika
elmlang
general
taken.
2019-04-06T01:29:43.613400
Yolando
elmlang
general
<@Danika> what are you trying to understand with this question? Are you looking for the actual implementation of the diffing algorithm that makes sure that event handling is happening efficiently?
2019-04-06T05:08:15.614800
Maida
elmlang
general
Basically, yes some implementation details. The question just popped in my head as I was going to bed :sweat_smile: I’m working on a TEA-like js framework and while i probably won’t keep it, i wanted to implement my own vdom. There’s a slight implementation difference where I have event listeners set up separately from the view; in hindsight because both Attributes and Events are part of the vdom elm should have an easier time knowing if / when to change events
2019-04-06T05:15:00.618600
Danika
elmlang
general
In that case, just look at the JS source code for the virtual dom. Code looks pretty readable.
2019-04-06T05:39:15.619300
Maida
elmlang
general
Has there been any discussion of supporting parameterized modules in Elm? Im curious what the pros/cons are for it.
2019-04-06T06:04:19.620900
Jae
elmlang
general
Something like defining this ``` module OurModule parameterA exposing (ourFunction) ourFunction = parameterA ``` and then in another module referencing it with ``` import OurModule 5 -- Returns 5 a = OurModule.ourFunction ```
2019-04-06T06:04:26.621000
Jae
elmlang
general
I imagine this would be useful for any-dict implementations where instead of the dict storing the compare function or it needing to be supplied in every function call, it could be just supplied once when importing the package
2019-04-06T06:06:20.621200
Jae
elmlang
general
If you wanted to import the same parameterized module multiple times then I imagine the syntax would look like this ``` import OurModule 5 as OurModule5 import OurModule 6 as OurModule6 -- Returns 5 a = OurModule5.ourFunction -- Returns 6 b = OurModule6.ourFunction ```
2019-04-06T06:09:22.621400
Jae
elmlang
general
There have been discussions but they did not lead to any concrete conclusion.
2019-04-06T07:25:53.621800
Maida