workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
I think I get it, i’ll try that now. Thank you <@Carman> and <@Freda>
2019-01-22T10:22:53.785000
Allyn
elmlang
general
:slightly_smiling_face:
2019-01-22T10:22:55.785200
Allyn
elmlang
general
Yes, you are right
2019-01-22T10:42:07.785300
Lynne
elmlang
general
A positive thing here is that you don't have to deal with `Maybe Profile` in your other pages
2019-01-22T10:42:40.785500
Lynne
elmlang
general
So, I’ve been following the ‘life of a file’ approach (aka <https://www.reddit.com/r/elm/comments/5jd2xn/how_to_structure_elm_with_multiple_models/dbuu0m4/>), and I’ve ended up in a slightly awkward situation: I split my model up with a union type (i.e. `model = FooModel FooRecord | BarModel BarRecord`), then later I split up my `Msg` type too (i.e. `type Msg = FooMsg Foos | BarMsg Bars`). That all seemed well and fine (using `Cmd.map` and `Html.map`), but: I’m increasingly running in to situations where I have to add an `otherwise -&gt; (model, Cmd.none)` to handle cases where the `Msg` no longer makes sense with the `Model`. Is there a way around this, is it a smell?
2019-01-22T13:16:56.791500
Bernardo
elmlang
general
Yeah I'm curious about this too. Although I'm guessing there might not be a perfect solution. elm-spa-example uses cases like: ``` _ -&gt; ( model, Log.error ) ``` (Log.error sends a message to a error tracking service)
2019-01-22T13:24:09.793500
Nana
elmlang
general
<@Nana> funny you should reference elm-spa-example, I just found elm-kitchen, which says: &gt; This is a modest attempt at providing a simplistic yet opinionated Elm SPA application skeleton based on rtfeldman’s Elm Example SPA, And has a similar smoking gun, here: <https://github.com/allo-media/elm-kitchen/blob/master/skeleton/src/Main.elm#L129>
2019-01-22T13:27:22.794900
Bernardo
elmlang
general
This is a hard problem. You want some messages to only come in when your're in certain states.
2019-01-22T13:28:38.796000
Carman
elmlang
general
The fact that messages are asynchronous makes it even trickier
2019-01-22T13:28:54.796400
Carman
elmlang
general
Consider firing off a slow HTTP request when your model is in the `FooModel ...` state. While the request is happening in the background, the user clicks a button and transitions the app into the `BarModel ...` state. _After_ that has happened, the HTTP request completes, giving you a `FooMsg ...`. How do you handle the situation?
2019-01-22T13:30:27.799900
Carman
elmlang
general
Heh, I think your use of ‘a hard problem’ is very fitting, if you squint at “state” and “transitions” it does start to look a lot like “cache invalidation”, and of course: <https://martinfowler.com/bliki/TwoHardThings.html>
2019-01-22T13:32:36.803600
Bernardo
elmlang
general
Here's another example for food of thought. Imagine that you have a messaging app. No matter which conversation the user is viewing, the app can get different Msgs, including new incoming texts from other conversations. You probably do want the texts to be added to the convos, even if you are viewing another one at the moment.
2019-01-22T13:33:18.804900
Bert
elmlang
general
Okay, it sounds like I’m not going crazy, and this is a ‘thing’. Has the Elm community come up with a name for it I wonder? :thinking_face:
2019-01-22T13:34:00.805600
Bernardo
elmlang
general
I've heard "make invalid state transitions impossible" or variations on that
2019-01-22T13:34:55.806500
Carman
elmlang
general
As far as I can tell, there is no way to do this at the type level
2019-01-22T13:35:40.808000
Carman
elmlang
general
Yeah. It’s exactly the word ‘impossible’ which made me think I was doing something wrong. I’d gotten all giddy after watching <@Leonie>’s “making impossible states impossible” talk, and then was confronted with this ‘situation’ :grimacing:
2019-01-22T13:36:04.808500
Bernardo
elmlang
general
<https://discourse.elm-lang.org/t/can-phantom-types-be-used-to-restrict-the-possible-transitions-in-a-state-machine/508>
2019-01-22T13:36:15.808800
Carman
elmlang
general
<@Bert> yeah seems like the best is usually to have your "data stores" on your main model, rather than on a "page model" which mirrors how you do things in React/Redux/Vue
2019-01-22T13:37:50.811000
Nana
elmlang
general
How is redux different, sorry?
2019-01-22T13:40:35.811300
Danika
elmlang
general
<@Danika> I meant, storing server data on a "page model" in Elm is like storing things on a component in React, whereas storing it on the main model is like storing it in Redux
2019-01-22T13:42:57.812800
Nana
elmlang
general
Beware of creating invalid states and lots of maybes if you put all your data on the top-level model
2019-01-22T13:46:06.813800
Carman
elmlang
general
<@Carman> hmm how would that create invalid states / lots of maybes? :thinking_face:
2019-01-22T13:50:00.815600
Nana
elmlang
general
Imagine a multi-step form that asks for address info on page 1, payment info on page 2, and a coupon code on page 3. If you put it all on the top level you end up with something like: ``` type alias Model = { state : State, page : Page } type Page = AddressPage | PaymentPage | CouponPage | SuccessPage type alias State = { street : Maybe String , city : Maybe String , country : Maybe String , cardNumber : Maybe Int , couponCode : Maybe String } ```
2019-01-22T13:58:16.821900
Carman
elmlang
general
This allows lots of invalid states (you shouldn't be able to go to payment if you don't have an address) and has lots of maybes. Contrast with something like: ``` type alias Model = { page : Page, ... } type alias Address = { street : String, city : String, country : String } type Page = AddressPage { street : Maybe String, city : Maybe String, country : Maybe String } | PaymentPage { address : Address, cardNumber : Maybe Int } | CouponPage { address : Address, cardNumber : Int, couponCode : Maybe String } | SuccessPage { address : Address } ```
2019-01-22T13:58:21.822100
Carman
elmlang
general
<@Carman> ah, I was talking about server data, form data definitely makes more sense to store on the "page"
2019-01-22T14:02:54.823800
Nana
elmlang
general
I think the same idea goes for server data. If there are some states where it shouldn't exist then it probably shouldn't be on the top-level model
2019-01-22T14:04:19.824500
Carman
elmlang
general
``` type alias Model = { profile : Maybe ProfileFromServer, page : Page } type Page = SignUp | ProfilePage | ... ``` versus ``` type Page = SignUp | ProfilePage ProfileFromServer | ... ```
2019-01-22T14:06:00.826100
Carman
elmlang
general
Aye, I guess the choice is between: 1. Use tagged unions (`|`) in your model, or: 2. Don’t.
2019-01-22T14:09:31.827500
Bernardo
elmlang
general
`type Choice = TaggedUnion | Dont`
2019-01-22T14:10:06.829000
Rosalee
elmlang
general
hmm, but typically you first navigate to a profile page and *then* load the data
2019-01-22T14:10:07.829200
Nana
elmlang
general
1. Necessitates that you might end up with a message which only makes sense on a ‘different’ side of the union (aka the problem I first came here asking about). 2. Eliminates 1., but introduces ‘invalid states’.
2019-01-22T14:10:59.830900
Bernardo
elmlang
general
2 does not eliminate 1, it just obscures it
2019-01-22T14:11:53.831900
Carman
elmlang
general
Uh, whoops, I put the numbers the wrong way around :joy:
2019-01-22T14:12:07.832200
Bernardo
elmlang
general
and how would `ProfilePage ProfileFromServer` work with navigating through urls?
2019-01-22T14:12:27.832700
Nana
elmlang
general
The problem <@Bernardo> was asking about earlier (handling messages that are unexpected given the current state of the model) exists no matter how you structure the app
2019-01-22T14:13:39.833500
Carman
elmlang
general
<@Carman> yeah. I think it’s interesting how it manifests itself in different ways.
2019-01-22T14:14:50.834600
Bernardo
elmlang
general
agreed :slightly_smiling_face:
2019-01-22T14:15:06.835000
Carman
elmlang
general
So yeah, it’s: 1. Use tagged unions (`|`), and know you’re forced to end up (probably) with something like `otherwise -&gt; ( model, Cmd.none )`, or: 2. Don’t use tagged unions, so you can always ‘find’ the value for which a message concerns, but accept that your model will inevitably allow inconsistent states to exist.
2019-01-22T14:17:00.837300
Bernardo
elmlang
general
I think definitely use tagged unions for pages and such though
2019-01-22T14:17:39.838100
Nana
elmlang
general
Thanks for the chat everyone, that was really productive! I have to lunch now though.
2019-01-22T14:18:32.839000
Bernardo
elmlang
general
In my experience, you generally end up having to do `otherwise -&gt; ( model, Cmd.none )` regardless of which approach you take
2019-01-22T14:24:55.842000
Carman
elmlang
general
With tagged unions (`|`) it's usually at the end of a flat case statement on all the tags. Without them it's usually a compound case on a variety of maybes and booleans.
2019-01-22T14:25:48.842900
Carman
elmlang
general
btw, the way I'm dealing with my server data, I don't consider it "wrong" to have data which is not relevant to the current page for example, if you're viewing the profile of User A, having data stored for User B just means that if you then go back to User B's page, you don't have to fetch the data again
2019-01-22T14:29:42.844600
Nana
elmlang
general
and it's always stored by ID, so User A's data would never overwrite User B's data
2019-01-22T14:30:55.845500
Nana
elmlang
general
that sort of data makes sense to store on the top-level because you always want it around regardless of what page you're on
2019-01-22T14:32:11.846200
Carman
elmlang
general
app data != page data ^^
2019-01-22T14:33:00.846500
Danika
elmlang
general
Afternoon. Having difficulty integrating an elm Browser Element into an existing react app, mainly when it comes to configuring webpack. Is using react-elm-component package and elm-webpackloader the advisable way to go about all this.
2019-01-22T15:18:38.849300
Leah
elmlang
general
Which Github issue were you looking at? Are there any discussions on the thread? I’ve noticed the same thing (filed a possibly different bug) and would like to follow it as much as possible.
2019-01-22T17:44:54.849700
Melodee
elmlang
general
To be sure, there’s no way to pattern match against record syntax, is there?
2019-01-22T17:47:09.850500
Bernardo
elmlang
general
I.e. I went from ``` Customers String (Maybe CustomerInfo) ```
2019-01-22T17:47:27.850600
Bernardo
elmlang
general
to ``` Customers { filter: String, modal: Maybe CustomerInfo } ```
2019-01-22T17:47:40.850800
Bernardo
elmlang
general
But now instead of: ``` Customers _ (Just _) -&gt; False ```
2019-01-22T17:48:12.851000
Bernardo
elmlang
general
I have to: ``` Customers page -&gt; case page.modal of Just _ -&gt; False Nothing -&gt; True ```
2019-01-22T17:48:42.851300
Bernardo
elmlang
general
Hmm, does Elm have `isJust`? :thinking_face: :haskell:
2019-01-22T17:49:22.851500
Bernardo
elmlang
general
you can match on a record, but can't match on the values in the record directly, so ``` case myPoint of { x, y } -&gt; ... ```
2019-01-22T17:49:24.851700
Virgie
elmlang
general
no, though `Maybe.Extra` probably does
2019-01-22T17:49:46.851900
Virgie
elmlang
general
Oh, that’s good to know! So that would bind `x` to whatever is in `x` in the record?
2019-01-22T17:52:24.852100
Bernardo
elmlang
general
It does, and `Maybe.Extra` does have it :tada:
2019-01-22T17:53:55.852300
Bernardo
elmlang
general
``` Customers { modal } -&gt; isJust modal ```
2019-01-22T17:53:59.852500
Bernardo
elmlang
general
That’s a little nicer :sunglasses:
2019-01-22T17:54:06.852700
Bernardo
elmlang
general
Thanks! :cookie:
2019-01-22T17:54:18.852900
Bernardo
elmlang
general
it's a little more limited than haskell can do, but this probably makes the totallity checker much easier. Also cramming more stuff into patterns might be bad style anyway
2019-01-22T17:55:17.853100
Virgie
elmlang
general
How do you upgrade an elm dependency
2019-01-22T19:37:56.853800
Dexter
elmlang
general
The way I do it is try to remove the dependency manually from elm.json, then add it back again with elm install
2019-01-22T19:48:39.854400
Lindsey
elmlang
general
as far as I know there's no elm command to remove or upgrade a dependency though.
2019-01-22T19:50:39.856100
Lindsey
elmlang
general
Thanks, that sound a bit backwards, but I’ll give it a shot :slightly_smiling_face:
2019-01-22T19:58:06.856600
Dexter
elmlang
general
I’ve been playing with the idea of writing a Dhall parser for Elm. My main reason is that I want to learn more about parsers but it would also be nice to use Dhall instead of JSON when communicating with a Haskell server.
2019-01-22T20:23:34.858400
Dione
elmlang
general
I looked at this issue <https://github.com/elm/compiler/issues/1828>
2019-01-23T01:58:40.858600
Jae
elmlang
general
Anyone know where we can see the changes for `0.19.0-bugfix6`?
2019-01-23T03:39:17.859600
Garnett
elmlang
general
<#C0K384K4Y|news-and-links>, rtfeldman's post a little while ago
2019-01-23T03:51:00.860200
Bert
elmlang
general
Thanks!
2019-01-23T03:51:08.860400
Garnett
elmlang
general
Not in much detail though
2019-01-23T03:51:21.860600
Bert
elmlang
general
The base repo is updated for 0.19 now. :slightly_smiling_face:
2019-01-23T09:22:12.862700
Jeanene
elmlang
general
Yeah, that’s similar to what I saw :sleepy:
2019-01-23T10:25:18.862900
Melodee
elmlang
general
thanks!
2019-01-23T10:25:19.863100
Melodee
elmlang
general
any parcel or travis expert that gets whats going on here? <https://travis-ci.org/Razzeee/htbah-character-creator>
2019-01-23T19:04:16.866100
Desire
elmlang
general
It seems you have to install `request` manually and add it to your `package.json`.
2019-01-24T03:15:11.866900
Timika
elmlang
general
npm install request --save
2019-01-24T03:15:17.867100
Timika
elmlang
general
but why?
2019-01-24T04:24:06.867400
Desire
elmlang
general
One of your dependencies has a dependency that is no longer automatically installed, so you have to do that yourself. I don’t think it’s related to travis or parcel at all. I’ve just yesterday created a new parcel project from scratch and did not have to install that dependency.
2019-01-24T04:26:23.867600
Timika
elmlang
general
You have a lot of webpack related stuff in your `devDependencies`, maybe it’s one of those?
2019-01-24T04:26:46.867800
Timika
elmlang
general
<https://docs.npmjs.com/cli/ls.html>
2019-01-24T04:27:03.868000
Timika
elmlang
general
Might give you a hint which package is causing this.
2019-01-24T04:27:17.868200
Timika
elmlang
general
already tried, did not work but I'm guessing elm at the moment, that's why I'm confused
2019-01-24T04:28:12.868400
Desire
elmlang
general
did try `npm ls request-promise` earlier
2019-01-24T04:29:52.868600
Desire
elmlang
general
None
2019-01-24T04:30:02.868800
Desire
elmlang
general
should have tried this
2019-01-24T04:30:10.869200
Desire
elmlang
general
i think that was added in the new 0.19 rev6
2019-01-24T04:30:43.869400
Desire
elmlang
general
That could be the case. But I wonder why I did not get the issue yesterday. :thinking_face:
2019-01-24T04:31:10.869600
Timika
elmlang
general
well I don't like the design :confused:
2019-01-24T04:32:24.869800
Desire
elmlang
general
BTW, I DM D&amp;D 5e, nice to see another pen and paper player here! :wave:
2019-01-24T04:32:36.870000
Timika
elmlang
general
nice, started a d&amp;d round last year
2019-01-24T04:34:30.870200
Desire
elmlang
general
also some c'thulu
2019-01-24T04:34:44.870400
Desire
elmlang
general
```takodana:oslo-elm-day-19-cpu-emulation-demo malax$ npm ls request [email protected] /Users/malax/projects/malax/oslo-elm-day-19-cpu-emulation-demo └─┬ [email protected] └─┬ [email protected] └── [email protected]```
2019-01-24T04:35:14.870600
Timika
elmlang
general
that’s weird. It installed request automatically for me.
2019-01-24T04:35:30.870800
Timika
elmlang
general
It’s a different binwrap version too.
2019-01-24T04:35:56.871000
Timika
elmlang
general
maybe it's not the bugfix6 for me
2019-01-24T04:36:36.871200
Desire
elmlang
general
Yeah, I just saw you don’t have that.
2019-01-24T04:37:00.871400
Timika
elmlang
general
do you need `elm-webpack-loader` still when you use parcel?
2019-01-24T04:37:21.871600
Timika
elmlang
general
I tend to install elm explicitly via npm.
2019-01-24T04:37:33.871800
Timika