workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | First map the list to a string list with that function, then look into the “join” function (either on list module or string module) | 2019-03-14T17:49:48.089600 | Simon |
elmlang | general | ah yeah, somehow i missed `join` | 2019-03-14T17:52:20.090100 | Natalie |
elmlang | general | is there any syntax like `filter (_ >= 0)` in PureScript? | 2019-03-14T17:52:58.090500 | Natalie |
elmlang | general | or is `\x -> x >= 0` the way to go? | 2019-03-14T17:53:17.090900 | Natalie |
elmlang | general | Yeah, no infix partial application of operators | 2019-03-14T17:58:51.092000 | Earlean |
elmlang | general | What's the simplest way to embed working Elm code into a static webpage? For context, I am writing a blog post about elm and want working elm code in that blog post. Want something like <https://repl.it> embeds | 2019-03-14T20:04:26.094900 | Al |
elmlang | general | i guess i could just compile `Browser.sandbox` for all the different examples and then embed that JS? | 2019-03-14T20:05:04.095700 | Al |
elmlang | general | Isn't there Browser.embed? | 2019-03-14T21:52:57.096100 | Carlota |
elmlang | general | Ah, apparently not. | 2019-03-14T21:53:25.096300 | Carlota |
elmlang | general | Hey folks. Trying to deal with nested data structures (namely updating them) and getting frustrated that `{ myRecord.data | thing = 5 }` sort of syntax isn't possible. As it seems pretty reasonable as to what that would do. | 2019-03-14T22:02:19.097100 | Rosaria |
elmlang | general | Am I missing something? | 2019-03-14T22:02:31.097600 | Rosaria |
elmlang | general | FWIW I've looked around a bit and seen the distate for deeply nested data structures. I really only have 1-2 levels max. | 2019-03-14T22:09:20.098200 | Rosaria |
elmlang | general | So I'm hoping there's a solution for not-deeply-nested-but-still-a-bit-nested. | 2019-03-14T22:09:35.098600 | Rosaria |
elmlang | general | Helper functions, mostly. E.g.
```
setThing value data = {data | thing = value}
{myRecord | data = setThing myRecord.data}
``` | 2019-03-14T22:17:04.100400 | Dede |
elmlang | general | Or even:
```
setThing value data = {data | thing = value}
setData data record = { record | data = data }
myRecord |> setData (myRecord.data |> setThing 5)
``` | 2019-03-14T22:28:46.101900 | Dede |
elmlang | general | Whether or not that’s an improvement is probably in the eye of the beholder. | 2019-03-14T22:29:24.102500 | Dede |
elmlang | general | <@Dede> I appreciate the reply. It is an improvement, but it seems so unnecessary. Wish Elm could help a bit more here. | 2019-03-14T22:37:44.103000 | Rosaria |
elmlang | general | I'm going to try doing a "Literate Elm" file | 2019-03-14T22:41:19.103100 | Al |
elmlang | general | > `{ myRecord.data | thing = 5 }`
> As it seems pretty reasonable as to what that would do
This is a conversation that happens a lot. I’m always curious what you think the reasonable thing would be?
For example, what would the return value of that expression be? | 2019-03-14T22:52:24.103900 | Hoyt |
elmlang | general | <@Hoyt> It seems fairly obvious to me that the record would return `myRecord` as that's the main thing you're modifying. It's no different than doing:
```
let newData = { oldData | thing = 5 }
in
{ myRecord | data = newData }
``` | 2019-03-14T22:57:54.105500 | Rosaria |
elmlang | general | newData is throwaway. You almost never need it and when you do you can simply break it up as above. | 2019-03-14T22:58:21.105900 | Rosaria |
elmlang | general | I'm actually curious what you think it would return. As there doesn't seem to be any other logical thing for it to return. Keep in mind too that this behavior was intuited by someone learning Elm for the first time, they thought this syntax would just work and were shocked that it didn't. Only to learn that the above code or something like it is instead necessary. | 2019-03-14T23:03:38.110700 | Rosaria |
elmlang | general | So it makes me believe more strongly that that syntax is actually the right thing to be doing. | 2019-03-14T23:04:32.111300 | Rosaria |
elmlang | general | It seems like it could also be argued that it would return `data`, since that is what is on the left-side of `|` | 2019-03-14T23:07:16.112200 | Hoyt |
elmlang | general | I don’t have a preference either way, mostly just curious what is the “reasonable” thing different people think | 2019-03-14T23:07:46.112800 | Hoyt |
elmlang | general | The value on the left of `|` is what is updated | 2019-03-14T23:07:59.113200 | Hoyt |
elmlang | general | I think that if you return data it loses most of its utility. | 2019-03-14T23:08:08.113400 | Rosaria |
elmlang | general | Since if you had data, and wanted to update and return data | 2019-03-14T23:08:17.113600 | Rosaria |
elmlang | general | You would only be doing `{ data | ... }` | 2019-03-14T23:08:23.113800 | Rosaria |
elmlang | general | But then we have a bit of syntax dissonance. Generally { x | … } updates `x` and returns `x` | 2019-03-14T23:08:51.114700 | Hoyt |
elmlang | general | But in this case, we are updating a nested property of `x` and yet returning `x` | 2019-03-14T23:09:10.115500 | Hoyt |
elmlang | general | `{ x | attribute = newValue }`
updates `x` and returns `x` | 2019-03-14T23:09:32.116800 | Hoyt |
elmlang | general | But
` { x.prop | attribute = newValue }`
updates `prop` but returns `x` | 2019-03-14T23:09:54.117900 | Hoyt |
elmlang | general | I’m not arguing either way, just pointing out that there are different ways to lookat it | 2019-03-14T23:10:18.119100 | Hoyt |
elmlang | general | eg. `{ someRecord | data = {myRecord.data | thing = 5 }}` is also a common thing to want to be able to do | 2019-03-14T23:10:41.120100 | Earlean |
elmlang | general | I find `{ x.prop | attribute = newValue }` to be returning `x` to be less than obvious | 2019-03-14T23:10:44.120300 | Hoyt |
elmlang | general | I like that the value on the left of `|` is what is updated and returned | 2019-03-14T23:11:02.120800 | Hoyt |
elmlang | general | The reason I find it obvious is because the value you're modifying isn't actually prop. It's the x. Which just happens to contain a prop. | 2019-03-14T23:11:27.121400 | Rosaria |
elmlang | general | You must return the thing that's modified | 2019-03-14T23:11:44.121900 | Rosaria |
elmlang | general | Which is indeed x | 2019-03-14T23:11:45.122200 | Rosaria |
elmlang | general | I would argue that you aren’t updating `x`, you are updating the value of `prop` | 2019-03-14T23:11:55.122500 | Hoyt |
elmlang | general | That's simply incorrect though. Because if x isn't updated, then prop can't be updated. One is contained by the other. | 2019-03-14T23:12:55.124200 | Rosaria |
elmlang | general | :slightly_smiling_face: I could respond with you being simple incorrect :slightly_smiling_face: | 2019-03-14T23:13:30.124900 | Hoyt |
elmlang | general | One person’s “this is obvious and reasonable” is another person’s “the other thing is” | 2019-03-14T23:13:45.125600 | Hoyt |
elmlang | general | `prop` is being updated, so `prop` should be returned. | 2019-03-14T23:13:57.126200 | Hoyt |
elmlang | general | You could, but that would also be incorrect. It's not a matter of opinion. It's just how memory of a computer works. Props memory lives as part of Xs memory. We don't have pointers in Elm. | 2019-03-14T23:14:20.126800 | Rosaria |
elmlang | general | HAHA! This compiles to javascript. The idea of “this is how memory works” is very far removed :slightly_smiling_face: | 2019-03-14T23:14:45.127400 | Hoyt |
elmlang | general | The values are intertwined and unless explicitly separated, live together. | 2019-03-14T23:14:46.127600 | Rosaria |
elmlang | general | I would argue that both approaches are “reasonable” | 2019-03-14T23:14:52.127800 | Hoyt |
elmlang | general | Actually, since we are working with persistent data structures, `x` doesn’t get updated at all | 2019-03-14T23:15:10.128500 | Hoyt |
elmlang | general | Well, Elm doesn't go so far as to have a document like "The Go memory model" so we can't say anything about anything truly :stuck_out_tongue: | 2019-03-14T23:15:23.129000 | Rosaria |
elmlang | general | it has a pointer to a nested structure in memory. `x` never get changed at all | 2019-03-14T23:15:30.129200 | Hoyt |
elmlang | general | The memory locations that represent `x` don’t get touched | 2019-03-14T23:15:43.129600 | Hoyt |
elmlang | general | :slightly_smiling_face: | 2019-03-14T23:15:48.130000 | Hoyt |
elmlang | general | if you build it in a certain way | 2019-03-14T23:15:54.130300 | Hoyt |
elmlang | general | But, again, both ways are “reasonable” | 2019-03-14T23:16:14.131000 | Hoyt |
elmlang | general | That's also correct, but as far as Elm's concerned that wouldn't add up. Because as I said there's no pointers there. X is just a giant block of memory. | 2019-03-14T23:16:19.131200 | Rosaria |
elmlang | general | One value that gets passed around | 2019-03-14T23:16:31.131600 | Rosaria |
elmlang | general | It doesn’t have to be “a giant block of memory” | 2019-03-14T23:16:58.132800 | Hoyt |
elmlang | general | In any case, it is late. My point is that both expectations are perfectly reasonable. | 2019-03-14T23:17:21.133300 | Hoyt |
elmlang | general | > eg. `{ someRecord | data = {myRecord.data | thing = 5 }}` is also a common thing to want to be able to do | 2019-03-14T23:17:23.133600 | Rosaria |
elmlang | general | I need to stare at this for a second. | 2019-03-14T23:17:30.133900 | Rosaria |
elmlang | general | Also, there are design considerations that I would argue that ` { x.prop | value = newValue }` is a design issue :slightly_smiling_face: | 2019-03-14T23:17:44.134500 | Hoyt |
elmlang | general | But that’s another discussion. | 2019-03-14T23:17:48.134700 | Hoyt |
elmlang | general | I’ve built a handful of elm systems, and, to be honest, I’ve never wanted to do `{ x.prop | value = newValue }` | 2019-03-14T23:18:09.135500 | Hoyt |
elmlang | general | I generally consider that a flag that I’m missing an abstraction somewhere :slightly_smiling_face: | 2019-03-14T23:18:21.136000 | Hoyt |
elmlang | general | So I appreciate the lack of that syntax, because it helps me identify those places | 2019-03-14T23:18:41.136600 | Hoyt |
elmlang | general | You've -never- wanted to do it? Not even once? | 2019-03-14T23:18:41.136700 | Rosaria |
elmlang | general | nope | 2019-03-14T23:18:44.136900 | Hoyt |
elmlang | general | I can't imagine that. | 2019-03-14T23:18:50.137300 | Rosaria |
elmlang | general | My models are relatively flat. They at most have 1 level deep. | 2019-03-14T23:19:07.138200 | Rosaria |
elmlang | general | But it's quite often a necessity. | 2019-03-14T23:19:14.138500 | Rosaria |
elmlang | general | I like to have 1- to 2-level nesting | 2019-03-14T23:19:18.138800 | Hoyt |
elmlang | general | Why I would build a bunch of helper functions to deal with setting those nested values is beyond me | 2019-03-14T23:19:28.139200 | Rosaria |
elmlang | general | To me it doesn't say I'm missing an abstraction | 2019-03-14T23:19:43.139800 | Rosaria |
elmlang | general | It just represents extra work | 2019-03-14T23:19:47.140200 | Rosaria |
elmlang | general | And I would say that both opinions are reasonable | 2019-03-14T23:19:56.140700 | Hoyt |
elmlang | general | My functions for updating the nested properties generally come about because I have an abstraction that represents updating those | 2019-03-14T23:20:22.141900 | Hoyt |
elmlang | general | I find it hard to believe that if the syntax didn't exist since Elm's inception, that you would have avoided it in favor of "abstractions". | 2019-03-14T23:20:27.142100 | Rosaria |
elmlang | general | That’s okay | 2019-03-14T23:20:35.142300 | Hoyt |
elmlang | general | It is perfectly fine to find it hard to believe | 2019-03-14T23:20:45.142600 | Hoyt |
elmlang | general | Because the way you design thing is almost assuredly perfectly reasonable, as well :slightly_smiling_face: | 2019-03-14T23:21:06.143300 | Hoyt |
elmlang | general | Well it's not, because I'm forced to make all these helper functions that aren't helpful | 2019-03-14T23:21:22.143600 | Rosaria |
elmlang | general | It's irony :disappointed: | 2019-03-14T23:21:38.144100 | Rosaria |
elmlang | general | Ah, then maybe not. :slightly_smiling_face: | 2019-03-14T23:21:41.144200 | Hoyt |
elmlang | general | I don't feel like I'm missing any abstraction or anything. I have a model for my page, and a response object that comes from the server. | 2019-03-14T23:22:30.146100 | Rosaria |
elmlang | general | I put the response in the model | 2019-03-14T23:22:33.146400 | Rosaria |
elmlang | general | And then want to update it at some point | 2019-03-14T23:22:38.146700 | Rosaria |
elmlang | general | And my problem exists right away. | 2019-03-14T23:22:44.147100 | Rosaria |
elmlang | general | It's not a complicated problem. | 2019-03-14T23:22:52.147800 | Rosaria |
elmlang | general | Simply one that I have no tools to solve succintly. | 2019-03-14T23:23:09.148600 | Rosaria |
elmlang | general | Maybe direct mapping the server response to a nested record w/o an abstraction is something to think about | 2019-03-14T23:23:18.148900 | Hoyt |
elmlang | general | The server objects are used bidirectionally. It simplifies a lot of things. Tearing apart would only mean more code to put it back together. | 2019-03-14T23:23:44.149600 | Rosaria |
elmlang | general | If I want to update that object, I change a part of it and send it back. | 2019-03-14T23:24:03.150100 | Rosaria |
elmlang | general | Hence needing to update nested objects. | 2019-03-14T23:24:10.150400 | Rosaria |
elmlang | general | That’s what encoder/decoder pairs are for | 2019-03-14T23:24:14.150500 | Hoyt |
elmlang | general | Perhaps decoding it on the download into something appropriate, then encoding it back to the wire protocol | 2019-03-14T23:24:39.151300 | Hoyt |
elmlang | general | But, again, I don’t know your situation, so I can’t say what you should do | 2019-03-14T23:24:47.151800 | Hoyt |
elmlang | general | I'm already doing that. | 2019-03-14T23:24:51.152000 | Rosaria |
elmlang | general | But | 2019-03-14T23:24:58.152400 | Rosaria |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.