workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
I see
2019-03-02T06:36:48.243500
Lynne
elmlang
general
Well, `view` is supposed to render your model so there is basically no option to moving knowledge about specific views to it and doing URL parsing in `update` instead
2019-03-02T06:38:43.243700
Lynne
elmlang
general
I mean, if you want to request data only when it is actually needed
2019-03-02T06:39:13.243900
Lynne
elmlang
general
Why do you think it is bad if I may ask?
2019-03-02T06:39:29.244100
Lynne
elmlang
general
Because it means that if I change my view such that asciidoc HTML is displayed in other places, I need to update the `update` function as well.
2019-03-02T06:40:11.244300
Winnie
elmlang
general
Basically, `update` needs to know specifically under which conditions the generation needs to happen.
2019-03-02T06:40:53.244500
Winnie
elmlang
general
And these conditions do not exist in URL, is it correct?
2019-03-02T06:41:13.244700
Lynne
elmlang
general
I can examine the URL to determine if it will need the generation, but only because
2019-03-02T06:41:51.244900
Winnie
elmlang
general
but only by encoding that knowledge in `update`.
2019-03-02T06:42:06.245100
Winnie
elmlang
general
It's essentially view-specific details leaking to other parts of the program.
2019-03-02T06:42:25.245300
Winnie
elmlang
general
I understand your concern but in Elm core of program is model, not view. So what you have said about `update` is how it should be done when we are talking about the Elm architecture
2019-03-02T06:43:34.245500
Lynne
elmlang
general
In other words view is a product of model, not vice versa
2019-03-02T06:44:26.245700
Lynne
elmlang
general
well...only because they've taken away native modules. That's how I used to do it.
2019-03-02T06:44:31.245900
Winnie
elmlang
general
Your point is true, though, so I guess my hands are tied.
2019-03-02T06:44:56.246100
Winnie
elmlang
general
You may consider custom components instead if it is that critical
2019-03-02T06:45:04.246300
Lynne
elmlang
general
I wouldn't say critical. It's just frustrating that something so conceptually straightforward requires such gymnastics.
2019-03-02T06:45:46.246500
Winnie
elmlang
general
Anyhow, thanks for you help on this.
2019-03-02T06:46:01.246700
Winnie
elmlang
general
You are welcome :slightly_smiling_face:
2019-03-02T06:46:15.246900
Lynne
elmlang
general
I'll look into custom components, but I imagine I'll just go the standard route.
2019-03-02T06:46:26.247100
Winnie
elmlang
general
Apart from possible inconveniences the standard way also gives some nice opportunities like displaying the "Loading..." screen while your picture is being rendered
2019-03-02T06:47:17.247300
Lynne
elmlang
general
Right. I wouldn't have a problem with standard approach if the view could somehow trigger the port itself. That would plug the leak.
2019-03-02T06:52:53.247500
Winnie
elmlang
general
You could always generate `Html` in `update`, store it in your `Model` and just return it in `view`. I am not sure if that is a good idea though :sweat_smile: .
2019-03-02T09:22:35.247900
Tamra
elmlang
general
It has a disadvantage of potentially doing unnecessary job as several `update` calls may happen before `view` which only happens on each animation frame
2019-03-02T09:24:22.248100
Lynne
elmlang
general
Therefore, if your model is updated often, generating Html and storing it in the model will be a waste
2019-03-02T09:24:46.248300
Lynne
elmlang
general
what do people think is the easiest replacement for the 0.18 websockets library for a migration to 0.19? I looked at PortFunnel and it seemed to be more sophisticated (and hence more complex) to implement
2019-03-02T10:27:44.249900
Lynn
elmlang
general
I’d prefer to have the same basic api, so I can focus (at least initially) on wiring up the ports that will be needed
2019-03-02T10:28:59.250700
Lynn
elmlang
general
<wishful-thinking>I guess the ideal would be that someone was allowed to port the existing (native) code to 0.19 and put it on elm-explorations so that we could all use while the new version is worked on</wishful-thinking>
2019-03-02T11:43:42.256300
Lynn
elmlang
general
Hey! Our workshop at the University of Utrecht (the Netherlands) starts on Monday and a lot of people signed up today. If any of you fine folks will be around please give us a hand as a coach. Even a single evening will be appreciated. The schedule is here: <http://software.garden/test-run.html>
2019-03-02T12:02:25.257200
Dorsey
elmlang
general
It’s all on GitHub...
2019-03-02T12:10:53.257600
Dede
elmlang
general
Hello. I wrote a parser to parse something like ” = some random text” and I need to get “some random text” from it, whatever are the characters after the “=” symbol. ``` stringParser : Parser String stringParser = getChompedString &lt;| chompWhile (\c -&gt; True) stringEqualityParser : Parser String stringEqualityParser = succeed identity |. spaces |. symbol "=" |. spaces |= stringParser ``` This does the job, but is there a more elegant solution?
2019-03-02T12:16:21.257900
Allyn
elmlang
general
what is inelegant to you here? it is quite understandable I think.
2019-03-02T12:24:01.258900
Virgie
elmlang
general
How do you intend to use this, the `stringParser` will just keep on chomping till the end of the input, so you can't really use this at the moment in a larger parser
2019-03-02T12:25:00.259800
Virgie
elmlang
general
I don’t need to use it in a larger parser
2019-03-02T13:33:06.260400
Allyn
elmlang
general
I was wondering if there wasn’t any shorter solution which did not imply to create the `stringParser` function
2019-03-02T13:37:14.261500
Allyn
elmlang
general
you can always inline that function, but this is good code
2019-03-02T13:38:45.262000
Virgie
elmlang
general
that was definitely not what I was thinking of :wink:
2019-03-02T13:39:49.262900
Allyn
elmlang
general
Could you do something like `keep zeroOrMore `
2019-03-02T13:39:55.263200
Hoyt
elmlang
general
<@Hoyt> that is not part of the API any more since 0.19
2019-03-02T13:40:22.263800
Virgie
elmlang
general
ah, okay, I”m looking at old docs. Haven’t looked at changes to the parser for 0.19
2019-03-02T13:40:41.264500
Hoyt
elmlang
general
one improvement is - if you can find a character that will never occur in your code like NUL, to use `chompUntilEndOr "\0"`
2019-03-02T13:41:13.265000
Virgie
elmlang
general
this will drop down into JS and be a little more efficient I think
2019-03-02T13:41:25.265400
Virgie
elmlang
general
ah, I see. Looking at the updated ones
2019-03-02T13:41:34.265700
Hoyt
elmlang
general
It does not accept “\0” as a parameter, but “\t” works
2019-03-02T13:45:46.266200
Allyn
elmlang
general
elm format rewrites `\0` to `"\u{0000}"` which I think it should accept. anyway `\t` also does the job
2019-03-02T14:02:22.267000
Virgie
elmlang
general
It works indeed, but I prefer “\t” for readability
2019-03-02T14:03:22.267500
Allyn
elmlang
general
Google could not find anything obvious, hence why I asked
2019-03-02T16:51:28.267700
Lynn
elmlang
general
None
2019-03-02T16:53:57.267900
Lynn
elmlang
general
how can i call play method on video/audio element with elm? is it possible?
2019-03-02T17:39:48.269600
Cleveland
elmlang
general
`elm-use` doesn't seem to support 0.19 yet. Does anyone know why? Haven't gotten around to it yet? Is it in the works?
2019-03-02T17:42:07.270300
Verlene
elmlang
general
I didn't even know that existed :smile: I tend to use `npm i` and `npx` to run project-local stuff, though there are a few tools for elm version management around, including `elmv` and various `asdf` plugins, amongst others (presumably)
2019-03-02T17:45:08.271800
Huong
elmlang
general
Yeah, I just stumbled upon it now, and figured it seemed sensible to be able to easily switch between versions. I'd prefer to stay out of npm-land if I can. :stuck_out_tongue:
2019-03-02T17:46:44.272600
Verlene
elmlang
general
I meant you can hack up your own version of Elm if not having something native is a showstopper: <https://github.com/elm/>
2019-03-02T17:52:08.272700
Dede
elmlang
general
<@Cleveland> you can make a port that tells JS to document.querySelector(#id).play() at the very least. prob need to wrap in rAF
2019-03-02T18:45:39.274200
Jarvis
elmlang
general
i have a thumbnail gallery that opens a &lt;video&gt; in a modal when user clicks respective thumbnail. but i want videos to initialize at volume=0. for now i use a mutation observer on document.body that sets node.volume=0 on new &lt;video&gt; nodes.
2019-03-02T18:48:32.276600
Jarvis
elmlang
general
so, the sky's the limit :smile:
2019-03-02T18:51:01.276900
Jarvis
elmlang
general
Dan Abrams just made a talk about this: <https://www.youtube.com/watch?v=8jW58fXuuOk>
2019-03-02T19:30:00.279700
Allyn
elmlang
general
He created a wrapper around HTML5 apis: <https://github.com/danabrams/elm-media>
2019-03-02T19:36:53.279900
Allyn
elmlang
general
I'm thinking about a data structure for a question with single choice answer, like: ``` What is the value of 2 + 2? ( ) 3 (*) 4 ( ) 5 ``` I'd like to make invalid states impossible, so the requirements are following: 1. There must always be exactly one correct answer That could be satisfied with a `NonEmptyList` where the first element is the correct answer. 2. Answers must be unique A Set would work, assuming there will be no additional data in the answer (like an id). For the UX: 3. It must be possible to re-order the options It's not much fun if the first option is always correct. Best candidate I can think of so far is the `AssocList` (<https://package.elm-lang.org/packages/pzp1997/assoc-list/latest/>) with keys being the options and values indexes for ordering, so `AssocList.Dict Option Int`. Then to check if a given answer is correct I would test if it's the head of the `AssocList.keys`, and to render I would do `AssocList.toList &gt;&gt; sortBy Tuple.second`. The only downside I see is that the AssocList can be empty, which would violate requirement 1. I think I could live with that, but maybe I should make a `NonEmptyAssocList`. Is there anything else I should consider?
2019-03-03T01:45:32.280500
Dorsey
elmlang
general
Thinking about your problem, what comes to mind is that you always need a good answer and a few bad ones. So maybe you could use something like `Question String (List String)`, and then it's only a matter of displaying a random number of bad answers, then the correct answer, then the remaining bad answers?
2019-03-03T02:06:30.284000
Krista
elmlang
general
I mean, not conflate the data and its representation
2019-03-03T02:07:06.284800
Krista
elmlang
general
That would work, but I'd like the order to be explicit (i.e. not random). Also the uniqueness is not guaranteed - I'd have to check for that at runtime.
2019-03-03T02:35:19.286700
Dorsey
elmlang
general
There’s a much better wrapper coming this month.
2019-03-03T02:42:53.287200
Cammy
elmlang
general
Right now this is the way to do it but I’ll be releasing a wrapper very soon that avoids reaching into virtual dom like this.
2019-03-03T02:45:24.288900
Cammy
elmlang
general
Why not just use a volume or muted attribute on the video dom nodes, instead of a mutation observer?
2019-03-03T02:45:53.289400
Cammy
elmlang
general
Maybe `Question String Int (List String)` with the Int being the index of the correct answer?
2019-03-03T03:02:26.291400
Krista
elmlang
general
not sure what you meant about uniqueness
2019-03-03T03:02:39.291700
Krista
elmlang
general
Yeah, that's interesting. Uniqueness of the answers, so that it's not possible to do ``` How much is 2 + 2 - ( ) 4 - (*) 4 - ( ) 5 ```
2019-03-03T03:19:31.293200
Dorsey
elmlang
general
I guess I could use `AssocSet` (it's ordered and guarantees that values are unique).
2019-03-03T03:22:20.295300
Dorsey
elmlang
general
But there can still be collision between correct and one of the incorrect answers.
2019-03-03T03:23:04.295700
Dorsey
elmlang
general
:thinking_face:
2019-03-03T03:23:10.295900
Dorsey
elmlang
general
Ah, that is yet another concern that should maybe not be conflated with the data and its representation. Maybe the wrong answers can be manually provided, if not then you will need some kind of generation, some kind of fuzzing...
2019-03-03T03:31:29.298700
Krista
elmlang
general
Created a PR to add Elm to <https://zeit.co/new> I used create-elm-app for that: <https://github.com/zeit/now-examples/pull/291>
2019-03-03T05:41:53.299600
Shena
elmlang
general
Was unsure whether it belongs to "Programming Languages" or "Frameworks and Libraries"
2019-03-03T05:42:39.299700
Shena
elmlang
general
Actually I should probably add a few words about deploying to now in the readme.md
2019-03-03T05:44:22.299900
Shena
elmlang
general
Are the number of answers fixed? Like to 3 or something?
2019-03-03T06:10:15.302400
Ashton
elmlang
general
``` type alias Answer = { value : String , order : Int } type alias Question = { value : String , rightAnswer : Answer , wrongAnswers : List Answer } answers : Question -&gt; List Answer answers { rightAnswer, wrongAnswers } = List.sortBy .order (rightAnswer :: wrongAnswers) ```
2019-03-03T06:14:43.306500
Ashton
elmlang
general
<@Dorsey> I'd just do `type Question = Question { question : String, correctIndex : Int, answers : (List String) }` in a `Question` module and expose the `Question` type(not the constructor) as well as a `makeQuestion : String -&gt; Int -&gt; List String -&gt; Maybe Question` function that makes sure the `Int` is a valid index of the `List String` and that the list contains no duplicates(or something similar, like filter out dupes and check the length).
2019-03-03T06:14:54.306700
Earnest
elmlang
general
If you add &amp; expose other functions like `shuffleAnswers : Question -&gt; Question`, just make sure they maintain the invariants you've set in the `makeQuestion` function.
2019-03-03T06:19:50.307700
Earnest
elmlang
general
<@Dorsey> you could write a version of Selectlist can is for a Set. <https://package.elm-lang.org/packages/rtfeldman/selectlist/latest/SelectList> The Set will guarantee rhe uniqueness and the data structure will guarantee at least one selected item (the correct answer). Then you can have a type like `type Question = Question String (SelectSet Answer)`
2019-03-03T07:28:46.311900
Edie
elmlang
general
`Answer` could be simplified as a String to not over complicate the data structure.
2019-03-03T07:33:14.313000
Edie
elmlang
general
I'd like to insert a little elm component into an existing js/typescript/java legacy app that is build using maven and npm/grunt plugins. Grunt seems deprecated and so I don't expect the grunt-elm plugin to be maintained any further. Can anyone suggest an approach to integrating the elm build into this maven-driven (with npm and grunt plugins) project? Thanks in advance.
2019-03-03T07:56:53.318700
Susanna
elmlang
general
I am pretty sure grunt is capable of running shell commands, so you can just call `elm make` from your grunt pipeline
2019-03-03T08:10:07.319500
Lynne
elmlang
general
If you want to run it by Maven instead, there is a plugin to execute shell commands for it: <https://search.maven.org/artifact/org.codehaus.mojo/exec-maven-plugin/1.6.0/maven-plugin>
2019-03-03T08:12:27.320000
Lynne
elmlang
general
Or this one <https://search.maven.org/artifact/org.apache.maven.plugins/maven-invoker-plugin/3.2.0/maven-plugin>
2019-03-03T08:19:36.320200
Lynne
elmlang
general
That's very cool! I didn't know about `SelectList`, so thanks a lot. It's no surprise that it comes from <@Leonie> :slightly_smiling_face:
2019-03-03T09:07:55.320400
Dorsey
elmlang
general
<@Jarvis> i was thinking of safe and typed version of `document.querySelector(#id).play()`
2019-03-03T09:12:46.320600
Cleveland
elmlang
general
<@Cammy> looking forward too that
2019-03-03T09:12:50.320800
Cleveland
elmlang
general
You have to be very careful with your id’s doing it with querySelector. That doesn’t sound hard, but in practice, I spend a lot of time helping people with this.
2019-03-03T09:15:00.322300
Cammy
elmlang
general
that one of the reasons i don't want to do this with ids because then in order to have arbitrary number of players on page i need to somehow keep track of player ids which is much simple in js then elm i am guessing
2019-03-03T09:20:32.322500
Cleveland
elmlang
general
<@Cammy> so that you are doing is for audio/video and not for DOM APIs in general right?
2019-03-03T09:23:13.322800
Cleveland
elmlang
general
Around the media playback parts of the DOM API (play, pause, etc), as well as the other media apis.
2019-03-03T09:25:01.324300
Cammy
elmlang
general
This is what I talked about at Oslo elm day. Can I ask, what’s the use-case for having a lot of players on one page as opposed to one that switches sources? There’s a limit to the number of players some browsers can load on a page.
2019-03-03T09:53:36.326700
Cammy
elmlang
general
By the way, the way I solved this in an earlier incarnation was generating an opaque type that contained the id, and using a Dict if I had multiple on the page. That was better than strings, but not 100%, at least through ports.
2019-03-03T09:55:21.328500
Cammy
elmlang
general
if i can't have multiple players that would mean player is singleton which is just wrong as for examples where you need more then one player take a look at <http://coub.com|coub.com> or this <http://tv.myvideo.ge/> this is tv streaming built with react it has main player and on the left side if you hover over some channels they have preview of stream in a mini player in my code mini player and main player is same component with different options passed to them screenshot <https://imgur.com/a/Ax6kOMH>
2019-03-03T10:22:54.329100
Cleveland
elmlang
general
So coub (atleast in the iOS app version) seems to only have one player at a time, which is the way something like that should work. I’ll have to take a look at how it works on a desktop browser later, but I see where this would be difficult to do with the current virtual dom implementation, but my new library should make this much easier while adhering to best practices for a good user experience, and increase performance over using 20+ individual media elements on a page. I’m not sure, however, that we have the necessary capabilities in Elm currently to do this properly, the way that it works in the iOS native app. I really want to see what they’re doing in a desktop browser. For previews, yeah, that’s a good use case, but I might suggest instead of having an arbitrary number of media elements, you only need two. The most videos that can be playing simultaneously is two: a main video and one preview at a time, assuming the previews only appear on mouseover. If you have 40 linked videos on the page, you don’t want to load every preview at page load, it’ll eat a ton of bandwidth, and use a ton of bandwidth. Just load the appropriate preview as you mouseover...use fMP4 and encode the previews really small, and they should load quickly. This is generally the better of the two ways I’ve seen it done on sites like YouTube (the other is image sequences).
2019-03-03T10:57:44.339600
Cammy
elmlang
general
Any packages for manipulating the RGB values of images?
2019-03-03T11:09:00.340100
Wendell
elmlang
general
Or HSL, I guess. I’m color space agnostic.
2019-03-03T11:09:39.340700
Wendell
elmlang
general
You mean like making a color image black and white or something?
2019-03-03T11:09:49.341000
Cammy
elmlang
general
Sure, that’s a good example
2019-03-03T11:10:20.341200
Wendell
elmlang
general
Don’t quote me on this, but for raw pixel manipulation, you probably need canvas. However, you can do a lot with css filters and svg filters. I suppose you could also write a jpeg or png decoder using elm/bytes, manipulate the data, then create a blob or something, but that seems nuts.
2019-03-03T11:12:38.343900
Cammy