workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | <@Christoper> yep, that's a good solution. | 2019-04-01T21:51:47.234200 | Earlean |
elmlang | general | There are at least two issues for code that has similar behavior.
<https://github.com/elm/core/issues/993>
<https://github.com/elm/core/issues/980>
Apparently, it doesn’t work to change `Time.every` subscriptions dynamically. I’m going to just use a single `Time.every(100, SomeMsg)` call, with a tiny state machine. That appears to work. | 2019-04-02T03:49:10.235100 | Granville |
elmlang | general | Anyone hit this use case when doing an SPA? <https://github.com/elm/browser/issues/71> | 2019-04-02T03:59:03.235400 | Zachary |
elmlang | general | Maybe you’re looking for <https://package.elm-lang.org/packages/elm/browser/latest/Browser-Navigation#replaceUrl> ? (re-reading your issue, probably not) | 2019-04-02T04:06:14.235800 | Lea |
elmlang | general | I think this still trigger url change msg | 2019-04-02T04:14:17.236100 | Zachary |
elmlang | general | Probably, I can’t think of a component level solution | 2019-04-02T04:19:38.236300 | Lea |
elmlang | general | Can you expand on what you're trying to do? I don't really understand what the problem you're encountering is | 2019-04-02T04:23:25.236500 | Earlean |
elmlang | general | If you use "path" based url routing for the different pages of your SPA, maybe you could handle tabs via fragments in the url <https://package.elm-lang.org/packages/elm/url/latest/Url-Parser#fragment> ? | 2019-04-02T04:41:33.236700 | Mindy |
elmlang | general | <@Earlean> I'm trying to add a path to history without triggering onUrlRequest | 2019-04-02T05:06:45.236900 | Zachary |
elmlang | general | Can you explain why you want to do that? | 2019-04-02T05:08:04.237100 | Earlean |
elmlang | general | Because the user is switching between tabs, inside a fraction of the page. SPA routing would trigger reload, while I already handle the transition inside the component itself | 2019-04-02T05:09:29.237400 | Zachary |
elmlang | general | You write the onUrlRequest function so you get to decide what it does. If you don't want it to result in any changes to your model you can just have it do that. | 2019-04-02T05:10:18.237600 | Earlean |
elmlang | general | Hmm, that got me thinking, I could filter out the routes I'm not interested in | 2019-04-02T05:13:41.237800 | Zachary |
elmlang | general | Thanks <@Earlean> | 2019-04-02T05:14:07.238000 | Zachary |
elmlang | general | Is there any editor plugin out there for elm that adds a project tree? Like a list of links to functions/types in a file, as opposed to just filenames? | 2019-04-02T05:34:36.238900 | Gertrude |
elmlang | general | Also, some guidelines about how to refactor a large single Main into smaller files maybe ... I'm hitting 700 lines here and it's getting unweildy | 2019-04-02T05:35:13.239600 | Gertrude |
elmlang | general | Intellij Idea with help of <@Carl>'s Elm plug-in displays structure of selected Elm file in a separate pane. It is also accessible by Ctrl/Cmd+F12 - very easy to navigate. And there is also "Go to symbol" action to navigate to a known function anywhere | 2019-04-02T05:41:47.242000 | Lynne |
elmlang | general | <@Gertrude> one thing you can do is pull dependencies out by concern. For example, you could extract the `Model` type from your main into its own `Model.elm` file and pick things that focus on the model (transformation functions used in `update`, etc.) into this file, maybe factor some parts of update into it, taking care about not putting other concerns into it (i.e. a function that uses `Model` and `Msg` like `update` should probably not go into your `Model.elm` file). | 2019-04-02T05:43:26.243600 | Antonette |
elmlang | general | Once you've got a `Model.elm` file you may want to extract your `view` function from your main file to put it into its own `View.elm` file ; this `View.elm` file can import whatever it needs from your `Model.elm` module just as the `Main.elm` file does, etc. | 2019-04-02T05:44:56.245400 | Antonette |
elmlang | general | Another thing is recognizing parts that repeat ; maybe you've got tabs that are very similar but for a couple of params (the message they send when clicked on, the label of the tab, whether it's the current tab or not, ...) ; that might be tighter and easier to update if you factored the common code. | 2019-04-02T05:47:25.247800 | Antonette |
elmlang | general | One last way I'd mention here is when you've got something that clearly is a subpart of the main view and acts like its own little view (its got its own subpart of your `Model`, it could have its own `Msg` and `update`, it has its own `view`, ...) ; this is a good sign that you could factor this out in its own module (or set of modules depending on its size and complexity). | 2019-04-02T05:49:29.250200 | Antonette |
elmlang | general | The trouble I seem to come to is circular dependencies, as well as where to separate concerns | 2019-04-02T05:50:06.250700 | Gertrude |
elmlang | general | <@Gertrude> 700 lines is not much though I think | 2019-04-02T05:51:42.252000 | Nana |
elmlang | general | So much relies on each other, ie. Model and Msg are referred to almost everywhere, for example, so it's hard to refactor anything out. | 2019-04-02T05:51:46.252100 | Gertrude |
elmlang | general | especially when you have something like the IntelliJ structure view | 2019-04-02T05:52:13.253100 | Nana |
elmlang | general | <@Gertrude> that's why I started mentionning that your `Model` and `Msg` types could live in their own file actually :wink: they're usually good "leaf" modules that you can (and probably should) de-couple as soon as possible to make factoring parts easier and less loop-inducing. | 2019-04-02T05:52:37.253700 | Antonette |
elmlang | general | The anti-pattern as far as my experience got me is to bring into your `Model` and `Msg` module dependencies that don't exclusively work on their own concern (i.e. how to manipulate the model and how to define your messages). | 2019-04-02T05:53:51.254600 | Antonette |
elmlang | general | One mantra that could help is: "that it works with my `Model`/`Msg`/`whatever` does not necessarily mean I should put it in the `Model`/`Msg`/`whatever` module". | 2019-04-02T05:56:46.256100 | Antonette |
elmlang | general | <@Gertrude> is it helping a bit? :slightly_smiling_face: | 2019-04-02T05:59:35.257700 | Antonette |
elmlang | general | <@Antonette> a bit. (sorry about slow reply, so many meetings ...) | 2019-04-02T07:22:42.258400 | Gertrude |
elmlang | general | I think the take away is separating types in their own namespaces and not necessarily bringing more than helper functions along with. | 2019-04-02T07:23:02.258900 | Gertrude |
elmlang | general | I also have some past experience with a much larger project that was largely split along Model/Update/View lines, and the problem I had with that was that it wound up with every change having to touch a dozen files and it being hard to find out where Compenent lives, where Component has to refer to Model, send Msg, needs update changes to handle Msg, etc etc | 2019-04-02T07:24:48.260800 | Gertrude |
elmlang | general | Also I think one problem with this as written is that I often pass down the entire model even to relatively small subcomponents, because the nature of the design I'm replicating is such I often need access even at the micro level | 2019-04-02T07:34:45.262400 | Gertrude |
elmlang | general | As a side question, do you know about Evan's talk "The Life of a File"? He addresses the topic of when and what to extract to modules | 2019-04-02T07:43:03.263500 | Sharon |
elmlang | general | I have heard of it, but not watched it yet. | 2019-04-02T07:45:46.263800 | Gertrude |
elmlang | general | I should. | 2019-04-02T07:45:48.264000 | Gertrude |
elmlang | general | Once upon a time I was shown a website similar to Haskell's Hoogle[1], but for Elm. It allows the user to search for functions by type. It was magical.
Now, I can't find it. Please help.
[1] <https://hoogle.haskell.org/> | 2019-04-02T07:57:15.265100 | Briana |
elmlang | general | <@Briana> <https://klaftertief.github.io/elm-search/> | 2019-04-02T07:57:58.265400 | Nana |
elmlang | general | B O O K M A R K E D | 2019-04-02T07:58:13.265700 | Briana |
elmlang | general | Thank you! | 2019-04-02T07:58:17.265900 | Briana |
elmlang | general | If you ever loose the bookmark, the search is linked as “Fancy Search” int the sidebar of the elm package website. | 2019-04-02T08:07:31.266100 | Jin |
elmlang | general | (my time to be late to the party :sweat_smile: sorry, lunch happened) | 2019-04-02T08:35:38.266300 | Antonette |
elmlang | general | I know your pain there :wink: coming to elm from a background in imperative programming I was under the impression the Elm architecture was a lot more constricting than it is (I was trying to always write my `update` functions as `Msg -> Model -> (Model, Cmd Msg)` for example). | 2019-04-02T08:38:23.266500 | Antonette |
elmlang | general | So I tended to work as if with components (as in every component had a `Model`, `Msg`, `init`, `update` and `view`, ... even when there was no need for a state or messages). | 2019-04-02T08:39:21.266700 | Antonette |
elmlang | general | Also I was using a lot of `Html.map` and `Cmd.map` and `Sub.map` etc. | 2019-04-02T08:40:28.267000 | Antonette |
elmlang | general | Now I tend to grow my code more organically, starting with one file, then extracting when I feel like a file has grown too large usually getting types and their helpers out first then maybe extracting sub-views, etc. not necessarily giving them a `Model` or `Msg` and all the bells and whistles. | 2019-04-02T08:41:40.267300 | Antonette |
elmlang | general | As for touching a dozen files, it's not necessarily always as bad as it sounds. I especially like using refactor pattern like using type aliases for simple types then growing them into full-fledged types and using the compiler as a refactor tool that tells me where the change in contract is messing things up and working them from there. | 2019-04-02T08:43:15.267500 | Antonette |
elmlang | general | Yeah. I think in this case, the types that are all that big are mostly already factored out, ie. I have a `Types` module ATM which contains all my common data types and their JSON encoders/encoders and any helper functions for working with them. But something like `Msg` almost doesn't make sense to factor out because it's basically the smallest type in my code. XD | 2019-04-02T08:43:33.267700 | Gertrude |
elmlang | general | ie. It's not Msg that's big, it's `update`, but factoring that out without also factoring out `Model` and `Msg` quickly gets into cyclic dependency territory | 2019-04-02T08:44:38.267900 | Gertrude |
elmlang | general | Indeed. | 2019-04-02T08:45:40.268100 | Antonette |
elmlang | general | That's why I wouldn't advise you to start with factoring out something that has dependencies. | 2019-04-02T08:45:53.268300 | Antonette |
elmlang | general | It's like playing mikado ; you want to pull the fancy stick at the bottom only once you've moved enough of the easy ones up. | 2019-04-02T08:46:25.268500 | Antonette |
elmlang | general | :wink: | 2019-04-02T08:46:26.268700 | Antonette |
elmlang | general | I'm building an elm app that should be embeddable/reused in different apps, and it takes some configuration (via flags). What's the best way to include/embed the elm app in different sites? | 2019-04-02T09:05:43.270400 | Chin |
elmlang | general | Here are some framework Integration examples created by Evan. There can be some additional life cycle stuff you have to address but they're a good starting point how to implement it in general. <https://github.com/andys8/components?files=1> | 2019-04-02T12:32:23.271100 | Millie |
elmlang | general | Interesting math:
```
> xCoordinates 5 0.1
[0, 0.1, 0.2, 0.30000000000000004, 0.4]
: List Float
```
List is computed by adding 0.1 to the previous item | 2019-04-02T13:16:17.272400 | Jana |
elmlang | general | welcome to floating points :slightly_smiling_face: | 2019-04-02T13:17:41.272700 | Virgie |
elmlang | general | :cry: | 2019-04-02T13:18:03.272900 | Jana |
elmlang | general | equalz f1 f2 = (fabs (f1-f2)) < 0.0000000001 :grimacing: | 2019-04-02T13:18:56.273700 | Lindsey |
elmlang | general | there are other solutions (like rationals) but they have much worse performance | 2019-04-02T13:19:58.274400 | Virgie |
elmlang | general | <@Jana> in general there's no avoiding floating point roundoff completely, but you should be able to get nicer/more accurate results by using division instead of repeated floating point addition:
```
> List.map (\i -> toFloat i / 10) (List.range 0 4)
[0,0.1,0.2,0.3,0.4] : List Float
``` | 2019-04-02T13:40:20.276400 | Janiece |
elmlang | general | <@Janiece> Thanks, that’s a great suggestion. Am making a little barChart widget. | 2019-04-02T13:49:00.278500 | Jana |
elmlang | general | Using division has the advantage that something like
```
List.map (\i -> toFloat i / 1000) (List.range 0 1000000)
```
to step from 0 to 1000 in 0.001 increments will give you *exactly* 1000 as the last value - repeatedly adding 0.001 a million times would definitely not guarantee that | 2019-04-02T13:49:41.278700 | Janiece |
elmlang | general | And in general you tend to get nice numbers even near the end:
```
> List.map (\i -> toFloat i / 1000) (List.range 0 1000000) |> List.reverse |> List.take 5 |> List.reverse
[999.996,999.997,999.998,999.999,1000]
``` | 2019-04-02T13:50:09.279200 | Janiece |
elmlang | general | happy to help <@Jana>! | 2019-04-02T13:50:39.279400 | Janiece |
elmlang | general | BTW I actually experimented a while ago with an API for generating `Float` ranges in a flexible/accurate/efficient way
<https://github.com/ianmackenzie/elm-geometry/blob/master/src/Float/Range.elm>
See the doc comments for `numSteps` and `maxStepSize` for basic usage examples
I didn't end up needing the module myself, but I'd be happy to publish it if it would be useful for others (perhaps part of <https://package.elm-lang.org/packages/ianmackenzie/elm-float-extra/latest/>)
Or feel free to just copy that module into your own project and tweak it to fit your needs - zero dependencies! | 2019-04-02T14:04:05.282200 | Janiece |
elmlang | general | (the code is relatively long/complex because I tried to handle all sorts of input corner cases, and generate lists "in reverse" to avoid the unnecessary list traversals/memory allocations you get when using `List.range`/`List.map` etc.) | 2019-04-02T14:06:03.283500 | Janiece |
elmlang | general | There's some Decimal packages:
```
$ npx elm repl
> import Decimal as D
> import List.Extra exposing (scanl)
> scanl (\_ acc -> D.add acc (D.fromIntWithExponent 1 -1)) D.zero (List.repeat 4 ()) |> List.map D.toString
["0","0.1","0.2","0.3","0.4"]
``` | 2019-04-02T14:07:04.283600 | Earnest |
elmlang | general | Thanks <@Janiece>, I’ll take a look at that. | 2019-04-02T14:12:56.284300 | Jana |
elmlang | general | looking at the code again I realize that it's not actually using the division trick, it's basically using `start + n * stepSize` which should be more accurate than repeated additions but a bit less accurate than division | 2019-04-02T14:15:10.286100 | Janiece |
elmlang | general | can't remember exactly why I went that route :stuck_out_tongue: | 2019-04-02T14:15:42.286700 | Janiece |
elmlang | general | Floating points are so weird! | 2019-04-02T14:18:52.287000 | Jana |
elmlang | general | The inaccuracy here really has no effect, other than a psychological one on me :smile: | 2019-04-02T14:19:25.287700 | Jana |
elmlang | general | yeah the psychological effect is strong! | 2019-04-02T14:26:17.288200 | Janiece |
elmlang | general | but I think can be counterbalanced a bit when you look at how accurate something like 0.30000000000000004 actually is | 2019-04-02T14:27:01.288700 | Janiece |
elmlang | general | 4e-17 is a ridiculously tiny number | 2019-04-02T14:27:24.289300 | Janiece |
elmlang | general | a `Float` can represent the radius of the earth (6371 kilometers) to an accuracy of about a ten-millionth of a millimeter | 2019-04-02T14:30:28.290100 | Janiece |
elmlang | general | Hi, what's the canonical way to manage the user authentication with Elm? (is there an auth0 support ?) | 2019-04-02T15:04:53.291100 | Jesusa |
elmlang | general | there’s no canonical way, it’s left up to you | 2019-04-02T15:22:02.291400 | Alicia |
elmlang | general | there is an auth0 package to help with it for auth <https://package.elm-lang.org/packages/kkpoon/elm-auth0/latest/> | 2019-04-02T15:22:16.291800 | Alicia |
elmlang | general | Also, what's the story with mobile app dev? are there any docs/posts I could checkout | 2019-04-02T15:29:29.292500 | Jesusa |
elmlang | general | <@Jesusa> Cordova or another kind of webview should definitely work if you're into that | 2019-04-02T15:44:10.293300 | Nana |
elmlang | general | Did anyone here use bytes so far as a replacement for JSON? Did you run benchmarks? (I'm running benchmarks preparing for my elm-europe talk, and it seems that at least for data with a lot of strings, bytes are much slower than json) | 2019-04-02T17:49:45.293900 | Virgie |
elmlang | general | and for those interested, the kernel code is here <https://github.com/elm/bytes/blob/master/src/Elm/Kernel/Bytes.js#L152>. maybe we can pre-allocate the minimal string width (no idea if that helps) and make larger reads (so read 32 bits at once instead of 8 bits repeatedly) | 2019-04-02T17:52:29.296000 | Virgie |
elmlang | general | That's interesting! json parsing has the advantage of being implemented in C++ in the browser I guess. | 2019-04-02T17:54:01.296800 | Lindsey |
elmlang | general | How much time do you have at hand? I could probably patch you the compiler so you could experiment with it. | 2019-04-02T17:54:40.297700 | Niesha |
elmlang | general | I think json could efficiently copy the whole string (i.e. find opening quote, find closing quote, `String.slice` the intermediate part), and `Bytes` needs to do more work | 2019-04-02T17:55:44.298800 | Virgie |
elmlang | general | <@Niesha> I will give that a go, but would like some more data first. I want to also try an example with mostly numbers | 2019-04-02T17:57:17.300100 | Virgie |
elmlang | general | I'm decoding a list of objects from JSON and right now, everything blows up if one of the objects are formatted incorrectly. How can I just ignore the broken objects and keep the good ones? | 2019-04-02T18:10:06.301500 | Janna |
elmlang | general | if the json is incorrectly formatted it cannot be decoded | 2019-04-02T18:12:58.301700 | Virgie |
elmlang | general | and the parser cannot know from what point the input is correctly formatted again | 2019-04-02T18:13:24.301900 | Virgie |
elmlang | general | I have a small example of decoding a bunch of numbers here: <https://github.com/bburdette/stl/tree/master/example> | 2019-04-02T18:16:09.302400 | Lindsey |
elmlang | general | Can't I do some magic with `Json.Decode.oneOf` or `.andThen` or something? | 2019-04-02T18:16:17.302500 | Janna |
elmlang | general | <@Janna> yep, you can use `Json.Decode.oneOf` and have the second decoder listed produce a value indicating failure to decode | 2019-04-02T18:16:40.302700 | Earlean |
elmlang | general | depends on how ill-formatted the json is though. If the list structure is correct then `oneOf` should work | 2019-04-02T18:18:02.303000 | Virgie |
elmlang | general | <https://ellie-app.com/592mLqnXrWha1> | 2019-04-02T18:19:02.303200 | Nana |
elmlang | general | oh actually you don't even need `oneOf` :smile:
just `Decode.list (Decode.maybe <http://Decode.int|Decode.int>)`
<https://ellie-app.com/592scSKT4jYa1> | 2019-04-02T18:25:19.303600 | Nana |
elmlang | general | Thanks :slightly_smiling_face: | 2019-04-02T19:06:05.304000 | Janna |
elmlang | general | You can also slip in a `filterMap` to get rid of the `Maybe` <https://ellie-app.com/593vG3m3W8ja1> | 2019-04-02T19:34:27.304300 | Hoyt |
elmlang | general | I’m kind of a lurker here, but I wanted to let everyone know that I was really inspired by the json decoders/encoders in Elm. they reminded me a little of the scalaz stuff I used to work on. I build a similar decoder library to elm’s in Go: <https://github.com/go-functional/dcode/> | 2019-04-02T20:18:00.305600 | Lakita |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.