workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
Thinking out loud, when a new node is added to the design surface, I'd record its x,y coordinates in my model. On `onMouseDown`, I'd record the node that was selected and subscribe to `onMouseMove` events. As `onMouseMove` events come in, I'd update the x,y coordinates. On `onMouseUp`, I'd unsubscribe from the `onMouseMove` event.
2019-02-18T21:42:48.698300
Marcus
elmlang
general
I'm not sure what the algorithm is for drawing the edge between nodes. It's probably not that complex.
2019-02-18T21:44:04.698900
Marcus
elmlang
general
Anybody know how to have an incoming port with no input? From Firebase, I want to let my Elm app know that the user logged out, so I have this in my JS: ``` app.ports.loggedOut.send() ``` And this in my Elm: ``` port loggedOut : msg -> Sub msg subscriptions model = loggedOut LoggedOut ``` But that syntax is wrong…
2019-02-19T00:49:28.701100
Jacquelyn
elmlang
general
I couldn’t find in the Elm documentation how to do this
2019-02-19T00:50:14.701200
Jacquelyn
elmlang
general
We do ``` port loggedOut : (() -> msg) -> Sub msg subscriptions model = loggedOut (\_ -> LoggedOut) ``` JS: ``` app.ports.loggedOut.send(null); ```
2019-02-19T00:54:07.701400
Lizabeth
elmlang
general
Is it possible the JSON decoder is required even for a null argument?
2019-02-19T00:54:35.701600
Dede
elmlang
general
If <@Lizabeth>’s answer doesn’t resolve it, you could try a port with the full signature `(Json.Decode.Value -&gt; msg) -&gt; Sub msg`. You can probably just use `Json.Decode.succeed` for the decoder in that case.
2019-02-19T00:55:40.701800
Dede
elmlang
general
I’ve updated my answer to check properly what we were doing.
2019-02-19T00:59:51.702200
Lizabeth
elmlang
general
But I’m not sure if that is the proper way to do it, it just worked for us, so I kept using it.
2019-02-19T01:04:00.702500
Lizabeth
elmlang
general
AFAICT the implementation of Elm is the specification, so by definition if it worked it’s a proper way :wink:
2019-02-19T01:05:59.703200
Dede
elmlang
general
Have you seen kite by <@Reuben> yet? <https://github.com/erkal/kite>
2019-02-19T03:16:19.703600
Timika
elmlang
general
<@Marcus> Check this one <https://github.com/erkal/kite>
2019-02-19T03:31:04.704000
Walton
elmlang
general
Is the [measureText](<https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/measureText>) function available in any way in Elm 0.19?
2019-02-19T03:41:19.704700
Jannet
elmlang
general
No. Use ports, works well
2019-02-19T03:45:34.705400
Bebe
elmlang
general
Do you measure text somehow in `elm-canvas`? <@Bebe>
2019-02-19T03:55:23.705700
Jannet
elmlang
general
Okay I see how you did it <https://github.com/joakin/elm-canvas/blob/589fc02f427e5f192ef060292e65c64c91f6c477/public/dynamic-particles.html#L20>
2019-02-19T03:57:47.706800
Jannet
elmlang
general
Not supported, it is hard to fit into a functional paradigm. Ports work great
2019-02-19T03:58:08.707300
Bebe
elmlang
general
Yes that example does the initial calculations and point creation in JS, passes things to elm in flags. Works well too :+1:
2019-02-19T03:59:52.708800
Bebe
elmlang
general
Thanks for elm-canvas, I'll try something else. Ports and javascript don't work for me. Text is created dynamically and I don't want to produce top-level messages for text that changes every frame and can be used in rendering nested data
2019-02-19T04:01:09.709000
Jannet
elmlang
general
<@Walton> Hey, that's super cool. Thanks for pointing that out.
2019-02-19T04:52:51.709300
Marcus
elmlang
general
What is the philosophy on "duck typing" in Elm? ``` someFunction: { hasProp: String } someFunction x = -- ... x type alias A = { hasProp: String } type alias B = { hasProp: String } someFunction A someFunction B ``` I don't think this is possible at the moment. And I can see the argument for explicitness vs reusablity. But on the other hand... Its very handy. Would like some opinions on the matter. Does this break some stuff and remove any sort of type safety? I do not think it does. If this does already exist then please tell me so I can delete this question :stuck_out_tongue:
2019-02-19T05:41:31.713900
Renda
elmlang
general
I think you can do that with extensible records, although that functionality has been pruned in 0.19. Btw, I think the term you're looking for is "structural typing"
2019-02-19T05:42:58.714600
Niesha
elmlang
general
It's basically duck typing, but with types
2019-02-19T05:43:12.715000
Niesha
elmlang
general
As opposed to nominal typing
2019-02-19T05:43:15.715200
Niesha
elmlang
general
shouldn't that code just work since the type aliases are the same?
2019-02-19T05:45:46.715800
Sharon
elmlang
general
Exactly, <https://ellie-app.com/4M6STzJLzXka1>
2019-02-19T05:46:16.716000
Lynne
elmlang
general
type aliases are replaced with actual types before compilation
2019-02-19T05:47:08.716400
Lynne
elmlang
general
on my SPA example, i have been able to move to new page by clicking on the link but i can't type the url of that new link. i am facing `Cannot GET /page/50` error if i type <http://localhost:8000/page/50>
2019-02-19T06:01:17.717700
Leopoldo
elmlang
general
<@Niesha> <@Sharon> <@Lynne> ahh so this does actually work. I did not know that ^^. Also did not know that structural typing is the typed word for duck typing, thanks! So is this ok to use? I find it quite useful to type this way.
2019-02-19T06:07:19.720100
Renda
elmlang
general
Or are the caveeats to watch out for?
2019-02-19T06:07:51.721200
Renda
elmlang
general
<@Leopoldo> if you type a url then there will be a request to the server, your server needs to be able the handle those urls and respond with your elm app.
2019-02-19T06:08:57.722300
Earlean
elmlang
general
<@Renda> I think at some point your records will become so large that you will prefer coming with type aliases for them
2019-02-19T06:10:37.723100
Lynne
elmlang
general
Especially if you will want same record in and out
2019-02-19T06:10:56.723500
Lynne
elmlang
general
<@Earlean> is there any guide on elm url mapping to server and REST api ?
2019-02-19T06:18:58.724700
Leopoldo
elmlang
general
now my SPA app is on localhost:8000 and my local rest server is on port 9000 but if i have to move my app to a remote host, what are the guidelines? does it mean for my previous issue, i will need to make provision for a custom app (views) for the custom page i.e newpage.elm for page/{id} ?
2019-02-19T06:22:21.727900
Leopoldo
elmlang
general
<@Leopoldo> It really has nothing to do with Elm. Your Elm app is compiled to JavaScript and served as regular JS file, which, in turn, is linked from some HTML page (typically, `index.html`).
2019-02-19T06:23:50.729000
Lynne
elmlang
general
What you should look for and learn is how web content is served, what is HTTP and how it connects your browser and a remote server
2019-02-19T06:24:24.729700
Lynne
elmlang
general
Browser never loads any Elm file or module, it loads an HTML page (unless server returns something else, but that's a more advanced topic)
2019-02-19T06:26:45.732300
Lynne
elmlang
general
yes, i was referring to the compiled `elm`
2019-02-19T06:27:44.734100
Leopoldo
elmlang
general
<@Renda> Also, if you write the function type definition like this: `someFunction : {r | hasProp: String } -&gt; String` it will work on any record which has `hasProp: String`, not just those that look exactly like `{ hasProp: String }`
2019-02-19T06:31:13.737100
Nana
elmlang
general
Ohhhh I thought that was what the others meant. Because that is what I tried to accomplish!
2019-02-19T06:50:19.737300
Renda
elmlang
general
Thanks man!
2019-02-19T06:50:24.737500
Renda
elmlang
general
I hadn't, thanks very much
2019-02-19T08:07:58.739500
Vashti
elmlang
general
is there a way with elm/time to set a day/month/year??
2019-02-19T09:15:55.741600
Kizzie
elmlang
general
Has anyone whos upgrade to 0.19 had a problem with browser extentions? We just got our front end to 0.19, and now we are trying to build our whole product and get user testing, and we (might have) got some feedback that appeared to be a big virtual dom problem.
2019-02-19T09:34:37.742000
Ashton
elmlang
general
A difference in our upgrade, is that we were rendering in something like `&lt;div id="root"/&gt;` before, and now we are using `&lt;body/&gt;`, and so we are wondering what happens when a browser extention wants to stick something in the body.
2019-02-19T09:35:52.743400
Ashton
elmlang
general
(Before it might just put it above or below the root div, which might not clash with the virtual dom, but now interfering with the body might in fact clash with the virtual dom, since it would be injecting html next to the Elm rendered html)
2019-02-19T09:41:46.745800
Ashton
elmlang
general
<@Kizzie> you can use the justinmimbs/time-extra package
2019-02-19T09:43:12.746100
Nana
elmlang
general
<@Ashton> this has been an issue for some people
2019-02-19T09:43:51.746500
Agustin
elmlang
general
Yeah? Okay, thats interesting. You wouldnt happen to know of any information on this topic?
2019-02-19T09:49:46.746700
Ashton
elmlang
general
Have people had to implement any solutions to this?
2019-02-19T09:50:09.746900
Ashton
elmlang
general
We are just encountering the problem, so I dont have a sense of how severe it is.
2019-02-19T09:50:22.747100
Ashton
elmlang
general
related: <https://discourse.elm-lang.org/t/javascript-exception-cannot-read-property-childnodes-of-undefined-with-extension-dark-reader/2748/5?u=dmy>
2019-02-19T09:51:17.747300
Velia
elmlang
general
Thank you <@Lizabeth> and <@Dede>, Got it working with <@Lizabeth>’s suggestion… just changed `loggedOut (always LoggedOut)` for the subscription
2019-02-19T09:53:16.747500
Jacquelyn
elmlang
general
All anecdotal I’m afraid but I’ve seen multiple people complain about dom behaviour caused by browser extensions messing about with the dom.
2019-02-19T09:54:37.747700
Agustin
elmlang
general
Grammarly is pretty notorious for messing with SPA apps.
2019-02-19T09:55:27.748000
Rosa
elmlang
general
Thanks
2019-02-19T09:55:42.748200
Ashton
elmlang
general
Thats the big one, couldn’t recall the name
2019-02-19T09:56:00.748400
Agustin
elmlang
general
Okay. Thank you. Maybe if we just render every document with a `div []` at the top, then it will be protected from browser extensions adding things to the bottom, since the Elm virtual dom will never care about things below the solitary top `div []`
2019-02-19T09:57:24.748600
Ashton
elmlang
general
Thanks, i'll give it a try
2019-02-19T10:16:02.748800
Kizzie
elmlang
general
if you add an `type alias` for a record, Elm gives you a positional constructor for free to create it. this is extremely useful for applicative style json parsing (e.g. with the json-pipeline package) What do you think, are there other use cases where the the constructor should be used? Concretely, would you create larger records like ``` type alias User = { name: String, age: Int, active: Bool, items: List Product, sessionId: Id } ``` rather like this: `user = User "Me" 33 True [] (Id "235423")` or `user = { name = "Me", age = 33, active = True, items = [] , sessionId = Id "34321" }`
2019-02-19T11:04:00.753800
Earnestine
elmlang
general
its used in Decoders, but other than I prefer the record style, even for small ones
2019-02-19T11:05:52.754500
Rosa
elmlang
general
The downside of using this constructor is much worse readability. Also, if you have, say, two adjacent `Int` or `String` or whatever fields, it is very easy to put them in wrong order and compiler won't help you with it
2019-02-19T11:08:24.755900
Lynne
elmlang
general
Hi Chad! I am using 0.19.0 and I haven't run into any issue so far.. what problem exactly you're facing?
2019-02-19T11:12:46.756500
Paulita
elmlang
general
Hopefully someone could answer that. I'm using parcel to bundle code and I've got an issue with assets. I'm using assets as suggested in elm-spa example : <https://github.com/rtfeldman/elm-spa-example/blob/master/src/Asset.elm> However parcel does not bundle any of these images. The following library does load them to dist : <https://github.com/tiaanduplessis/parcel-plugin-asset-copier> but image names are suffixed with hashes and Elm code does not know that files are being suffixed.
2019-02-19T11:56:02.760100
Romona
elmlang
general
Something like `parcel build --no-content-hash src/index.html` could help you a bit. Files will still have a hash to them, but it _will not change_ based on the content but is static as long as the path to them does not change.
2019-02-19T12:03:34.761400
Timika
elmlang
general
AFAIK there is now way for parcel to know that you use your assets and cannot rename paths to them in your Elm code. So this (together with `parcel-plugin-asset-copier`) might be a decent workaround.
2019-02-19T12:05:16.762600
Timika
elmlang
general
(Disclaimer: I’ve never used `--no-content-hash` with `parcel-plugin-asset-copier` in production, this is merely an idea)
2019-02-19T12:06:31.763500
Timika
elmlang
general
(More disclaimer: This will also mess with HTTP caching if you serve your assets with an nearly-infinite `max-age` which is what is usually done when using content-aware hashes. This can be circumvented by using a different cache strategy though.)
2019-02-19T12:09:05.765100
Timika
elmlang
general
Alternatively, you could `import` your assets in your JS bootstrap code and pass the paths to Elm via flags and use them in your app instead. This way you don’t have to mess around with plugins, can keep content aware hashes and nearly-infinite `max-age` caching with the cost of handling flags, passing around your image paths to every view that uses them and more (albeit simple) javascript. Let me know if anything above helps. :slightly_smiling_face:
2019-02-19T12:12:58.767700
Timika
elmlang
general
I'm using a JS module containing imports of the assets and an Elm module with the type for the assets and a JSON decoder. Then I pass the assets to Elm application through the flags.
2019-02-19T12:16:12.768100
Donella
elmlang
general
I wrote myself a little tool in Haskell to help me generate these modules from a directory content.
2019-02-19T12:21:47.770000
Donella
elmlang
general
Ah pity there's nothing that would handle that by default. I'll try to use flags as you've suggested and see where it will lead. Thanks <@Timika> :slightly_smiling_face:
2019-02-19T12:23:56.770700
Romona
elmlang
general
I have used flags for this, and seen flags recommended more than once. Seems like the common solution.
2019-02-19T12:33:31.772100
Danika
elmlang
general
I just have a screenshot from someone who tried out our new system, from the console saying over and over again about a `childNode` being missing, and the tester clearly has a lot of browser extensions.
2019-02-19T12:42:33.772200
Ashton
elmlang
general
hey folks. can anyone help me with a naming question? there's a fairly common pattern I've seen where a custom type is used to make a record opaque to the client code that uses it: ``` type State = State InnerState type alias InnerState = { foo : String , bar : String } ``` is there any good naming convention for these? "inner" seems a little off to me, and if there's something the community uses, I'd be happy to prefer that.
2019-02-19T12:52:05.772500
Elina
elmlang
general
I use `Internals`
2019-02-19T12:52:23.772600
Noelle
elmlang
general
I don’t rememer where I saw it
2019-02-19T12:52:35.772800
Noelle
elmlang
general
Or just don’t alias it at all, depending on your module, this works well.
2019-02-19T13:02:45.774000
Timika
elmlang
general
I often use some variation on `State` for the internal value and something more descriptive for the outer one.
2019-02-19T13:29:28.774400
Carman
elmlang
general
An interesting example is this type from a tower-defense game that has several tags, each of which wrap some kind of state record: ``` type Game = IntroPhase IntroState | TowerPlacementPhase PlacementState | AttackPhase GameState | Victory GameState | Defeat GameState ```
2019-02-19T13:32:34.774600
Carman
elmlang
general
<https://github.com/JoelQ/safe-tea/blob/master/Game.elm#L38-L66>
2019-02-19T13:33:06.774900
Carman
elmlang
general
I use `Rep`, short for `Representation`.
2019-02-19T13:41:52.775200
Dede
elmlang
general
<http://web.mit.edu/6.005/www/fa15/classes/13-abstraction-functions-rep-invariants/>
2019-02-19T13:42:42.775400
Dede
elmlang
general
different vertex shapes are on the road map
2019-02-19T14:36:14.775600
Reuben
elmlang
general
<https://github.com/erkal/kite/projects/1#card-13685869>
2019-02-19T14:36:21.775800
Reuben
elmlang
general
What exactly do you want to do? Maybe I will have time in a week to work on Kite.
2019-02-19T14:42:41.776000
Reuben
elmlang
general
Big trouble with browser extensions and third-party trackers and other scripts. We have a bit of a problem. We finally after several weeks of hard work were able to convert from 0.18 -&gt; 0.19. We use a fullscreen elm application to be able to control navigation etc. We deployed and people starting complaining about nothing showing up in the browser! Oh no! Turns out that these people had browser extensions that injected things into the &lt;body&gt; tag of every page (Yikes). But that is unfortunately “the real world” where people have crap like that. Adding anything not controlled by Elm to the body will make Elm throw errors over and over - which is fair. Unfortunately this completely stops the application from running, and means you cannot make a website based on Elm fullscreen - it simply might not show for many users :S It also means that you cannot use some tools like Hubspot or Drift for forms and analytics, because you often have no control over where they inject their iframe tag (meaning the end body usually). A solution is to use an embedded Elm application, but that limits navigation in your elm app, which is a huge sacrifice to make. The best solution in my mind, would be that Elm fullscreen applications could be added to a top level wrapper element in body, and Elm would ignore anything outside that. Does anyone have any suggestions or have solved similar problems?
2019-02-19T15:17:11.787900
Kathlyn
elmlang
general
You are not alone: <https://elmlang.slack.com/archives/C0CJ3SBBM/p1550586877742000> I think that this issue has been underestimated because it was not that bad in 0.18. It could help to open an issue on github and post again on discourse until the problem gravity is correctly assessed. Then maybe something will be done. I think that Elm takes the whole body with `application` to be sure that it is alone handling navigation. But this indeed backfires with extensions.
2019-02-19T15:33:16.788100
Velia
elmlang
general
This mainly happen with `Browser.application` that takes the whole body. See also <https://elmlang.slack.com/archives/C0CJ3SBBM/p1550607431787900>
2019-02-19T15:36:46.788400
Velia
elmlang
general
<@Kathlyn> yes,
2019-02-19T15:38:39.788900
Simon
elmlang
general
same issue
2019-02-19T15:38:43.789300
Simon
elmlang
general
I used our gulp pipeline to hack the elm output to take the “fullscreen app” and sandbox it an element down
2019-02-19T15:39:00.789700
Simon
elmlang
general
so we could continue to work w/ all popular integrations
2019-02-19T15:39:09.790000
Simon
elmlang
general
``` // Monkey patch step to work around Elm's Browser.application deficiencies. // Please see VENDORHACKS.md for more details gulp.task("build:scripts:elm:monkey-patch", () =&gt; { const originalApplicationBodyLoadingCode = "var bodyNode = _VirtualDom_doc.body;" const isolatedApplicationBodyLoadingCode = 'var bodyNode = _VirtualDom_doc.getElementById("elmIsolationContainer");' return gulp .src(output) .pipe($.replace(originalApplicationBodyLoadingCode, isolatedApplicationBodyLoadingCode)) .pipe(gulp.dest(outputPath)) }) ```
2019-02-19T15:39:41.790200
Simon
elmlang
general
this gives you the best of both worlds, the full-screen full on Elm mode in 19, but isolation to work with Intercom, Hubspot (presumably Drift etc)
2019-02-19T15:40:24.790800
Simon
elmlang
general
we also have a little runtime dance to get around ad blockers preventing Segment&amp;Elm from loading as well
2019-02-19T15:40:52.791400
Simon
elmlang
general
happy to share more if interested
2019-02-19T15:40:56.791600
Simon
elmlang
general
Note: this is a different issue from browser extensions messing w/ other parts of the Dom, we have punted on that for now
2019-02-19T15:41:30.792100
Simon
elmlang
general
I believe I filed a bug for this (if folks want to upvote it) - Elm is too opinionated on its fullpage mode to work w/ normal B2B addons
2019-02-19T15:42:59.793000
Simon