workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | Ah okay apparently I've been structuring my code the nonstandard way.
My question still applies. What's the advantage of that way over `.map`? | 2019-01-26T08:39:39.030400 | Rico |
elmlang | general | The advantage is less typing. It's shorter to pass in a function than to always `.map`, but the result is equivalent. | 2019-01-26T08:42:03.032800 | Earlean |
elmlang | general | Imagine of every time you used `Html` you had to `Html.map` it to your msg type. It ends up pretty messy | 2019-01-26T08:46:47.035900 | Earlean |
elmlang | general | I guess I see that with like `onInput`, but I'm not sold on it more generally. But I have learned enough to get back to writing code. Thanks :) | 2019-01-26T08:50:50.039200 | Rico |
elmlang | general | You see it in other places too, `Json.Encode.list` takes a function to encode the items in the list because you're always going to need to do that. | 2019-01-26T08:53:05.042600 | Earlean |
elmlang | general | <@Lynne> thanks again for the pointer… you were of course absolutely right about the interchangeability of the types. I don’t know how I missed the obvious there… :man-facepalming: | 2019-01-26T08:53:15.042900 | Moshe |
elmlang | general | It happens :slightly_smiling_face: | 2019-01-26T08:53:34.043100 | Lynne |
elmlang | general | <@Rico> in fact, if you're doing it with`Html` you'd be using `Attribute.map` on `onInput` for each attribute because different events produce different types of values | 2019-01-26T08:55:53.046000 | Earlean |
elmlang | general | <@Rico> This is true of `Sub` and `Cmd` too. Try it out for yourself by always passing the `identity` to these kinds of functions and `.map` them all | 2019-01-26T08:58:28.048700 | Earlean |
elmlang | general | Yup, tried it on its feet and works really well. Thanks for the millionth time, Joel. | 2019-01-26T11:53:37.049800 | Cammy |
elmlang | general | Glad to help! :slightly_smiling_face: | 2019-01-26T14:28:17.050000 | Carman |
elmlang | general | Is there an issues with responsive design mode in FF and Chrome and the values from `Browser.Dom.getViewport` and `Browser.Events.onResize` ? | 2019-01-27T11:31:58.053300 | Chandra |
elmlang | general | Like when "touch simulation" is enabled in FF it seems to report the wrong sizes. | 2019-01-27T11:36:46.054200 | Chandra |
elmlang | general | And with "touch simulation" disabled it works fine. | 2019-01-27T11:39:37.055100 | Chandra |
elmlang | general | In chrome I experienced something similar with desktop vs mobile mode, where mobile mode seemed to report inaccurate dimensions. | 2019-01-27T11:42:01.056500 | Chandra |
elmlang | general | It _might_ be the "device pixel ratio" (DPR) kicking in, or vaguely related to that | 2019-01-27T17:46:46.057800 | Huong |
elmlang | general | Hey! :wave:
I am trying to integrate `billstclair/elm-geolocation` into my app. From what I read in the docs one of the things to do is to invoke `PortFunnel.subscribe(app, {modules: modules});` in my `index.js` where `app` is sth like ```const app = Elm.Main.init({
node: document.getElementById('root'),
});```
my app is already working yet the `app` object (I haven't used before) seems to be an empty Object `{}` | 2019-01-27T18:00:15.060800 | Evie |
elmlang | general | Oh, there might be something with needing to include:
```
<meta name="viewport" content="width=device-width, initial-scale=1.0">
``` | 2019-01-27T18:57:30.061000 | Cornell |
elmlang | general | in the `head` | 2019-01-27T18:57:34.061200 | Cornell |
elmlang | general | I'll give it a shot, thanks. :slightly_smiling_face: | 2019-01-27T21:42:46.061500 | Chandra |
elmlang | general | Would that only be needed for testing. Like if I opened the page on a phone would it still need that I'm the head. | 2019-01-27T21:46:12.061800 | Chandra |
elmlang | general | <@Evie> they will be a `ports` field on `app` is your have ports defined in your Elm app that you're using. | 2019-01-27T22:10:39.063500 | Earlean |
elmlang | general | If you define ports but don't have any code that sends to them or subscribes to them then the dead code elimination the compiler does will remove them so they won't be available on `app.ports` in JS. | 2019-01-27T22:12:00.065900 | Earlean |
elmlang | general | I'm thinking of setting up a CMS to store all the text for my app, so that it can easily be edited. Does anyone have a recommendation for a good "headless CMS"?
ie. it should probably produce JSON, and be configurable to store different kinds of info, like news posts, help texts, i18n dictionary and such, and the text should be easy to edit for non-programmers | 2019-01-28T04:14:34.069900 | Nana |
elmlang | general | or actually, maybe GraphQL would be better, together with `dillonkearns/elm-graphql` :thinking_face: | 2019-01-28T04:15:26.070400 | Nana |
elmlang | general | <@Nana> you can either injectit at compile time when you build the docker container, as I do, or use airtable, which I do on some other projects XD | 2019-01-28T04:18:11.072100 | Euna |
elmlang | general | <@Euna> hmm haven't heard of Airtable :thinking_face: So is it like Jira + Confluence + database? | 2019-01-28T04:25:56.075100 | Nana |
elmlang | general | we're generally not allowed to use cloud services though :stuck_out_tongue: | 2019-01-28T04:29:14.075400 | Nana |
elmlang | general | looks kinda cool though | 2019-01-28T04:30:42.075700 | Nana |
elmlang | general | if youre not allowed to use cloud and can only on prem | 2019-01-28T04:45:47.076000 | Euna |
elmlang | general | dotCMS is the only thing that I can think of that isnt a blog cms | 2019-01-28T04:46:09.076600 | Euna |
elmlang | general | and can run on prem | 2019-01-28T04:46:15.076800 | Euna |
elmlang | general | other than doing it yourself | 2019-01-28T04:46:19.077000 | Euna |
elmlang | general | if you do, can't recommend gqlgen enough for graphql | 2019-01-28T04:46:32.077500 | Euna |
elmlang | general | (<https://pastebin.com/45QLqyf4>) I have a snippet here which takes a rowindex and col index and attempts to update a `Array (Array a` (grid.rows). I feel like I'm doing it right but it's not working. The error message indicates that the argument is Row while it's expecting an Array of Cells. Which again makes sense because Row is a type alias with some extra state involved. My question is how can I change it so that it maps over the entire record but leaves everything except for the inner array as it was? | 2019-01-28T05:29:47.081100 | Olevia |
elmlang | general | @Sybil consider this :
```
updateAtIndex : (a -> a) -> Int -> Array a -> Array a
updateAtIndex transformation targetIndex =
Array.indexedMap
(\index item ->
if index == targetIndex then
transformation item
else
item
)
updateCell : ( Int, Int ) -> String -> Grid -> Grid
updateCell ( row, col ) input grid =
let
updatedRows =
grid.rows
|> updateAtIndex (updateAtIndex (validateInput input) col) row
in
{ grid | rows = updatedRows }
``` | 2019-01-28T05:38:37.082600 | Antonette |
elmlang | general | (this is just a simple refactor extracting the index update mechanism) | 2019-01-28T05:39:12.083100 | Antonette |
elmlang | general | First thing I noticed that made me question what's happening here is that you were putting the updated rows in a var named `updatedGrid` ; I supposed that you had tried to return this (which is not a grid) instead of an updated version of your grid (which your function declares it returns), and fell back to returning the original grid when this was not working to your satisfaction (and probably not compiling). | 2019-01-28T05:41:06.084900 | Antonette |
elmlang | general | Exactly, but I also have the problem 1 level deeper | 2019-01-28T05:41:46.085700 | Olevia |
elmlang | general | Another thing that I noticed was that you were basically repeating the updating at an index pattern, hence the refactor. | 2019-01-28T05:41:49.086000 | Antonette |
elmlang | general | so I kind of lied, since the rows isnt a Array (Array Cell) but rather a Array(Row) which is a record with Array Cell | 2019-01-28T05:42:12.086800 | Olevia |
elmlang | general | There might even be a function that allows you to update an array at an index in the standard lib if you want to go standard :wink: | 2019-01-28T05:42:14.087000 | Antonette |
elmlang | general | so that means i have to destructure a record somewhere in there aswell | 2019-01-28T05:42:39.087600 | Olevia |
elmlang | general | Yep :slightly_smiling_face: | 2019-01-28T05:42:47.087800 | Antonette |
elmlang | general | Let's do this then. Let's assume your row records have a `cells` field which are the cells. | 2019-01-28T05:43:20.088600 | Antonette |
elmlang | general | ```
updateAtIndex : (a -> a) -> Int -> Array a -> Array a
updateAtIndex transformation targetIndex =
Array.indexedMap
(\index item ->
if index == targetIndex then
transformation item
else
item
)
updateCells : (b -> b) -> { a | cells : Array b } -> { a | cells : Array b }
updateCells transformation row =
{ row | cells = transformation row.cells }
updateCell : ( Int, Int ) -> String -> Grid -> Grid
updateCell ( row, col ) input grid =
let
updatedRows =
grid.rows
|> updateAtIndex (updateCells (updateAtIndex (validateInput input) col)) row
in
{ grid | rows = updatedRows }
``` | 2019-01-28T05:45:33.088800 | Antonette |
elmlang | general | (edited, we needed the transformation un `updateCells` to be from the same origin type to the same target type) | 2019-01-28T05:46:54.090200 | Antonette |
elmlang | general | seeing it makes it click, but there was no way i was going to do that all in one function block | 2019-01-28T05:48:40.090700 | Olevia |
elmlang | general | I tend to push to much into 1 function, big mistake | 2019-01-28T05:48:56.091200 | Olevia |
elmlang | general | :slightly_smiling_face: | 2019-01-28T05:49:01.091400 | Antonette |
elmlang | general | Not necessarily, with proper composition it's not necessarily that hard. | 2019-01-28T05:49:15.091800 | Antonette |
elmlang | general | Now using the same update pattern to update the grid, you can come up with something like this:
```
updateAtIndex : (a -> a) -> Int -> Array a -> Array a
updateAtIndex transformation targetIndex =
Array.indexedMap
(\index item ->
if index == targetIndex then
transformation item
else
item
)
updateCells : (b -> b) -> { a | cells : Array b } -> { a | cells : Array b }
updateCells transformation row =
{ row | cells = transformation row.cells }
updateRows : (b -> b) -> { a | rows : Array b } -> { a | rows : Array b }
updateRows transformation grid =
{ grid | rows = transformation grid.rows }
updateCell : ( Int, Int ) -> String -> Grid -> Grid
updateCell ( row, col ) input =
updateRows (updateAtIndex (updateCells (updateAtIndex (validateInput input) col)) row)
``` | 2019-01-28T05:49:41.092300 | Antonette |
elmlang | general | (sorry for the multiple edits, I realized I misplaced a couple of parens along the way) | 2019-01-28T05:51:48.093300 | Antonette |
elmlang | general | Now, if you'd like to go even further into composition, there is a pattern you might want to discover... <https://package.elm-lang.org/packages/arturopala/elm-monocle/latest> | 2019-01-28T05:52:44.094800 | Antonette |
elmlang | general | no problem, i dont think this is somethign that I could've managed in a timely manner with without the help of this slack so thanks a lot | 2019-01-28T05:52:48.095000 | Olevia |
elmlang | general | My pleasure :slightly_smiling_face: | 2019-01-28T05:53:06.095500 | Antonette |
elmlang | general | i'll be sure to check out that package | 2019-01-28T05:53:11.095700 | Olevia |
elmlang | general | The idea is to package those kinds of "take something, put it back modified" into nice data structures that composes. | 2019-01-28T05:53:49.096500 | Antonette |
elmlang | general | Which would give you something like:
```
arrayAt : Optional (Array a) a
...
cellsLens : Lens Row (Array Cell)
...
rowsLens : Lens Grid (Array Row)
...
cellInGridAt : (Int, Int) -> Optional Grid Cell
cellInGridAt (row, cell) =
rowsLens
|> Compose.lensWithOptional (arrayAt row)
|> Compose.OptionalWithLens cellsLens
|> Compose.OptionalWithOptional (arrayAt cell)
updateCell : (Int, Int) -> String -> Grid -> Grid
updateCell position input =
Optional.modify (cellInGridAt position) (validateInput input)
``` | 2019-01-28T06:00:21.102800 | Antonette |
elmlang | general | The idea with "optics" like you find in Monocle is that you wrap an "accessor" that can "zoom in (read and write into) a part of a structure and clip them together as lego bricks to make "deeper" and more specific accessors. | 2019-01-28T06:02:12.104700 | Antonette |
elmlang | general | This can result in very readable code where you aren't too bothered about the nitty gritty of how to access a specific part of a data structure and put it back together (which I find is the main pain in everyday Elm) once you've written a few of these optics. | 2019-01-28T06:03:41.106100 | Antonette |
elmlang | general | I apreciate it but that would be an insane amount of knowledge i need to absorb for just that functiom, i will definitely check it out though | 2019-01-28T06:07:49.106800 | Olevia |
elmlang | general | Sure, I didn't mean to push you to take it all in right now :wink: just giving you a little foretaste so you know what you can gain once you're fed up writing complicated accessors like that. | 2019-01-28T06:09:06.107800 | Antonette |
elmlang | general | (which, in my case, came quick after writing yet another modify-at-index-in-field-at-index-in-otherfield-in-yetanotherthirdfield kind of function) | 2019-01-28T06:10:02.108800 | Antonette |
elmlang | general | yeah, seems like a problem that shows up a lot | 2019-01-28T06:13:44.109100 | Olevia |
elmlang | general | Anyways, have fun, and never hesitate reaching out here :slightly_smiling_face: | 2019-01-28T06:17:10.110200 | Antonette |
elmlang | general | yeah, you’ll want to include that tag always. The default behaviour on mobile is for browsers to layout the page as if it is desktop size and to then show it super zoomed out | 2019-01-28T06:19:57.110300 | Shenita |
elmlang | general | <https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag> | 2019-01-28T06:20:02.110600 | Shenita |
elmlang | general | Wow, I have never in my life written a "modify-at-index-in-field-at-index-in-otherfield-in-yetanotherthirdfield kind of function". I suppose I've always kept my collections shallow. | 2019-01-28T06:23:22.111800 | Bert |
elmlang | general | That's what happens when you're using real-world complicated structures like a form composed of different types of questions which have in turn possible answers which can be composed of various fields which in turn may have multiple associated data. | 2019-01-28T06:25:32.113300 | Antonette |
elmlang | general | (which happens to be the case that made me reach out for Elm-Monocle and even contribute to it occasionally) | 2019-01-28T06:26:15.114200 | Antonette |
elmlang | general | I feel like I have dealt with real-world complicated structures (ref: <https://www.futurice.com/blog/elm-in-the-real-world/>) | 2019-01-28T06:27:56.115300 | Bert |
elmlang | general | I didn't mean to imply you haven't. I meant to express that sometimes, you need deeply nested data structures. | 2019-01-28T06:28:55.116400 | Antonette |
elmlang | general | (and with such cases, it's useful to have something that helps you traverse them) | 2019-01-28T06:29:17.116900 | Antonette |
elmlang | general | The case I'm referring to (for context) was such that we had an endpoint to pick up a form to edit, and an endpoint to save said form in its integrity. Making smaller endpoints to save only parts of the form and building it incrementally on the backend was not an option, so we had to have a structure that represented the form. Such a structure was deeply nested by design, and there was no way around it. Using optics helped us de-clutter the code tremendously. | 2019-01-28T06:31:51.119700 | Antonette |
elmlang | general | Also, another place where optics came up really, really handy is video-games, where a whole world of data lives in a more or less deeply nested structure and accessing the parts you need can become tedious and error-prone really fast. | 2019-01-28T06:33:09.121100 | Antonette |
elmlang | general | And I agree <@Bert> that keeping things small and shallow is the way to avoid useless complications and build more robust software whenever you can :wink: | 2019-01-28T06:37:04.124100 | Antonette |
elmlang | general | This was a great clarification! :+1: | 2019-01-28T06:38:35.124600 | Bert |
elmlang | general | What I meant by "real-world complicated structures" was more akin to "cases where you can't cut the big tree of data into smaller logs to feed smaller interfaces using small endpoints" rather than "structures in a real world you haven't gone to" :wink: | 2019-01-28T06:41:11.126500 | Antonette |
elmlang | general | (and since written media carries tone poorly...) | 2019-01-28T06:41:56.127100 | Antonette |
elmlang | general | I wish people used threads more on this Slack. Replies to questions drown in answers to other questions, and if they don't @ me, I often won't notice an answer. | 2019-01-28T08:12:19.128200 | Chaya |
elmlang | general | 100% agree. | 2019-01-28T08:39:33.128600 | Cammy |
elmlang | general | It's annoying to post/read any code in the tiny thread sidebar | 2019-01-28T09:45:42.129000 | Earnest |
elmlang | general | Especially on small monitors | 2019-01-28T09:45:56.129200 | Earnest |
elmlang | general | How do you run `elm reactor` on specific ip address | 2019-01-28T10:20:19.130200 | Phoebe |
elmlang | general | Threads are almost better on the mobile app than on desktop, which is kinda backwards. | 2019-01-28T10:20:52.130300 | Bert |
elmlang | general | ```
$ elm reactor --help
The `reactor` command starts a local server on your computer:
elm reactor
After running that command, you would have a server at <http://localhost:8000>
that helps with development. It shows your files like a file viewer. If you
click on an Elm file, it will compile it for you! And you can just press the
refresh button in the browser to recompile things.
You can customize this command with the following flags:
--port=<port>
The port of the server (default: 8000)
``` | 2019-01-28T10:22:15.130500 | Dede |
elmlang | general | I do not see any help for address | 2019-01-28T10:23:47.130700 | Phoebe |
elmlang | general | Yeah, it's pretty clear it's just running on localhost. | 2019-01-28T10:24:16.130900 | Dede |
elmlang | general | i remember that in 0.18 you can run elm reactor on custom address | 2019-01-28T10:24:45.131100 | Phoebe |
elmlang | general | with --address flag i think | 2019-01-28T10:25:00.131300 | Phoebe |
elmlang | general | Elm doesn't seem to be afraid to shed capabilities when they're judged not to be good for the overall ecosystem. As a workaround, if you're on Mac/Linux, I think you could probably set up a trivial port forwarder with `nc`. | 2019-01-28T10:26:18.131500 | Dede |
elmlang | general | I'm sure there's a windows equivalent. | 2019-01-28T10:26:29.131700 | Dede |
elmlang | general | I'm using linux but I dont have any experience using nc | 2019-01-28T10:30:24.131900 | Phoebe |
elmlang | general | something like `nc -s 0.0.0.0 -p 8080 localhost 8000` Replace 0.0.0.0 with something more specific if you like. | 2019-01-28T10:35:08.132100 | Dede |
elmlang | general | Hang on, I don't think I got that right. | 2019-01-28T10:37:25.132300 | Dede |
elmlang | general | yes it didnt work | 2019-01-28T10:38:07.132500 | Phoebe |
elmlang | general | I would like to run on 0.0.0.0 | 2019-01-28T10:39:56.132700 | Phoebe |
elmlang | general | Apologies for my dusty memory. Several options are in this thread, probably makes more sense for you to reference it directly than for me to recapitulate it. <https://unix.stackexchange.com/questions/10428/simple-way-to-create-a-tunnel-from-one-local-port-to-another> | 2019-01-28T10:46:23.132900 | Dede |
elmlang | general | An `nc` option is in the third answer, but requires a non-standard `nc` install on modern linux. | 2019-01-28T10:46:43.133200 | Dede |
Subsets and Splits