workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
So the component’s model can know that the component requested a new field. A component’s view is called when the top level data changes.
2019-05-03T16:24:02.055500
Leoma
elmlang
general
So, if you are waiting for the first time that a particular relationship between a component’s history AND the data model exist, you will get that during a call to view.
2019-05-03T16:25:06.055700
Leoma
elmlang
general
If you want to trigger some work when that happens, you will need to trigger it from view.
2019-05-03T16:25:26.055900
Leoma
elmlang
general
I feel that for a stateful component "new data is available for rendering" should be a Msg too.
2019-05-03T16:25:28.056100
Jake
elmlang
general
Same as it is at the top-level where you get a Msg from a port
2019-05-03T16:26:06.056300
Jake
elmlang
general
Ok, there’s a problem with that, and the problem is that it is not enforcable with the type system
2019-05-03T16:26:16.056500
Leoma
elmlang
general
<@Leoma> do you have a simplified example of how you know when your input is ready?
2019-05-03T16:26:24.056700
Chae
elmlang
general
no i don’t
2019-05-03T16:27:07.056900
Leoma
elmlang
general
I’m trying to explain more broadly
2019-05-03T16:27:26.057100
Leoma
elmlang
general
Please give me a moment without more quesitons
2019-05-03T16:27:40.057300
Leoma
elmlang
general
A component’s view can generate messages, (and a (component might have subscriptions). These will have a type of Component.Msg. So if another view/update uses them, it HAS to wrap them `type Msg = ... | MyComponentMsg Component.Msg`
2019-05-03T16:29:31.057500
Leoma
elmlang
general
So, at this level, in update, when we get a `MyComponentMsg Component.Msg` it’s very clear how it must be handled. `Component.update` should be the only function with a type signature that can make use of these messages.
2019-05-03T16:30:26.057700
Leoma
elmlang
general
So it is very easy and clear to enforce “a component’s model is the result of the history of events on that component”
2019-05-03T16:30:58.057900
Leoma
elmlang
general
There is no way to easily enforce “I’m a component that needs it’s update called when particular data changes occur, and I really hope whoever is using me remembers to to that diligently”
2019-05-03T16:31:57.058100
Leoma
elmlang
general
Consider that such a change could occur in any part of the parent’s update function, or any functions it calls. It is very challenging to enforce this cleanly.
2019-05-03T16:32:55.058300
Leoma
elmlang
general
It also breaks the single source of truth as a component now has a copy of data that exists in it’s callee’s model.
2019-05-03T16:33:37.058500
Leoma
elmlang
general
For those reasons, I’m convinced that there will be times you want to look at data coming in from the parent model, AND data available in the component’s model, and trigger an event. And the cleanest place to do this is during view.
2019-05-03T16:34:35.058700
Leoma
elmlang
general
Does that all make sense?
2019-05-03T16:34:45.058900
Leoma
elmlang
general
It does make sense
2019-05-03T16:36:02.059100
Chae
elmlang
general
Yay! Thanks for listening.
2019-05-03T16:36:19.059300
Leoma
elmlang
general
Am I understanding correctly that the view for this component is relying on data from it’s own model as well as a “parent” model?
2019-05-03T16:38:48.059500
Chae
elmlang
general
Again, a component’s model is a function of it’s history. What a component renders is a function of it’s history AND ALSO what the callee passes into view. Consider an info panel that can be toggled open and shut. The component’s model might have `{isOpen : Bool}`, and the view might be `view : String -&gt; Model -&gt...
2019-05-03T16:41:35.059800
Leoma
elmlang
general
So the implementation of view says “if my current model is open, render the toggle button and String passed in, else just render the toggle button”
2019-05-03T16:42:30.060000
Leoma
elmlang
general
Ok! That makes a ton of sense to me as I’ve encountered that exact scenario many times (in React actually)
2019-05-03T16:43:10.060200
Chae
elmlang
general
I’ve found that with something like that, it’s much easier to store things like `isOpen` and such in the parent/global state. The only time I use a “component” model is when the values in the local model are truly local.
2019-05-03T16:45:26.060400
Chae
elmlang
general
Ok, so suppose we have a requirement that if a view is toggled open, and that rendered view contains a profanity, we need to log a message via http call.
2019-05-03T16:45:29.060600
Leoma
elmlang
general
Hmm
2019-05-03T16:47:27.061200
Chae
elmlang
general
Again. A component’s model is generated by a history of the events the component has generated. Other stuff is not a part of that model. There’s nothing else to it. The first time we can simultaneously look at “history of the events the component has generated” and “other stuff” is in view.
2019-05-03T16:47:40.061400
Leoma
elmlang
general
And again, the type system makes it easy to enforce that Msg originating from a component are sent back to it’s update. Anything else is hopes/prayers and fighting the type system.
2019-05-03T16:51:25.062300
Leoma
elmlang
general
My gut is telling me that `isOpen` should be part of the “parent” model. But I’m going to think about it for a bit. Just over a year ago we had a situation where we needed to focus a field that could be inside a collapsed accordion view, and if so open that section of the form. We ended up moving the open state of the...
2019-05-03T16:53:26.062500
Chae
elmlang
general
Right, so the toggle was an example.
2019-05-03T16:56:55.062700
Leoma
elmlang
general
But if you agree that there is a possibility that some data should be in the component’s model, then I think the rest of my ideas hold.
2019-05-03T16:57:52.062900
Leoma
elmlang
general
In any case, I’m not suggesting it’s impossible to avoid the need for `view : Model -&gt; (Html Msg, Cmd Msg)`, I’m suggesting that at times, avoiding that need will be unnatural and problematic.
2019-05-03T17:00:27.063100
Leoma
elmlang
general
Now, a custom element can use `dispatchEvent` in `connectedCallback` to trigger any event. Via this hack, one can trigger a Cmd Msg when something is rendered. Effectively giving you `view : Model -&gt; (Html Msg, Cmd Msg)`
2019-05-03T17:02:11.063300
Leoma
elmlang
general
I am using that now to make the rest of my code nicer.
2019-05-03T17:02:37.063500
Leoma
elmlang
general
never mind, I've restarted elm-live and... it is working well.
2019-05-03T17:06:28.063700
Loralee
elmlang
general
Garage startup, 3 guys dream big and want to change the world with the right “you”. (SF Bay Area Only) Looking for “you” who are passionate about social networking platform. Currently, we are looking for a designer and a full-stack software engineer. You can also contact us to make friends or share thoughts as being ...
2019-05-03T19:54:37.064000
Brigida
elmlang
general
Erm
2019-05-03T20:45:02.064400
Danika
elmlang
general
Probably not the most appropriate place for this
2019-05-03T20:45:13.064800
Danika
elmlang
general
_maybe_ <#C0LUAGWRK|jobs> if you’re actually trying to hire someone...
2019-05-03T20:45:34.065500
Danika
elmlang
general
:wave: hi, my team has been using this tool: <https://fractal.build/> and I was wondering if Elm + some webpack magic could serve as a replacement? Our workflow for building this auto documenting static site style guide is basically: 1. Build a SMACCS/BEM module, adhere to naming conventions, write the SCSS and the HT...
2019-05-03T21:52:07.069800
Winnifred
elmlang
general
In Browser.Dom package docs, there's this code example, ```import Browser.Dom as Dom import Task type Msg = NoOp jumpToBottom : String -&gt; Cmd Msg jumpToBottom id = Dom.getViewportOf id |&gt; Task.andThen (\info -&gt; Dom.setViewportOf id 0 info.scene.height) |&gt; Task.perform (\_ -&gt; NoOp)``` Shouldn'...
2019-05-04T05:11:20.071000
Jae
elmlang
general
<https://github.com/elm/browser/commit/8ea63a705801326d414707cb8fe12c4d4a62b5e4> :slightly_smiling_face:
2019-05-04T05:12:21.071200
Lea
elmlang
general
Ah, thanks!
2019-05-04T05:15:21.071400
Jae
elmlang
general
If I want to create a countdown, is there some trick to avoid an update every second (for second precision clock)?
2019-05-04T05:57:09.072500
Carter
elmlang
general
No.
2019-05-04T05:58:25.072700
Niesha
elmlang
general
Is there a problem with updating every second?
2019-05-04T05:58:38.073000
Ashton
elmlang
general
<@Chin> I do lazy update of just the clock but if i do every second i get a quite high cpu average
2019-05-04T06:08:30.074100
Carter
elmlang
general
Have you tried `Html.Lazy`?
2019-05-04T06:35:38.074500
Ashton
elmlang
general
Just settings the value in your model every second shouldnt be too taxing, my expectation is that its _other_ stuff thats taxing the cpu, like recomputing the Dom after every update, even tho it hasnt changed.
2019-05-04T06:36:56.076100
Ashton
elmlang
general
You can get some of your performance back with `Html.Lazy`, if thats the case.
2019-05-04T06:37:18.076500
Ashton
elmlang
general
Has there been any progress on server-side Elm? I haven't checked in a year or so.
2019-05-04T16:15:09.079100
Gayla
elmlang
general
You could use a `Platform.worker` with the html string library and fake it? <https://package.elm-lang.org/packages/zwilias/elm-html-string/2.0.2/Html-String> No official progress though
2019-05-04T16:29:38.080300
Danika
elmlang
general
Thanks. That's a nodejs API? It looks like this was the last word (Aug 21, 2018) <https://github.com/elm/browser/issues/19#issuecomment-414813158>
2019-05-04T16:32:28.081100
Gayla
elmlang
general
You’d need to use ports in combination with the above html-string library. You could send the complete html string over a port and serve it with something like express
2019-05-04T16:35:35.082500
Danika
elmlang
general
Might as well go with purescript.
2019-05-04T16:40:15.083000
Niesha
elmlang
general
Hmm im not sure I’d agree with that, but I do think server side elm is still not “there” for anything but experimentation rn
2019-05-04T16:41:55.084000
Danika
elmlang
general
anyone have an implementation of `Parser.deadEndsToString` ?
2019-05-04T16:51:41.084800
Simon
elmlang
general
you mean something custom?
2019-05-04T16:53:28.085000
Virgie
elmlang
general
The builtin one is a todo :sweat_smile:
2019-05-04T16:54:04.085100
Huong
elmlang
general
It was surprising, I kept searching my code over and over for the errant “TODO” :rolling_on_the_floor_laughing:
2019-05-04T16:54:31.085300
Simon
elmlang
general
There are some open PR’s with very simple implementations that you could use. It would be cool if someone were to make an implementation that can show relevant snippets from the original input along the way, though that’s more relevant to the Parser.Advanced modules I suppose
2019-05-04T16:56:25.085500
Huong
elmlang
general
Appreciate it, will check there (And while that would be cool, I’m just looking to hammer out my parsers implementation gaps
2019-05-04T16:57:12.085700
Simon
elmlang
general
Also kind of amazing/sad someone contributed a simple PR in good faith that just sits there :confused:
2019-05-04T16:58:19.085900
Simon
elmlang
general
Ah, that code works the charm, thanks <@Huong>
2019-05-04T17:01:48.086100
Simon
elmlang
general
linko?
2019-05-04T20:09:48.086600
Gayla
elmlang
general
<https://github.com/elm/parser/pull/16/files>
2019-05-04T20:10:10.086800
Simon
elmlang
general
It looks like no committer has looked at it.
2019-05-04T20:12:32.087000
Gayla
elmlang
general
hence the sad part
2019-05-04T20:12:48.087200
Simon
elmlang
general
The change from 2018 to 2019 does not make sense to me
2019-05-05T07:44:27.087600
Tobie
elmlang
general
Is this the right way to produces a String with a `\0` char? I need to remove those from a String. ```null = String.fromChar '\u{0000}'```
2019-05-05T11:03:05.089900
Hoa
elmlang
general
Directly using `\0` doesn’t work
2019-05-05T11:03:49.090500
Hoa
elmlang
general
So using `Byte.Parser` I thought to do something like: `String.replace null "" (P.string 64)`
2019-05-05T11:05:11.091000
Hoa
elmlang
general
You could also do `"\u{0000}"` - no need to go through a `Char` first
2019-05-05T11:28:42.093000
Huong
elmlang
general
Right! Simpler.
2019-05-05T11:29:08.093300
Hoa
elmlang
general
Anyway, it works. :slightly_smiling_face:
2019-05-05T11:29:14.093500
Hoa
elmlang
general
is there a good place to tell the Elm team on the rare occasions that a compiler message seems buggy or unenlightening?
2019-05-05T13:34:24.095100
Cher
elmlang
general
<https://github.com/elm/compiler/issues>
2019-05-05T13:46:42.095300
Dede
elmlang
general
<@Dede> thx!
2019-05-05T13:50:40.095800
Cher
elmlang
general
There's also a dedicated repo for tracking bad error messages
2019-05-05T13:56:09.096500
Huong
elmlang
general
<https://github.com/elm/error-message-catalog> that's the one. It's a good place for tracking suboptimal error messages
2019-05-05T14:09:05.097500
Huong
elmlang
general
<@Huong> ah, even better. opened the issue
2019-05-05T14:20:55.098400
Cher
elmlang
general
Do we know if there is any fix in works for those buggy type error messages? sth like ``` expecting: Arg -&gt; Result but I got: Arg -&gt; Result ```
2019-05-05T16:11:46.100200
Florencia
elmlang
general
the way I understand it, the actual "actual" type is something else and this is a bug in the error reporting
2019-05-05T16:13:07.102400
Florencia
elmlang
general
it's cropped up a few times since 0.19
2019-05-05T16:13:30.102900
Florencia
elmlang
general
there has been some reshuffling in error reporting in the compiler source since 0.19. Wouldn't normally notice but I'm using the elm compiler as a reference in a compiler construction course
2019-05-05T16:51:04.103000
Virgie
elmlang
general
so, hopefully yes
2019-05-05T16:51:18.103200
Virgie
elmlang
general
i was wondering, is there a reason why `Time.Posix` is not `comparable`?
2019-05-06T09:40:11.106100
Lilli
elmlang
general
This way i can't use the `(&gt;)` operator. Sure, i can write my function comparePosix, but maybe this change was made to avoid comparison? (?) i'm a bit confused :sweat_smile:
2019-05-06T09:42:31.107900
Lilli
elmlang
general
It’s not because `Time.Posix` shouldn’t be comparable. It’s because, more strongly, there are general rules for what is comparable. Basic types like numbers, strings, (not Bools), tuples, lists. Because Time.Posix is not one of those, it isn’t comparable. Because we have `posixToMillis` and `millisToPosix`, we can co...
2019-05-06T09:54:49.108000
Leoma
elmlang
general
Hey everyone, Is someone familiar with the Random package? I'm using elm 0.19 and I can't find a way to use it nor install it
2019-05-06T09:58:28.109400
Wai
elmlang
general
Can you check you’re trying to install `elm/random` (0.19 compatible) and not `elm-lang/random` (pre 0.19)?
2019-05-06T10:00:22.110500
Huong
elmlang
general
`comparable` is compiler magic, and the magic doesn't support `Time.Posix`. You could probably make a PR.
2019-05-06T10:00:35.110600
Niesha
elmlang
general
I tried it: ```elm-package install elm/random Error: Could not find any packages named elm/random.```
2019-05-06T10:01:05.111200
Wai
elmlang
general
elm install elm/random
2019-05-06T10:01:34.111500
Danika
elmlang
general
elm-package is 0.18
2019-05-06T10:01:40.111800
Danika
elmlang
general
OMG thanks
2019-05-06T10:01:57.112000
Wai
elmlang
general
:smile:
2019-05-06T10:02:19.112200
Danika
elmlang
general
something else... Is there a way when reading the doc to know to which elm version it apply ?
2019-05-06T10:03:12.113100
Wai
elmlang
general
For official packages, elm/* is 0.19 and elm-lang/* is 0.18. For others, the site will only show 0.19 packages when you search. Google still indexes a lot if 0.18 packages. The easiest way to check is look at the repo, if it has an elm-package.json its 0.18.
2019-05-06T10:07:59.115700
Danika