workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
hmm^^
2019-04-12T05:51:11.028700
Emilee
elmlang
general
Also it turns out that firefox *does* actually still support `xlink:href`, so I could've ignored this whole weirdness^^ but it's still nice to follow the current standard :slightly_smiling_face:
2019-04-12T05:51:57.028900
Emilee
elmlang
general
thinking how to make an API with lots of options, where some are optional and others are not :thinking_face: it'd be really nice if the old extensible records were still in, then I could have done something like: ``` type alias Options = { foo : String --required , bar : Maybe String --optional } defaults = { bar = Nothing } ``` and then you would use it like: ``` Foo.view {Foo.defaults | foo = "foo"} ``` that means you would get a type error if you didn't specify all required options, but the optional ones you could leave out
2019-04-12T06:23:21.033300
Nana
elmlang
general
You can't do this anymore?
2019-04-12T06:24:03.033500
Danika
elmlang
general
Oh wait I can see why
2019-04-12T06:24:24.034000
Danika
elmlang
general
no, you're not allowed to change the type of a record - it was removed to enable easier garbage collection in the future
2019-04-12T06:24:50.034700
Nana
elmlang
general
``` type alias Required = { a | foo : String } type alias Optional a = { a | bar : Maybe String } type alias Foo = Optional Required defaults = { bar = Nothing } withDefault : Required -> Foo withDefault req = { defaults | req } ``` Does this work, or something similar?
2019-04-12T06:29:10.043700
Danika
elmlang
general
I guess I could achieve the same thing by having my function accept two records, one with the required stuff and the other with optional stuff, and expose a default record for the optional ones
2019-04-12T06:29:16.044100
Nana
elmlang
general
i dont think `{ defaults | req }` is valid syntax though
2019-04-12T06:30:08.045700
Danika
elmlang
general
:thinking_face:
2019-04-12T06:31:54.047100
Nana
elmlang
general
<@Nana> You might want to look how the generated code for <https://package.elm-lang.org/packages/dillonkearns/elm-graphql/4.2.0/> handles optional arguments. I’m AFK right now, so maybe best look at the examples.
2019-04-12T06:40:21.052400
Jin
elmlang
general
<@Nana> You could have `defaults : Required -&gt; Optional Required`, and then have `Foo.view (Foo.defaults { foo = "abc" } |&gt; Foo.setBar "123")`. Would that help?
2019-04-12T06:40:55.052600
Kenya
elmlang
general
I think that would achieve the same thing as having the function take two records, like: ``` Foo.view {foo = "foo"} {Foo.defaults | bar = Just "bar"} ```
2019-04-12T06:43:50.054000
Nana
elmlang
general
ah, so the way elm-graphql does it would be like this? ``` Foo.view {foo = "foo"} (\defaults -&gt; {defaults | bar = Just "bar"}) ```
2019-04-12T06:46:30.056400
Nana
elmlang
general
and you can use `identity` if you don't want to change any defaults
2019-04-12T06:47:19.056700
Nana
elmlang
general
``` &gt; import Foo &gt; Foo.withDefaults { a = "Hello World!", b = 0.5, c = 10 } { a = "Hello World!", b = 0.5, c = 10, d = Nothing, e = Nothing, f = Nothing } : Foo.Options ```
2019-04-12T06:50:57.057300
Danika
elmlang
general
I don't think I'd recommend doing this... ``` type alias Required = { a : String , b : Float , c : Int } type alias Optional required = { required | d : Maybe String , e : Maybe Int , f : Maybe Float } type alias Options = Optional Required withDefaults : Required -&gt; Options withDefaults r = { a = r.a , b = r.b , c = r.c , d = Nothing , e = Nothing , f = Nothing } ```
2019-04-12T06:51:32.057600
Danika
elmlang
general
Exactly
2019-04-12T06:52:24.057700
Huong
elmlang
general
<@Danika> that doesn't let you specify some of the optional arguments though?
2019-04-12T06:54:06.058800
Nana
elmlang
general
indeed
2019-04-12T06:54:21.059000
Danika
elmlang
general
<@Nana> Do you have functions that work on different records of optional arguments? Then the two argument approach would be the only one that works, or?
2019-04-12T06:56:37.061000
Kenya
elmlang
general
but I guess having two functions like `view : Required -&gt; Html msg` and `withExtra: Required Optional -&gt; Html msg` could be nice as a convenience
2019-04-12T06:57:12.061800
Nana
elmlang
general
Damn, Slate.js requires React
2019-04-12T08:55:25.062700
Hoa
elmlang
general
Well, Quill might fit the task equally well.
2019-04-12T08:58:00.063200
Hoa
elmlang
general
the only editor I've used before is TinyMCE, which I think was like 600 kb by itself :grin: not exactly "Tiny" but it had good features for restricting and cleaning up html
2019-04-12T08:58:03.063400
Nana
elmlang
general
I’ve used Quill a few years ago with React. I had a good impression back then :slightly_smiling_face:
2019-04-12T08:59:44.063600
Hoa
elmlang
general
Oh wait. It looks ProseMirror is maintained too.
2019-04-12T09:01:44.063800
Hoa
elmlang
general
<@Nana> Have you considered a builder pattern? Something like ``` module Thing ... builder: RequiredParameters -&gt; Builder ... build: Builder -&gt; Thing ... setOptA: Int -&gt; Builder -&gt; Builder ... setOptB: Bool -&gt; Builder -&gt; Builder ``` And use looks like: ``` Thing.builder(requiredParameters) |&gt; Thing.setOptA 17 |&gt; Thing.setOptB False |&gt; Thing.build ```
2019-04-12T09:45:26.067600
Dede
elmlang
general
<@Dede> that just seems more verbose though :thinking_face:
2019-04-12T09:46:37.067900
Nana
elmlang
general
Yeah, it’s a pattern I see commonly in languages that let you attach operations to datatypes, where you’d write ``` Thing::builder(required).a(17).b(False).build() ```
2019-04-12T09:49:04.069000
Dede
elmlang
general
That said, if there are dependencies between the optional arguments, this gives you a way to enforce them.
2019-04-12T09:49:34.069800
Dede
elmlang
general
You should be able to copy <https://pursuit.purescript.org/packages/purescript-options/4.0.0/docs/Data.Options> and use a similar idiom
2019-04-12T09:50:19.070900
Niesha
elmlang
general
E.g. setters can return different builder types so that your early choices condition what your later options are.
2019-04-12T09:50:24.071100
Dede
elmlang
general
I like this approach as well. I use it here <https://github.com/z5h/component-result/blob/1.1.0/src/ComponentResult.elm#L73> Then use it like ``` withModel myModel |&gt; withCmd myHttpGet |&gt; withCmd myPortCmd |&gt; withExternalMsg LoadingData ```
2019-04-12T09:56:53.071900
Leoma
elmlang
general
Oh yeah, wordiness varies a lot depending on whether you need to keep module prefixing or not.
2019-04-12T09:57:48.072400
Dede
elmlang
general
`builder(requiredParameters) |&gt; setOptA 17 ...` is not so bad.
2019-04-12T09:58:11.073300
Dede
elmlang
general
(Ha, I almost always keep the module prefix… Just put down that example to keep it simple).
2019-04-12T09:58:49.074300
Leoma
elmlang
general
This is an area where Rust-ish operation-type associations have a code density advantage.
2019-04-12T09:59:18.075000
Dede
elmlang
general
…which may or may not be a readability disadvantage :wink:
2019-04-12T09:59:29.075300
Dede
elmlang
general
Readability &gt; all, imo. :slightly_smiling_face:
2019-04-12T10:01:10.075600
Rochell
elmlang
general
:100: . Although sometimes brevity helps, brevity isn’t necessarily the rule.
2019-04-12T10:02:02.075700
Leoma
elmlang
general
but people will always disagree on what is more or less readable :stuck_out_tongue:
2019-04-12T10:02:55.075900
Nana
elmlang
general
If brevity is concise and easily readable, then awesome. But if you have to start thinking about how the code is phrased, rather than why it's phrased that way, then it's a stumbling block to understanding. :slightly_smiling_face:
2019-04-12T10:02:59.076100
Rochell
elmlang
general
Yeah, that's true enough.
2019-04-12T10:03:05.076300
Rochell
elmlang
general
It's an inexact art :slightly_smiling_face:
2019-04-12T10:03:29.076500
Rochell
elmlang
general
and also, keeping types simple
2019-04-12T10:04:07.076700
Nana
elmlang
general
json-decode-pipeline for example is famously hard for beginners to understand, even though it looks pretty readable
2019-04-12T10:05:34.076900
Nana
elmlang
general
The Rust attitude to keeping type simple is to clone the Elm type system, then do a complete tableflip by adding Traits and automatic coercions :wink:
2019-04-12T10:06:02.077100
Dede
elmlang
general
(I spend way more time fighting the type system than the borrow checker, even though the latter is what looks scary at first.)
2019-04-12T10:06:33.077300
Dede
elmlang
general
hello
2019-04-12T10:09:18.077700
Jefferson
elmlang
general
Rust just cannot be as easy as Elm
2019-04-12T13:43:39.079500
Myrna
elmlang
general
The non-trait type system is more or less identical to Elm’s type system. But after that, there’s just a whole lot more stuff.
2019-04-12T13:44:24.079700
Dede
elmlang
general
multi-paradigm, lifetime, mixed of side effects
2019-04-12T13:44:28.079900
Myrna
elmlang
general
One may think it must be good for a language can do all of this
2019-04-12T13:44:53.080100
Myrna
elmlang
general
But it is just opposite. Like C++, for a team using C++, half of team will not understand full spec of the language for just using it, not counting the domain specific problems...
2019-04-12T13:46:00.080300
Myrna
elmlang
general
Another example is data and object (opaque data).
2019-04-12T13:47:19.080600
Myrna
elmlang
general
Only the clean separation between two can yield a good program..
2019-04-12T13:47:45.080800
Myrna
elmlang
general
So, I’m enjoying using Rust, and I’m not really interested in a language slag-off. It’s very different from Elm, serving a different space. I’ll leave it at that.
2019-04-12T13:49:42.081100
Dede
elmlang
general
yeah, it is just my opinion. My main work language is C.
2019-04-12T13:50:53.081300
Myrna
elmlang
general
I am just have some rants to what I have seen in the industry code. My bad.
2019-04-12T13:51:27.081500
Myrna
elmlang
general
I find Rust much more tractable than C++ has become. (I’m also fond of C for its purity of essence., but I’d write in Rust over C because I like the guardrails.)
2019-04-12T13:51:57.081700
Dede
elmlang
general
what do you think has more overhead: • creating single-rule style tags • creating custom elements context: we're currently using custom elements for our svg icons because they are colored with css variables which are not supported in elm. an alternative would be to use pure elm and dynamically create a style tag for every icon defining the css variable i would like to use a pure elm approach, but i'm worried about the wonkyness and overhead of ad-hoc creating a lot of style tags
2019-04-12T16:27:57.084800
Emilee
elmlang
general
<@Emilee> I think there may be a workaround with the CSS variables with ``` Html.Attributes.attribute "style" "--some-var: 10px" ```
2019-04-12T16:44:40.088200
Alicia
elmlang
general
we have SVG icons as well, we used `fill: currentColor` for them, and then we wrap them in a span or whatever to set the color
2019-04-12T16:47:21.088800
Alicia
elmlang
general
like `span [ class "w-4 h-4 color-blue" ] [ Icon.decorativeIcon SomeIconName ]`
2019-04-12T16:47:46.089300
Alicia
elmlang
general
hmm, the attribute workaround seems feasible. of course it can accidentally nuke other styles, but that should be avoidable `currentColor` seems like a better choice for single-color icons than a css variable, but we can't change that right now since parts of our angular codebase depend on the way colors are set at the moment^^
2019-04-12T17:12:58.090900
Emilee
elmlang
general
Hi, I constantly feel that structure and presentation are two different respects of a HTML view
2019-04-12T18:40:25.093400
Myrna
elmlang
general
mix css style directly inside the code make my html structure very hard to read
2019-04-12T18:41:03.094200
Myrna
elmlang
general
Does anyone have suggestion for that situation?
2019-04-12T18:41:42.094900
Myrna
elmlang
general
Right now, I use bootstrap classname in the attribute tag for html, and have separate css for it. But bootstrap requires me to modify my html structure as well..
2019-04-12T18:43:12.096200
Myrna
elmlang
general
We've been using tailwinds which does utility classes (e.g `p-4 font-semibold color-blue`) , I love it now and try to use as little css as possible. It has a little learning curve but once you are over that development is fluid
2019-04-12T18:49:46.100400
Augustus
elmlang
general
Bulma is another one that is similar to tailwinds
2019-04-12T18:51:46.101500
Augustus
elmlang
general
<@Augustus> I agree, utilities classes are cool
2019-04-12T18:54:13.102000
Myrna
elmlang
general
very easy to manipulate as well
2019-04-12T18:54:27.102400
Myrna
elmlang
general
but feels like it is kind of abbreviation or alias to write css style attribute in the html, isn't it
2019-04-12T18:56:41.103500
Myrna
elmlang
general
of course, shorter, sweater, I looked up the grid css
2019-04-12T18:58:24.104200
Myrna
elmlang
general
the two probably can combine together, one for visual layout, the other for visual style
2019-04-12T18:58:58.104900
Myrna
elmlang
general
Separating layout and style was how `style-elements`(now `elm-ui`) started :smile:
2019-04-12T19:31:34.105600
Cornell
elmlang
general
I’m actually working on this now. Currently on vacation, but hope to land this in in near future
2019-04-13T03:01:13.108800
Patricia
elmlang
general
It’s hard stuff. I’ve been using CSS since forever and there’s always a bit overlapping. Bootstrap-like frameworks are good solution since they do most of the job for you. You pay some price for it though, since they require you write HTML and add cSS classes to match their patterns. I personally do’t like tailwind-like solutions but they have a lot of fans. Given that we have flexbox and CSS grids are starting to be more approachable I would think to start with something basic like Normalize.css and build from there with Sass and build “components” using BEM like you would in React. So you end up having something like `Card.scss` holding `Card`, `Card__heading`, `Card__content`, etc. Utility classes like `text-right` are nice to have. Separate layout and styles may be good too, for theming. Sites like <https://css-tricks.com> gives a lot of insights to cope with HTML/CSS complexity.
2019-04-13T05:26:08.109800
Hoa
elmlang
general
How do you all go about benchmarking elm code? I'm writing a game and the logic running in each animation frame is taking 40ms when it should be less than 16ms.
2019-04-13T06:51:25.114400
Jae
elmlang
general
I know it has to be a CPU bottleneck because there was no performance improvements when I modified my view function to not make an dom changes.
2019-04-13T06:52:15.114500
Jae
elmlang
general
I looked at the performance tab in Chromes dev tools but it just tells me A4, anonymous, and garbage collection are taking most of the time. It doesn't give me any understandable function names
2019-04-13T06:53:09.114700
Jae
elmlang
general
Is my only option to slowly remove different parts of my code until I notice a speedup?
2019-04-13T06:54:13.114900
Jae
elmlang
general
the bottom-up tab gives functions with the most self time. you can click on them to go to their definition where you can see the actual name
2019-04-13T06:55:05.115100
Virgie
elmlang
general
do you by any chance do record updates in your loop? they are known to be slow
2019-04-13T06:56:16.115300
Virgie
elmlang
general
Bottom up looks like this for me.
2019-04-13T06:57:51.115500
Jae
elmlang
general
I probably do have record updates all over the place
2019-04-13T06:58:09.115900
Jae
elmlang
general
The alternative to record updates is to recreate the record manually instead of using the update syntax?
2019-04-13T06:58:50.116100
Jae
elmlang
general
yes
2019-04-13T07:01:22.116300
Virgie
elmlang
general
try that first, I think that will help a lot. Then the debugger takes a lot of time (so don't do performance measurement while in --debug)
2019-04-13T07:02:37.116500
Virgie
elmlang
general
perhaps you could let it run for a little while to get more robust numbers
2019-04-13T07:02:52.116700
Virgie
elmlang
general
Definitely turn off the debugger if you want to have any clue about performance. It serializes the entire state, in a not-super-performant way, on every message. If you have a subscription to animation-frames and non-trivial state, that'll kill performance.
2019-04-13T07:05:28.116900
Huong
elmlang
general
Turning off the debugger completely fixed the issue.
2019-04-13T07:06:33.117100
Jae
elmlang
general
`--optimize` can also improve performance a bunch, especially when you have lots of boxed types (custom types with a single constructor)
2019-04-13T07:08:11.117300
Huong
elmlang
general
True. I want to avoid that though because then I lose hot reloading and Debug.log
2019-04-13T07:09:22.117500
Jae
elmlang
general
In the future, if I have the debugger off and I've avoided using the update syntax inside loops, is there a good way of figuring out what elm functions are taking a lot of CPU time?
2019-04-13T07:11:53.117700
Jae
elmlang
general
I'm worried I'm going to run into performance issues and then have to resort to picking apart my app when trying to find the hot path so I can know what to optimize
2019-04-13T07:13:02.117900
Jae
elmlang
general
I've found the bottom up tab to be helpful (click on the blue links/line numbers to go to the actual functions and see their name)
2019-04-13T07:13:45.118100
Virgie
elmlang
general
another useful thing is using what <@Virgie> describes to figure out hot code-paths, picking out the largest offender, benchmarking it and figuring out how to optimize that. If you ever get to that point, feel free to poke me and I'll gladly try and help you out!
2019-04-13T07:16:07.118300
Huong