workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
and that `Resolver` parameter which the documentation does not make it very clear what it should be used for
2019-04-19T12:14:38.482200
Vilma
elmlang
general
it maps a response to a result. This means you have to handle all the failure cases of a `Response` up-front
2019-04-19T12:15:57.482800
Virgie
elmlang
general
sometimes I just feel like I don’t get the Elm architecture :sweat:
2019-04-19T12:26:48.483100
Vilma
elmlang
general
Indeed previously it was simpler to concatenate two tasks together: ` ... |> Http.toTask |> Task.andThen ...` I have yet to see if this can be mapped directly with the new API
2019-04-19T12:31:54.484800
Hoa
elmlang
general
I’ve been trying for a bit now but I just can’t figure it out
2019-04-19T12:32:13.485200
Vilma
elmlang
general
the old `Http.toTask` function seemed to be very user-friendly and easy to understand and use
2019-04-19T12:32:35.485700
Vilma
elmlang
general
I just can’t see another way to achieve what I’m trying without something similar
2019-04-19T12:32:57.486100
Vilma
elmlang
general
because I want to send a message which will set some flags (e.g. loading flag to true) before the HTTP request runs
2019-04-19T12:33:27.486700
Vilma
elmlang
general
There was some discussion about this limitation, but I don’t remember which solutions came up. I believe there was a package that builds on the new HTTP package which makes easier to deal with the kind of issues.
2019-04-19T12:36:08.488100
Hoa
elmlang
general
I’m going to take a look
2019-04-19T12:36:21.488300
Vilma
elmlang
general
<@Vilma> Should be this: <https://package.elm-lang.org/packages/jinjor/elm-req/latest/>
2019-04-19T12:39:09.488800
Hoa
elmlang
general
(Found out on Elm Discourse)
2019-04-19T12:39:19.489100
Hoa
elmlang
general
Some context: <https://discourse.elm-lang.org/t/using-task-to-send-http-requests/2696>
2019-04-19T12:39:53.489300
Hoa
elmlang
general
thanks <@Hoa> going to read into this
2019-04-19T12:40:52.489600
Vilma
elmlang
general
but even then from what I’ve read it seems creating a custom Cmd Msg is not ideal because it will be run twice via de runtime?
2019-04-19T12:50:20.490200
Vilma
elmlang
general
Lemme see.
2019-04-19T12:50:33.490400
Hoa
elmlang
general
<https://medium.com/elm-shorts/how-to-turn-a-msg-into-a-cmd-msg-in-elm-5dd095175d84>
2019-04-19T12:50:41.490700
Vilma
elmlang
general
&gt; 1. Cmd Msg* is inefficient &gt; By creating your own Cmd Msg you are making 2 trips through the elm runtime. Which is unnecessary. The command you are sending out, will end up in some other branch of our update function.
2019-04-19T12:50:57.490900
Vilma
elmlang
general
then it recommends either calling `update` recursively or passing the message directly in the `update` branch you are in
2019-04-19T12:51:50.491500
Vilma
elmlang
general
I think I can do that but will involve me doing some changes to my app
2019-04-19T12:52:10.492000
Vilma
elmlang
general
Ah, that one is a classic
2019-04-19T12:53:13.492200
Hoa
elmlang
general
But wait, you have to use the Elm runtime to do a HTTP call.
2019-04-19T12:53:37.492700
Hoa
elmlang
general
The basic idea is that, instead of doing two calls and manage two `Cmd`’s you combine two (or more) tasks and finally manage a single `Cmd`.
2019-04-19T12:55:12.494200
Hoa
elmlang
general
I got some helper functions here: <https://package.elm-lang.org/packages/prikhi/http-tasks/1.0.0/Http-Tasks>
2019-04-19T12:55:26.494400
Earnest
elmlang
general
<@Virgie> Thanks, works great!
2019-04-19T13:00:48.494900
Jerilyn
elmlang
general
Anyone in here familiar or have any examples (besides rogeriochavez/spades boilerplate) of using elm-return to slim down an `update` function?
2019-04-19T15:46:48.496200
Buffy
elmlang
general
Whoah this is interesting... <https://ellie-app.com/5jykFvVbcDra1>
2019-04-19T16:21:52.497500
Buffy
elmlang
general
I don’t see anything special, it looks like the default app. Am I missing something?
2019-04-19T16:24:45.497600
Allyn
elmlang
general
Msg is a record instead of a sum.
2019-04-19T16:25:15.497800
Buffy
elmlang
general
I realized it's a bad idea in the process tho because the view has to construct the whole record which is the opposite of what I'm trying to do... That or you have to pass in `Msg` to the view function which felt backwards too. I went back to a sum type.
2019-04-19T16:26:16.498000
Buffy
elmlang
general
Anyone ever tried modeling `Msg -&gt; Model` with a Result type?
2019-04-19T18:25:30.000100
Buffy
elmlang
general
Yes. Some people have done that.
2019-04-19T19:03:16.001600
Ashton
elmlang
general
Any examples? I'm trying to make "Impossible States" in my update instead of defaulting to a `_ -&gt; ...` case.
2019-04-19T19:04:09.002700
Buffy
elmlang
general
Personally I havent seen much value in the approach, but I know at least a few people seem quite satisfied doing it.
2019-04-19T19:04:48.004100
Ashton
elmlang
general
When you case against a pair you get Msg * Model number of states, but with an Either it'd be Msg + Model states which should map better to what I'm trying to do. Well I might need a regular Sum instead of an either. You can see an example of something close to what I'm doing with <https://github.com/rogeriochaves/spades/blob/master/boilerplate/src/Update.elm#L21> Only I want to get rid of the defaulting that's required to "ignore" all the other page states by modeling the whole orchestration as a Sum instead of a Product. <https://github.com/rogeriochaves/spades/blob/master/boilerplate/src/Update.elm#L21>
2019-04-19T19:07:28.007700
Buffy
elmlang
general
Yeah, <@Leoma> has a return package that treats updates as returing a result-y kind of thing, which may error. I recall someone at my local Elm meet up showing off a big application where every update returned a `Result Error (Model, Cmd Msg)`
2019-04-19T19:08:18.009200
Ashton
elmlang
general
I guess Im a critic of this, so I would much rather convince you not to follow this way than help connect you with them. For example, at least on the theoretical argument of “making impossible states impossible”, I dont think `Msg`/`Model` combinations are impossible states.
2019-04-19T19:09:35.011500
Ashton
elmlang
general
0 At least in my book, a `Msg` isnt a state. Its not memory that persists over time. It doesnt stay in your application. Its just a fleeting report of something that happened that your application needs to respond to. 1 Its a lot more possible than you might think. `Msg` come from the outside world. You dont know when or where they are coming from. Weird combinations can happen. I know this, in part, because I and others have put analytics in our applications that report impossible states that we _thought_ were impossible.
2019-04-19T19:10:55.013900
Ashton
elmlang
general
First of all, I totally understand where you're coming from (or at least I think we understand each other). Therefor, I'm really modeling this as a Product of Sums, where "Outside" messages are a part of the top level product, but then I want to mitigate someone's ability to something like `onClick Login` if they're already logged in, yeh? EG: I have a `type Model = Authentication {email : String, password: String} | Main {name: String, etc : }` and a `type Msg = Authentication CredsMsg | Main MainMsg` and I'm trying to have an update that looks something like ``` update : Msg -&gt; Model -&gt; (Model, Cmd Msg) update msg mdl = case ??? of Authentication message, Authentication model -&gt; Main message, Main model -&gt; ``` which I have a version of that using a Tuple but then the compiler yells at me about not covering the `Authentication _, Main _` and `Main _, Authentication _` cases which are what I'm trying to avoid because they don't make sense.
2019-04-19T19:16:46.019100
Buffy
elmlang
general
I hope what I'm saying makes sense... happy to paste a larger snippet if it'd be useful?
2019-04-19T19:17:03.019600
Buffy
elmlang
general
I think I hear you.
2019-04-19T19:19:12.019900
Ashton
elmlang
general
I think its okay to just have a case that goes to nothing happening. So, just in pure practical terms, I think: ``` (MainMsg subMsg, Authneitcation authModel) -&gt; (model, Cmd.none) ``` is an okay to way to go.
2019-04-19T19:20:57.021800
Ashton
elmlang
general
The Tuple is the problem algebraically speaking... yes I _could_ use a `_ -&gt; ...` to just ignore the bad cases at runtime... and it'd work but then if me or someone comes along later the compiler won't yell at us if we try to add a case like `(Authentication _, Main _) -&gt; -- This case should be impossible to even construct`.
2019-04-19T19:23:38.024700
Buffy
elmlang
general
`(a, b)` means there's `a * b` number of cases so if a and b are both type `Bool` that's 4 cases. But if I use a Sum of Bools ala: ``` type MsgModelThingMaybe = Auth Bool | Main Bool ``` The you have `Auth + Main` which is only two constructors to case on. `|` is type speak for addition algebraically speaking. Where a Tuple or an anonymous Product is type speak for multiplication.
2019-04-19T19:27:33.029700
Buffy
elmlang
general
Yeah also I like to avoid `_ -&gt;`. And to avoid incompleteness, you could just write out some of the non-sense cases. I think for practical purposes that could be the best way to handle this.
2019-04-19T19:29:16.030400
Ashton
elmlang
general
Im still reluctant to call these combinations “nonsense” or “impossible”. They could happen. Maybe extremely rarely. Maybe theres no reason to handle them. But its still there. Its a logical possibility, and a very remote and trivial real possibility.
2019-04-19T19:30:33.031600
Ashton
elmlang
general
Man loopty loop... I think for now I'm gonna settle on `Debug.todo` in that case that "shouldn't" exist. Oh bother... :bear: :honey_pot:
2019-04-19T20:16:54.034400
Buffy
elmlang
general
A key thing is that messages are asynchronous and can show up late. So “impossible” stuff can happen pretty easily.
2019-04-19T20:33:55.035400
Dede
elmlang
general
I'm aware messages are asynchronous at least in principle, what I'm asking about arises from me trying to learn <@Willodean>/elm-return lib... I just searched it on the packages site and <@Ashton> you have a similar package... What I'm trying to do (maybe without the whole Lens thing) is this... <https://package.elm-lang.org/packages/toastal/return-optics/latest> But that's 0.18 and hasn't been upgraded it seems.
2019-04-19T20:41:06.037800
Buffy
elmlang
general
<@Myrtle> isn't using a `_ -&gt; ...` in examples from what I can tell...
2019-04-19T20:41:54.038600
Buffy
elmlang
general
What is the challenge?
2019-04-19T20:42:35.040000
Willodean
elmlang
general
Trying to use you're lib to facilitate composition of updates without resorting to a `_ -&gt; Debug.todo` case...
2019-04-19T20:43:23.040900
Buffy
elmlang
general
I started down this path following the spades boilerplate but every child component has a default case that NoOp's and I want to make those cases incorrect by construction.
2019-04-19T20:44:21.042100
Buffy
elmlang
general
Want to avoid -&gt; <https://github.com/rogeriochaves/spades/blob/master/boilerplate/src/Cats/Update.elm#L25>
2019-04-19T20:44:40.042400
Buffy
elmlang
general
If you scroll to the bottom of the README here apparently there's a way to do it? <https://package.elm-lang.org/packages/toastal/return-optics/latest>
2019-04-19T20:45:04.042800
Buffy
elmlang
general
But that package isn't updated to 0.19 and I'm also not super sure I should need Lenses to accomplish this?
2019-04-19T20:45:28.043300
Buffy
elmlang
general
That make any sense?
2019-04-19T20:45:35.043600
Buffy
elmlang
general
You can't
2019-04-19T20:47:26.043900
Willodean
elmlang
general
You are going to have a Noop case
2019-04-19T20:47:37.044300
Willodean
elmlang
general
Either you just don't have that case, or you do.
2019-04-19T20:48:03.044900
Willodean
elmlang
general
If you do, you do. Period
2019-04-19T20:48:14.045300
Willodean
elmlang
general
Also, don't use `_ -&gt;` in pattern matches
2019-04-19T20:49:01.046100
Willodean
elmlang
general
Enumerate or lose exhaustivity checks
2019-04-19T20:49:20.046700
Willodean
elmlang
general
This is what I'm trying to avoid.
2019-04-19T20:49:21.046800
Buffy
elmlang
general
I'm trying to enumerate. But a Tuple (Anonymous Product, etc...) is algebraic multiplication and it's causing more states than are valid for my use case but trying to tie the Msg and Models together in a Sum is not working like I'm expecting it too.
2019-04-19T20:50:14.047900
Buffy
elmlang
general
Is this relevant? <https://package.elm-lang.org/packages/bChiquet/elm-accessors/latest/Accessors-Library>
2019-04-19T20:51:15.048500
Buffy
elmlang
general
Ahh
2019-04-19T20:57:57.048700
Willodean
elmlang
general
You have numerous invalid cases due to space routing
2019-04-19T20:58:19.049400
Willodean
elmlang
general
You are fucked bro
2019-04-19T20:58:28.049700
Willodean
elmlang
general
The answer to this problem is injective type families or associated data families
2019-04-19T20:58:51.050500
Willodean
elmlang
general
You can do this in Haskell but you are fucked in Elm
2019-04-19T20:59:12.051000
Willodean
elmlang
general
Not sure what you mean by "space routing" and I've read through Sandi McGuire's Type Level programming book but haven't written anything with HKD or Type Families yet so still not super sure how they'd solve this problem. Turning the function algebra into a Sum seems to be what I'm trying to do but I don't even know what I'm saying too... Ugh... I'm such a tweener right now it's painful.
2019-04-19T21:02:00.055000
Buffy
elmlang
general
Clearly you can turn a `a -&gt; b` into a Product ala `(a, b)` but not sure how to then say I only want `(Int, Int) | (Bool, Bool)` and not also `(Int, Bool) | (Bool, Int)`... :confused:
2019-04-19T21:04:32.056400
Buffy
elmlang
general
I tried parameterizing the type constructor but that ended up polluting a bunch of shit `type ActionModel a b c d = PageOne a b | PageTwo c d` and didn't seem to do what was in my head.
2019-04-19T21:07:39.058900
Buffy
elmlang
general
Plus `PageOne a b` is just another way of saying `(a, b)` anyways so I knew it wasn't right.
2019-04-19T21:08:05.059600
Buffy
elmlang
general
They solve this problem because you can parameterize the second type by the first
2019-04-19T21:08:19.060200
Willodean
elmlang
general
Or having them share a type
2019-04-19T21:08:26.060500
Willodean
elmlang
general
I meant SPA routing
2019-04-19T21:08:37.060800
Willodean
elmlang
general
Consider we have 3 types
2019-04-19T21:09:38.062100
Willodean
elmlang
general
A route type
2019-04-19T21:09:42.062300
Willodean
elmlang
general
A model type
2019-04-19T21:09:46.062500
Willodean
elmlang
general
And a msg type
2019-04-19T21:09:55.062900
Willodean
elmlang
general
With yah so far :slightly_smiling_face:
2019-04-19T21:10:03.063100
Buffy
elmlang
general
update :: Msg (route :: Route) -&gt; Model (route :: Route) -&gt; Model (route :: Route)
2019-04-19T21:11:10.064900
Willodean
elmlang
general
Now we are guaranteed that everything lines up
2019-04-19T21:11:23.065300
Willodean
elmlang
general
You can't do this in Elm
2019-04-19T21:11:49.065800
Willodean
elmlang
general
See my brain is trying to write that like `update : Msg Route -&gt; Model Route -&gt; Model Route` but that's not a thing right? But why?
2019-04-19T21:12:45.067000
Buffy
elmlang
general
Because we want Route promoted or it gives us nothing
2019-04-19T21:13:29.067600
Willodean
elmlang
general
Phantom types don't help here? I mean I can think of why it should work in my head but I can't see why it can't / won't work in Elm.
2019-04-19T21:15:20.068500
Buffy
elmlang
general
Right
2019-04-19T21:17:16.069400
Willodean
elmlang
general
Because you want this as the concrete case
2019-04-19T21:17:38.070100
Willodean
elmlang
general
`Model 'PageOne`
2019-04-19T21:17:53.070600
Willodean
elmlang
general
Not
2019-04-19T21:18:29.071100
Willodean
elmlang
general
`Model Route`
2019-04-19T21:18:35.071400
Willodean
elmlang
general
To make matters worse you will need to existentialize and deexistentialize to convince the compiler you are right about this
2019-04-19T21:19:29.073100
Willodean
elmlang
general
`forall` is an issue
2019-04-19T21:19:51.073700
Willodean
elmlang
general
I think the intuition of it is starting to make sense in my brain now... in other words, in Elm we're sorta just stuck with the `a x b` Tuple and `Debug.todo` crashing out if a bad case ever gets hit, yeh? So where do Lenses fit into this whole thing? Like how's this happening? <https://package.elm-lang.org/packages/toastal/return-optics/latest> Or is it just irrelevant?
2019-04-19T21:21:26.075200
Buffy
elmlang
general
irrelevant
2019-04-19T21:22:31.075600
Willodean
elmlang
general
frankly this is a problem that is a legit use case for dependent types
2019-04-19T21:23:06.076200
Willodean
elmlang
general
however I would suggest that `Debug.todo` is a shitty answer
2019-04-19T21:23:31.076600
Willodean