workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | They're called HTML elements | 2019-04-29T09:05:54.170700 | Danika |
elmlang | general | <@Huong> Hmm, that's a nice argument, I'll buy it! :slightly_smiling_face: | 2019-04-29T09:06:33.171100 | Maxwell |
elmlang | general | I don't find this argument convincing. I mean, it doesn't try to answer or answer my question. You are being pedantic IMO. Thanks, anyway! :heart: | 2019-04-29T09:08:09.171300 | Maxwell |
elmlang | general | This was bothering me: `{ node: document.getElementById("foo") }` and I wanted to know if anyone around here was also bothered by that and thought `{ element: getElementById("foo") }` was more logical. | 2019-04-29T09:21:33.172500 | Maxwell |
elmlang | general | If you had an opportunity to change `node` to `element` would you change it or stick to `node` again? :slightly_smiling_face: | 2019-04-29T09:24:43.173300 | Maxwell |
elmlang | general | It’s not my call, but I’d stick to `node` - there is less ambiguity. JS having somewhat ambiguous function names shouldn’t influence Elm’s API :shrug: | 2019-04-29T09:26:43.174800 | Huong |
elmlang | general | I resolved the problem ! solution is in this article <http://lazyswamp.blogspot.com/2018/05/how-to-build-elm-platform-from-source.html> | 2019-04-29T09:58:11.174900 | Calista |
elmlang | general | wow, in trying to abstract this, I got the most insane type definition :sweat_smile: | 2019-04-29T10:33:25.175300 | Nana |
elmlang | general | ```
watchModel :
(msg -> model -> ( model, Cmd msg ))
-> (((model -> stuff) -> (model -> stuff -> model) -> ( model, Cmd msg ) -> ( model, Cmd msg )) -> ( model, Cmd msg ) -> ( model, Cmd msg ))
-> msg
-> model
-> ( model, Cmd msg )
``` | 2019-04-29T10:33:42.175500 | Nana |
elmlang | general | maybe add aliases to those internal functions.. | 2019-04-29T10:41:33.175900 | Liza |
elmlang | general | That is a rather complex signature, and I’m not sure how it would work, given that you can’t easily abstract over `stuff` :thinking_face: Perhaps something like this could work:
```
watchModel :
{ extract : model -> stuff
, invalidate : model -> model
, update : msg -> model -> ( model, Cmd msg )
}
-> msg
-> model
-> ( model, Cmd msg )
watchModel settings msg model =
let
stuff = settings.extract model
( updatedModel, cmds ) = settings.update msg model
in
if settings.extra updatedModel == stuff then
( updatedModel, cmds )
else
( settings.invalidate updatedModel, cmds )
``` (I’m sort of guessing at how you want a couple of those functions to behave, but that seems a somewhat reasonable abstraction) | 2019-04-29T10:44:37.176100 | Huong |
elmlang | general | Thank you! | 2019-04-29T10:44:57.176500 | Maxwell |
elmlang | general | (I like using records like that when I know that it doesn’t really make sense to partially apply with only some functions first, and some other functions later) | 2019-04-29T10:48:12.176700 | Huong |
elmlang | general | <@Huong> well, it does work :sweat_smile:
the way you use it is like:
```
Browser.element {
update = watchModel update watchers
...
}
```
`update` is your regular update function
and `watchers` is a function which looks like:
```
watchers watch =
watch .stuff computeStuff
>> watch .things computeThings
```
and "compute"-functions look like:
```
computeStuff model stuff = {model | computedStuff = ...}
``` | 2019-04-29T10:50:51.176900 | Nana |
elmlang | general | ohh. Okay, right! | 2019-04-29T10:51:52.177300 | Huong |
elmlang | general | don't know if I like it though... it looks pretty neat, but the type signatures are so weird | 2019-04-29T10:52:50.177500 | Nana |
elmlang | general | I didn’t consider the option of inversing it like that | 2019-04-29T10:53:00.177700 | Huong |
elmlang | general | Hm, does that work when `.stuff` and `.things` return a value of a different type? | 2019-04-29T10:53:46.177900 | Huong |
elmlang | general | wait, maybe it doesnt... | 2019-04-29T10:55:33.178100 | Nana |
elmlang | general | only tested it with one thing so far :stuck_out_tongue: | 2019-04-29T10:55:48.178300 | Nana |
elmlang | general | there is no ambiguity, an element is a node like a square is a rectangle : <https://www.w3.org/TR/domcore/#introduction-to-the-dom>
An element is a node.
An attibute is a node.
A chunck of text is a node. | 2019-04-29T10:56:31.178500 | Syble |
elmlang | general | and no inconsistency by the way :slightly_smiling_face: | 2019-04-29T10:56:49.178700 | Syble |
elmlang | general | Do'h, you're right | 2019-04-29T10:57:59.178900 | Nana |
elmlang | general | I think I see 2 issues - one is the order of operations:
- you need to gather all the values to watch _before_ the update, and then invalidate them _after_ the update. Currently, I don’t think that’s happening.
- when passing that `watch` function, it’ll get specialized to the first args it is passed. You need a rank-2 type for this (or use let-polymorphism but that means you can’t externalize `watchers`, so that seems pointless) | 2019-04-29T11:00:37.179100 | Huong |
elmlang | general | Hmmm, I don’t entirely agree. Attributes aren’t DOM nodes. A chunk of text may indeed be a DOM node (and you can actually pass a textnode, Elm will just replace it the same way it would replace a node representing a `div` element).
The thing is this: a document consists of a tree of nodes representing elements, text and comments. Elm needs a node in that tree to bind to. | 2019-04-29T11:07:31.179300 | Huong |
elmlang | general | you can have 10 nodes representing a `div` element, and Elm needs one of those nodes, not one of those elements. | 2019-04-29T11:08:03.179500 | Huong |
elmlang | general | (granted, the DOM spec explicitly refers to Element nodes as simply “elements”, though I suspect that is because, within the context of the spec, this brevity makes sense and is disambiguated by them explicitly making that concession) | 2019-04-29T11:12:04.180400 | Huong |
elmlang | general | Is it feasible to expect a browser to hold a variable of maybe 20^(7) elements? | 2019-04-29T11:12:12.180800 | Isaias |
elmlang | general | I highly doubt it | 2019-04-29T11:12:27.181300 | Isaias |
elmlang | general | What if they are really cheap elements like ints? | 2019-04-29T11:13:27.182300 | Isaias |
elmlang | general | I made an Ellie out of it
<https://ellie-app.com/5pTKYZdMJBxa1> | 2019-04-29T11:13:28.182400 | Nana |
elmlang | general | (Elm will even happily take a comment node, for what it’s worth) | 2019-04-29T11:13:36.182900 | Huong |
elmlang | general | And i could always resort to having it consult a database | 2019-04-29T11:13:45.183300 | Isaias |
elmlang | general | All it cares about is a node in the document which it can replace with your `view` | 2019-04-29T11:14:05.183400 | Huong |
elmlang | general | regarding gathering/invalidating I think I'm doing that correctly
but yeah it seems like I need some kind of polymorphism | 2019-04-29T11:14:47.183600 | Nana |
elmlang | general | <https://ellie-app.com/5pTMhhdHgWNa1> example of passing a comment node | 2019-04-29T11:14:58.183800 | Huong |
elmlang | general | ahhh, yeah, you’re doing that right indeed :thumbsup: | 2019-04-29T11:15:52.184200 | Huong |
elmlang | general | the polymorphism you need doesn’t exist in Elm | 2019-04-29T11:16:13.184700 | Huong |
elmlang | general | That’s 1.2 gigaelements. If they’re 32-bit ints, densely packed, that’s about 5 gig of data. That’s not a reasonable assumption to make about a browser, triply so for a mobile browser. | 2019-04-29T11:16:26.185200 | Dede |
elmlang | general | You’d need this line in the `watchModel` type annotation: `((forall stuff. (model -> stuff) -> (model -> stuff -> model) -> ( model, Cmd msg ) -> ( model, Cmd msg )) -> ( model, Cmd msg ) -> ( model, Cmd msg ))` | 2019-04-29T11:17:46.185300 | Huong |
elmlang | general | and the type of `watchers` would also need a `forall stuff.` inside the type of that `watch` function | 2019-04-29T11:18:34.185500 | Huong |
elmlang | general | and that’s fairly optimistic re packing :sweat_smile: | 2019-04-29T11:20:33.185700 | Huong |
elmlang | general | Yeah, that’s basically assuming you’ve linked your browser against LAPACK :slightly_smiling_face: | 2019-04-29T11:21:33.185900 | Dede |
elmlang | general | I’m going to do this from now on. | 2019-04-29T11:22:11.186300 | Danika |
elmlang | general | To expand on my ambiguity comment: `<a>` is clearly markup for an element, whether it appears in a document or not. An element only becomes a node when it appears in a document. Since the DOM spec is concerned with the document object model, it’s simply not concerned about what you call stuff when it’s not in a document. When it refers to an element, in the context of the spec, that is always an element appearing in a document, and hence, a node. | 2019-04-29T11:25:48.186600 | Huong |
elmlang | general | <@Huong> got it working with let-polymorphism though
<https://ellie-app.com/5pTYv2nC2FQa1> | 2019-04-29T11:27:19.186800 | Nana |
elmlang | general | (sorry if I’m rambling, I have a killer headache and it appears to affect what little English I speak) | 2019-04-29T11:27:28.187000 | Huong |
elmlang | general | cool! | 2019-04-29T11:28:31.187200 | Huong |
elmlang | general | that also lets you restructure things a bit so you still end up with a generic `wrap` function! <https://ellie-app.com/5pV6zRgmZyha1> | 2019-04-29T11:37:04.187700 | Huong |
elmlang | general | <@Huong> ah that's looking better! | 2019-04-29T11:38:22.187900 | Nana |
elmlang | general | (and because I enjoy this type of stuff, with the invalidator functions being `stuff -> model -> model` rather than `model -> stuff -> model` <https://ellie-app.com/5pV87jzxypKa1)> | 2019-04-29T11:39:30.188100 | Huong |
elmlang | general | I'm a little worried it might be too hard to follow, but maybe it's alright :smile: | 2019-04-29T11:47:16.188400 | Nana |
elmlang | general | with some minor changes, you could go for something closer to this:
```watchers : Model -> Model -> Model
watchers oldModel =
identity
>> watch oldModel .count updateCachedCount
>> watch oldModel .string updateCachedString
updateCachedCount : Model -> Model
updateCachedCount model =
{ model | cachedCount = model.count }
updateCachedString : Model -> Model
updateCachedString model =
{ model | cachedString = model.string }``` | 2019-04-29T12:03:15.188600 | Huong |
elmlang | general | With some careful types, that could, perhaps, even become something like this:
```
watchers : Watcher Model
watchers =
watcher <| \oldModel ->
succeed
|> watch oldModel .count updateCachedCount
|> watch oldModel .string updateCachedString``` | 2019-04-29T12:06:31.188800 | Huong |
elmlang | general | which is a _little_ odd, but prevents mistakes as far as mixing up old and new go, and if you’ve written tests with `elm-test`, the “function taking a lamda” might not be that far-fetched | 2019-04-29T12:07:35.189000 | Huong |
elmlang | general | <https://ellie-app.com/5pVKpycrhwZa1> poc | 2019-04-29T12:18:18.189700 | Huong |
elmlang | general | Yeah.. my derived datastructor has more conbinatorial states than i anticipated it would.. | 2019-04-29T12:26:51.191000 | Isaias |
elmlang | general | <https://ellie-app.com/5pVV9wyWRWfa1> ooh, I’m starting to like this API :thinking_face: | 2019-04-29T12:30:11.191100 | Huong |
elmlang | general | The main part of the API is now just this:
```watchers : Watcher Model
watchers =
succeed
|> watch .count updateCachedCount
|> watch .string updateCachedString
updateCachedCount : Model -> Model
updateCachedCount model =
{ model | cachedCount = model.count }
updateCachedString : Model -> Model
updateCachedString model =
{ model | cachedString = model.string }
``` | 2019-04-29T12:31:10.191300 | Huong |
elmlang | general | and the `wrap watchers update` call is still there, of course | 2019-04-29T12:31:30.191500 | Huong |
elmlang | general | Another option could be wrapping them in opaque types `Old model` and `New model` :thinking_face: | 2019-04-29T12:33:50.191700 | Nana |
elmlang | general | (and things like `watch2` are also pretty easy - <https://ellie-app.com/5pW2x8jzgxPa1> | 2019-04-29T12:37:38.191900 | Huong |
elmlang | general | I think the conceptual thing is easier without explicitly involving `Old` and `New`, though - those can remain implementation details - the thing is mostly that you can say “`watch` takes a property to watch and a function to invalidate when this thing changes on your model” | 2019-04-29T12:39:44.192100 | Huong |
elmlang | general | The one thing that isn’t super obvious is that watchers are completely independent - if `updateCachedCount` would also touch the `string`, that would be completely ignored and not invalidate the cache ~this isn’t true, it appears? :thinking_face:~ | 2019-04-29T12:41:35.192300 | Huong |
elmlang | general | anyway, have fun, I gotta go! This was a fun experiment to play with :smile: | 2019-04-29T12:42:13.192500 | Huong |
elmlang | general | oh, this implementation is actually broken | 2019-04-29T12:43:39.192800 | Huong |
elmlang | general | is something like the upcoming react async rendering available in elm (now or foreseeably)? | 2019-04-29T12:44:41.193500 | Efren |
elmlang | general | <https://ellie-app.com/5pWbQsgR5tLa1> there, that’s better | 2019-04-29T12:49:26.193600 | Huong |
elmlang | general | Has anyone figured out how to test functions like `Navigation.pushUrl` that need a `Browser.Navigation.Key` which doesn’t seem to have a good way to use a test value for :disappointed: <https://github.com/elm/browser/blob/1.0.1/src/Browser/Navigation.elm#L71> | 2019-04-29T12:52:59.194000 | Hoyt |
elmlang | general | `pushUrl` is developed by someone else who’s job it is to test.
I’d suggest refactoring your code so that you can test your functionality without also testing `pushUrl`’s functionality.
Can you give us more info? | 2019-04-29T13:09:52.194200 | Leoma |
elmlang | general | also, maybe it'd be a good idea to have to option to return commands as well :thinking_face: | 2019-04-29T13:38:22.194400 | Nana |
elmlang | general | this is an API in the works for addressing it, but nothing yet <https://github.com/elm-explorations/test/issues/24> | 2019-04-29T13:40:22.194600 | Alicia |
elmlang | general | the crux of the issue is if your model stores a `Key` you can’t construct that model in a test | 2019-04-29T13:41:18.194800 | Alicia |
elmlang | general | AH. Ok, yes. This seems like a messy situation. | 2019-04-29T13:46:00.195100 | Leoma |
elmlang | general | So, the real question it seems, is, what to do with models that contain a `Browser.Navigation.Key` in testing. | 2019-04-29T13:47:14.195400 | Leoma |
elmlang | general | not sure exactly what React async rendering is, but RemoteData is a pretty nice way to have views that wait for data
<https://package.elm-lang.org/packages/krisajenkins/remotedata/latest/> | 2019-04-29T14:00:27.195600 | Nana |
elmlang | general | <https://ellie-app.com/5pXmV36NrRta1> | 2019-04-29T14:05:30.195800 | Nana |
elmlang | general | A possible approach:
```
type alias Navigator = {
pushUrl: String -> Cmd msg
replaceUrl: String -> Cmd msg
...
}
type alias Model = {
nav: Navigator,
...
}
``` | 2019-04-29T14:31:35.197400 | Dede |
elmlang | general | For tests, construct a mock Navigator with closures that just print what's being attempted or whatever. | 2019-04-29T14:32:05.197700 | Dede |
elmlang | general | For the real code, construct a Navigator out of closures over the real Key. | 2019-04-29T14:32:20.197900 | Dede |
elmlang | general | Another approach, if you don't need to mock navigation events, is to store `Maybe Key` instead of `Key` on the model, and write wrapper nav functions that strip the Maybe off to do the work. | 2019-04-29T14:33:09.198100 | Dede |
elmlang | general | Another approach:
```type alias Model a = {a |
(all the non-key fields)
}
```
Use that type everywhere that isn't trying to do Nav operations, and then you can test with `Model {}` and do production with `Model {key: Key} ` | 2019-04-29T14:34:32.198300 | Dede |
elmlang | general | Yeah, was hoping there was a more straightforward way than all this, but looks like we’re going to have to head towards some form of dependency injection. I was hoping to test a function that calls `pushUrl`, but I’m thinking will need to rearrange things.
Thanks | 2019-04-29T14:35:23.198500 | Hoyt |
elmlang | general | And, sorry, I didn’t mean “test `pushUrl`” rather test that it was called. | 2019-04-29T14:35:54.198700 | Hoyt |
elmlang | general | There’s an open issue on this in elm-explorations <https://github.com/elm-explorations/test/issues/24#issuecomment-444143745> | 2019-04-29T17:14:30.199200 | Johnsie |
elmlang | general | Yeah, neither of the solutions (`Maybe` vs a wrapper for your model) is really great. For the first, you have to manage the `Maybe` in your code and your tests. In the case of `ModelWithKey` your `update` function will have a bunch of empty cases unless you feel comfortable with `_ ->`. In both cases, you are isolating the untestable parts of your code to make them as small as possible, but they’re still there. | 2019-04-29T17:28:20.199500 | Johnsie |
elmlang | general | Has anyone attempted to recreate the functionality of what we had in `elm-lang/Date.fromString` for Elm 0.19? We need to parse user input of a date entered in a text box without expecting users to enter iso strings. I've searched packages, but didn't find anything. I can write this parser, but would like to use a package if it exists. A port could technically do this, but really need it to be a function instead of a command. | 2019-04-29T17:38:36.203100 | Shakita |
elmlang | general | Using a nav object closed over the key or a mock doesn’t have those problems. | 2019-04-29T17:44:28.203500 | Dede |
elmlang | general | yeah, I like that solution better | 2019-04-29T17:45:05.203800 | Hoyt |
elmlang | general | <@Shakita> what format is your date in? Can you use a date picker instead of a textbox? | 2019-04-29T18:13:32.205100 | Earlean |
elmlang | general | We're using <https://github.com/CurrySoftware/elm-datepicker> but it requires a parser function in order to support users entering a date in the textbox. | 2019-04-29T18:20:59.205700 | Shakita |
elmlang | general | <@Georgene> Just FYI :slightly_smiling_face: Thought you might like this :slightly_smiling_face:
We have a nice css design system where I’m contracting, so writing helpers to use it. :slightly_smiling_face:
```
parseButton =
Spark.Button.button
|> Spark.Button.withLabel "Parse"
|> Spark.Button.withOnClick ParseText
|> Spark.Button.toHtml
modelDebugSection =
Spark.pageSection
|> Spark.withSeparator
|> Spark.withTitle "Model"
|> Spark.withContent [ text <| Debug.toString model ]
|> Spark.toHtml
``` | 2019-04-29T18:33:40.207200 | Hoyt |
elmlang | general | Yeah, that does sound better. | 2019-04-29T18:35:03.207300 | Johnsie |
elmlang | general | What happens if you do not call withOnClick? | 2019-04-29T18:47:09.207800 | Georgene |
elmlang | general | It doesn’t add the onClick handler | 2019-04-29T18:52:43.208000 | Hoyt |
elmlang | general | We haven’t worked on the required things yet to put on the initialization function `button`, so everything is optional for now | 2019-04-29T18:53:44.208200 | Hoyt |
elmlang | general | It sounds like you might want to re-architect your solution (I used to do data viz on a lot of nodes)
But if you are stuck to handling that many elements, dont want to do lazy loading, decided not to try drill downs, or filters, you could try webworkers
<https://www.w3schools.com/html/html5_webworkers.asp> | 2019-04-29T21:42:05.208800 | Denisha |
elmlang | general | Have Elm in the Spring 2k9 been recorded? | 2019-04-30T03:01:40.210000 | Leeanne |
elmlang | general | No worry, non-native here either, and affected by madening headache yesterday :slightly_smiling_face:
To elaborate on your point: you can not create an element `<a>` outside a document. It will be a Node as the DOM specify you have to create this element (or a vanilla Node) with the /ad hoc/ factory interface. But we're being picky at this point :monkey_face: | 2019-04-30T03:15:34.211500 | Syble |
elmlang | general | (nevertheless, it's interesting to understand those points to handle the Node and get how it works internally, why so convoluted at time) | 2019-04-30T03:17:01.211700 | Syble |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.