workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | The "?" operator in C# basically | 2019-01-17T08:17:44.535700 | Leonore |
elmlang | general | because `if` is an expression (and not a statement, like in most c-like languages) we can just use it as the ternary operator | 2019-01-17T08:18:54.536800 | Virgie |
elmlang | general | if then else operates how the ternary does in other languages | 2019-01-17T08:18:57.537000 | Danika |
elmlang | general | and writing the `if` out is common and (in my opinion) clearer than hiding it behind a function | 2019-01-17T08:19:40.537700 | Virgie |
elmlang | general | But I want it on the same line :sweat_smile: | 2019-01-17T08:20:04.538100 | Leonore |
elmlang | general | Then dont use elm format :sweat_smile: | 2019-01-17T08:20:27.538500 | Danika |
elmlang | general | <@Leonore> <https://elmlang.slack.com/archives/C0CJ671HU/p1547661097665400> | 2019-01-17T08:22:10.538700 | Nana |
elmlang | general | Oh wow hahah | 2019-01-17T08:23:21.539800 | Leonore |
elmlang | general | <@Leonore> there is an issue about it on GitHub, seems like the author of elm-format is willing to allow single-line ifs, someone just needs to update the code | 2019-01-17T08:23:36.540300 | Nana |
elmlang | general | Ah cool | 2019-01-17T08:23:49.540500 | Leonore |
elmlang | general | Thanks | 2019-01-17T08:23:59.540700 | Leonore |
elmlang | general | Hi elm community! I’m co-organizing an elm conference in Chicago on April 26.
If you like talking about elm, then you should apply to speak at `Elm in the Spring`!
Our CFP is open for two more weeks (closing 1/31/19). Slots are 30 min and we’re reserving two of those spots for first-time speakers.
<https://www.papercall.io/elm-in-the-spring-2019>
Questions? Feel free to email <mailto:[email protected]|[email protected]>. | 2019-01-17T12:53:13.541200 | Elease |
elmlang | general | <@Elease> you should post this in <#C0K384K4Y|news-and-links> so it doesn’t get lost so quickly as it will in <#C0CJ3SBBM|general> | 2019-01-17T18:36:44.542400 | Ruthann |
elmlang | general | Has anyone else run into a case where `preventDefaultOn` event helper doesn't work as expected? I have this code that I use as a generic `onPaste` event, it's meant to prevent the content being pasted into the target element but the JS equivalent of `e.preventDefault` doesn't occur..
```
onPaste : (Decode.Value -> msg) -> Html.Attribute msg
onPaste msg =
preventDefaultOn "paste" <|
Decode.map (\m -> ( m, True )) <|
Decode.map msg <|
<http://Decode.at|Decode.at> [ "clipboardData" ] Decode.value
``` | 2019-01-17T21:43:52.544400 | Lesli |
elmlang | general | If the code is changed to say `preventDefaultOn "copy"` you're not able to copy the text from that element. | 2019-01-17T21:48:35.544600 | Lesli |
elmlang | general | <@Lesli> this can mean the preventDefaultOn function is broken. Test if it works in pure js. If it does, then maybe use the `custom` function. This might not work also because with the HTML module, the event is placed on a specific DOM element - is not global. But if it works in js it should be a simple straight forward translation. | 2019-01-18T03:33:43.547300 | Yang |
elmlang | general | Can I somehow "watch" elm debugger from JavaScript? Like, getting events when stepping through the debugger? I do not want to send anything to Elm, but I would like to get the model in JS while using the debugger. | 2019-01-18T04:39:45.548500 | Renda |
elmlang | general | <@Renda> you could do this:
```
main =
Browser.element
{ init = init
, update = Debug.log "update" update
, subscriptions = \_ -> Sub.none
, view = view >> toUnstyled
}
``` | 2019-01-18T04:45:22.551800 | Nana |
elmlang | general | Oh hey thats pretty clever actually | 2019-01-18T04:46:08.552200 | Danika |
elmlang | general | Are you not logging the update function like this?
I figured it would have been something like this:
```
main =
Browser.element
{ init = init
, update = (\msg model -> Debug.log "update" <| update msg model)
, subscriptions = \_ -> Sub.none
, view = view >> toUnstyled
}
```
(but nice trick :+1:) | 2019-01-18T04:49:17.555100 | Elyse |
elmlang | general | btw, another trick that I heard from <@Carman> is that you can wrap your update function so that it sends the model or part of the model to JS through a port on every update, enabling "observable" style stuff | 2019-01-18T04:49:34.555400 | Nana |
elmlang | general | Oh very cool stuff <@Nana> thank you. I did not think about Debug like it would be calling the update function, thought it was just some "magic" going on behind the scenes, this is great and makes sense even to a newbie like me :smile: | 2019-01-18T04:51:01.557200 | Renda |
elmlang | general | That port idea sounds good too. Since I am using a port to update my JS I could just re-use my code as it is now! | 2019-01-18T04:54:05.559500 | Renda |
elmlang | general | Maybe you could show an example on how <@Carman> ? | 2019-01-18T04:54:58.560200 | Renda |
elmlang | general | <@Elyse> ah right, yes it should be `update = \msg model -> Debug.log "update" <| update msg model` | 2019-01-18T04:55:06.560300 | Nana |
elmlang | general | although it just makes a huge mess in the console when your model is big :stuck_out_tongue: probably better to just log specific stuff in that case | 2019-01-18T04:59:48.562300 | Nana |
elmlang | general | <@Renda> here's an example of "watching" the model and sending to js :slightly_smiling_face:
<https://ellie-app.com/4tRKwNW9F2Ja1> | 2019-01-18T05:24:59.566200 | Nana |
elmlang | general | maybe it should be moved out into it's own function instead of `let..in` though | 2019-01-18T05:25:44.566900 | Nana |
elmlang | general | this "watch" approach would be perfect if you're using a pub/sub client in JS I think | 2019-01-18T05:27:45.568100 | Nana |
elmlang | general | can there by some kind of performance hit if a custom type has hundreds of constructors? | 2019-01-18T06:21:31.568700 | Charmaine |
elmlang | general | <@Charmaine> seems unlikely to me, I assume that's just like defining hundreds of top-level functions? they're not like a part of the type which gets instantiated | 2019-01-18T06:38:41.570000 | Nana |
elmlang | general | that makes sense - i'm autogenerating keys for i18n texts and wanted to check beforehand if it might have troubles | 2019-01-18T06:40:28.571300 | Charmaine |
elmlang | general | though if you were to case on them it could be an issue perhaps? | 2019-01-18T06:41:26.571900 | Nana |
elmlang | general | like "is this value one of these hundred things" | 2019-01-18T06:42:04.572400 | Nana |
elmlang | general | yeah it's gonna do the case when selecting the id so that's what i was worried about | 2019-01-18T06:43:44.572800 | Charmaine |
elmlang | general | it seems that elm case compiles to js switch statement so i guess i'll have to check potential performance issue there | 2019-01-18T06:45:51.573400 | Charmaine |
elmlang | general | In our current (0.18 still) env, we use a huge union type for i18n texts. There's a huge compile-time hit, but performance at runtime is not an issue at all. | 2019-01-18T06:52:35.574600 | Huong |
elmlang | general | (by huge, I mean ~1k constructors) | 2019-01-18T06:53:31.574900 | Huong |
elmlang | general | <@Huong> why a union type rather than a record? | 2019-01-18T06:54:11.575500 | Nana |
elmlang | general | Compile time in 0.19 shouldn't be an issue, though | 2019-01-18T06:54:20.575800 | Huong |
elmlang | general | Not sure, we've been doing it this way since Elm 0.15 or .16, and we haven't really had the courage to try and change it | 2019-01-18T06:55:42.577200 | Huong |
elmlang | general | <@Huong> That’s super interesting! Do you have some more details written down somewhere? | 2019-01-18T07:04:36.578400 | Timika |
elmlang | general | <@Kaylee> hey thanks for the Ellie example. However I think I did not explain myself correctly. What I wish to do is when I go through the debug timetravel I want the clicked state to be send through the port. So that I can update my JS to the time travelled state. Does that make sense? | 2019-01-18T07:05:55.580500 | Renda |
elmlang | general | does timetravel not trigger `update` | 2019-01-18T07:06:26.581700 | Danika |
elmlang | general | <@Timika> about the entire thing or just the translation system? (to be fair, I'm not super happy with it, and reworking that bit is on my every-expanding-todo-list :wink: ) | 2019-01-18T07:06:42.582100 | Huong |
elmlang | general | I’m most interested in the t10n stuff as this is something we might have to do soon as well. :slightly_smiling_face: | 2019-01-18T07:07:13.582700 | Timika |
elmlang | general | Regardless of how awesome the solution is, having first-hand experience reports always helps when evaluating a possible solution. | 2019-01-18T07:08:29.584100 | Timika |
elmlang | general | <@Danika> it does not seem to trigger sending messages through a port. Take a look, this is the example Simon made for me, and I do not get console logs while going through the debugger:
<https://ellie-app.com/4tRKwNW9F2Ja1> | 2019-01-18T07:08:50.584700 | Renda |
elmlang | general | Oh interesting | 2019-01-18T07:09:48.585000 | Danika |
elmlang | general | Fire alarm just went off in the office so I’m away from a computer atm :dizzy_face: | 2019-01-18T07:10:01.585700 | Danika |
elmlang | general | Oh damn | 2019-01-18T07:10:33.586100 | Renda |
elmlang | general | Most oh damn is walking down four flights of stairs :joy: | 2019-01-18T07:11:05.586600 | Danika |
elmlang | general | Dying in fire or walking down its a though one | 2019-01-18T07:11:40.587000 | Renda |
elmlang | general | There’s probably not a fire, there’s construction work everywhere they probably just set it off by accident | 2019-01-18T07:13:33.587800 | Danika |
elmlang | general | Or maybe some undergrad has set something on fire in the electronics lab actually.. | 2019-01-18T07:13:47.588300 | Danika |
elmlang | general | Sounds like <https://www.gizra.com/content/elm-i18n-type-safety/> | 2019-01-18T07:19:27.588400 | Jin |
elmlang | general | The time traveling debugger doesn't run Cmds as this is unlikely to result in something that works. | 2019-01-18T07:32:25.588700 | Earlean |
elmlang | general | Well thats unfortunate because I do have a usecase. What are my options then? Is it possible to expose the model read only to JS ? So I can see it change? | 2019-01-18T07:53:16.589000 | Renda |
elmlang | general | There isn't. | 2019-01-18T08:01:53.589200 | Earlean |
elmlang | general | The thing you want to do isn't something the debugger was designed to support | 2019-01-18T08:02:28.589400 | Earlean |
elmlang | general | Hm ok. I guess I just have to keep track of the model in both JS and Elm then. | 2019-01-18T08:15:49.589600 | Renda |
elmlang | general | Migrating a SPA to 0.19 I'm getting the following error: ``Something is off with the body of the `view` definition:
25|> { title = "Gransden Show"
26|> , body = body model
27|> }
The body is a record of type:
{ body : List (Html Msg), title : String }
But the type annotation on `view` says it should be:
Document Msg`` | 2019-01-18T10:21:37.591300 | Anna |
elmlang | general | but the record type quoted looks exactly the same as Document to me | 2019-01-18T10:23:01.592100 | Anna |
elmlang | general | did you check the type of the function `body` | 2019-01-18T10:23:33.592500 | Walton |
elmlang | general | ? | 2019-01-18T10:23:35.592700 | Walton |
elmlang | general | It's `body : Model -> List (Html Msg)` | 2019-01-18T10:24:58.593100 | Anna |
elmlang | general | Are you using elm-css or elm/html? | 2019-01-18T10:29:09.593800 | Elyse |
elmlang | general | Both | 2019-01-18T10:29:27.594000 | Anna |
elmlang | general | I'm guessing your body returns elm-css's Html then, hence the confusion and a non-optimal error.
Try
```
body = [ toUnstyled <| div [] [ body model ] ]
```
(where `toUnstyled` is imported from `Html.Styled`) | 2019-01-18T10:31:10.595400 | Elyse |
elmlang | general | Thank you, I was obviously been using elm-css in 0.18 without completely understanding it! | 2019-01-18T10:35:08.596300 | Anna |
elmlang | general | Will do, thanks! | 2019-01-18T11:01:31.596600 | Elease |
elmlang | general | Hello. Is there a link between this thread: (<https://discourse.elm-lang.org/t/input-select-not-available-in-elm-ui/2874>) which basically explains dropdown are bad from a UX point of view, and the fact the select tag seems less well integrated in elm than other ones? By this I mean you have to use `on "change"`, as there is no "onChange" function in Html.events. | 2019-01-18T12:45:36.600700 | Allyn |
elmlang | general | Hi everyone ! :grinning:
The Early Birds Tickets for the Elm Europe Conference are on ! And it’s happening right here : <http://2019.elmeurope.org|2019.elmeurope.org> ! :tada::champagne:
<https://twitter.com/elm_europe/status/1086319592383922176> | 2019-01-18T12:56:49.601400 | Jalisa |
elmlang | general | <@Allyn> you can use `onInput` on select elements <https://ellie-app.com/4tZS6gHvRKFa1> | 2019-01-18T13:19:55.601800 | Nana |
elmlang | general | I definitely didn't know that! Thank you <@Nana> | 2019-01-18T14:49:21.602600 | Allyn |
elmlang | general | I've got a parser that I've written to accept input and produce a url with specific formatting:
```
parser : Parser String
parser =
succeed concat5
|= scheme
|= subdomain
|= shopifyStore
|= suffix
|= admin
```
It works, but the `concat5` function is just taking the five string arguments and (++) them together. I wanted to use something like `String.concat` to make this better, but I couldn't figure out a way given that this constructor needs five arguments. Is there a simple solution that I'm overlooking? | 2019-01-18T15:01:34.604800 | Hyacinth |
elmlang | general | yes, it's <https://package.elm-lang.org/packages/elm/parser/latest/Parser#getChompedString> | 2019-01-18T15:02:45.605100 | Virgie |
elmlang | general | Ha, awesome. I even used that in one of the sub-parsers. | 2019-01-18T15:03:20.605400 | Hyacinth |
elmlang | general | Thank you! | 2019-01-18T15:03:22.605600 | Hyacinth |
elmlang | general | Is there some kind of feed someplace that shows new elm packages being published/updated? | 2019-01-18T15:21:17.607100 | Lindsey |
elmlang | general | don't think so. Could be a nice feature for `elm reactor` (or similar tools) to just see (based on your elm.json) if there are new releases of your dependencies | 2019-01-18T15:42:33.607900 | Virgie |
elmlang | general | For this you can use <https://www.npmjs.com/package/elm-outdated> | 2019-01-18T15:48:17.608300 | Loida |
elmlang | general | Is there a way to chain a `Task` into a `Cmd`?
Specifically, I need to get the current time, and then send a value through a port based on that current time. I'd love to use `Task.andThen` but I don't know how to pass in a `Cmd` to that | 2019-01-18T17:42:57.609800 | Sofia |
elmlang | general | It sounds like you need to create the Cmd in your update function. after you get the Time update, you return a new command
```
type Message
= Time YourTime
update msg model =
case msg of
Time yourTime ->
(model, YourCommand yourTime)
``` | 2019-01-18T17:54:24.612200 | Alleen |
elmlang | general | I am thinking of creating a `elm/parser` cookbook that would hold a curated list of examples that illustrate how to use the `elm/parser` package. I am discussing it here to see if similar efforts are already well established, to see if there is any interest in a cookbook and if people are willing to contribute to it. | 2019-01-19T02:15:03.615200 | Marcelino |
elmlang | general | So, would a `elm/parser` cookbook be of interest? | 2019-01-19T02:15:33.615600 | Marcelino |
elmlang | general | That would be very helpful! Just today I ran into a problem with using the parser which I haven’t figured out yet. I’d be willing to help with some basic examples. | 2019-01-19T04:09:05.617100 | Kyung |
elmlang | general | Since ports are always just `Cmd`s and not `Task`s, you can't chain the effects. Only Tasks can be chained, and there's no way to "backtrack" from a Cmd to a Task. | 2019-01-19T04:12:33.617300 | Bert |
elmlang | general | That said, why not do the side effect in the port handling code, in JS? You can get the time there and do the rest of the port stuff then. | 2019-01-19T04:14:07.617500 | Bert |
elmlang | general | Definitely. Specially the docs and usage around backtracking, commit, are not very useful, and the advanced module is a bit daunting even though it seems very helpful | 2019-01-19T06:03:12.619600 | Bebe |
elmlang | general | I’d say so | 2019-01-19T07:40:24.620100 | Vilma |
elmlang | general | on the topic of `elm/parser`, how difficult would it be to parse *and run* elm code | 2019-01-19T07:46:45.621000 | Danika |
elmlang | general | it depends on what you want to run (and how). Evaluating simple expressions (like numbers, strings, ifs) would not be very hard. | 2019-01-19T07:50:15.621800 | Virgie |
elmlang | general | but type inference is non-trivial, and much of elm depends on kernel code which you'd have to re-implement | 2019-01-19T07:50:32.622300 | Virgie |
elmlang | general | Could anyone tell me how is it possible? I have an `on "focus" ...` handler which sends `SetFocus` message which logs a `Debug.log "UPDATE" model` when it is processed by `update`. I have also `Debug.log "VIEW" model` in the `view` function and I also see this message in the console. But for some weird reason VIEW message comes before the UPDATE message and, naturally, I see that outdated model is rendered. | 2019-01-19T07:57:48.624900 | Lynne |
elmlang | general | Why in the heaven `view` is not triggered after `update` has changed the model? | 2019-01-19T07:58:17.625500 | Lynne |
elmlang | general | Essentially I'd like to embed a DSL into an Elm app I'm building. The scope would be tightened (only certain functions can be called in the DSL and a sequence/structure of calls is enforced) such that essentially if I had
```type alias A =
{ bs : List B }
type alias B =
{ foo : Int, bar : String }
```
You'd be able to input in a textarea:
```
createA [
createB 102 "hello",
createB 0 "world",
...
}
```
Which should parse into valid data and sent on its merry way however I decide in Elm. This, i believe, is somewhat trivial to do with the parser, but consider I now have a function:
```
setFoo : Int -> B -> B
setFoo newFoo b =
{ b | foo = newFoo }
```
I'd like you to be able to write:
```createA [
createB
|> setFoo 1020201
|> setBar "hello".
createB 0 "world",
...
}
```
You can assume that the way `createB` and the `setX` functions are valid real Elm code you could write in my app. | 2019-01-19T08:08:17.625600 | Danika |
elmlang | general | because elm is a statically typed language such a DSL would not be very flexible. For instance to call elm functions, you'd need a way of mapping the function name to the actual function | 2019-01-19T08:13:36.625900 | Virgie |
elmlang | general | and that is hard because you can't store it in a uniform way, like a `Dict String Function` because the function type is different between like `+` or `++` | 2019-01-19T08:14:35.626100 | Virgie |
elmlang | general | (you'd need some casting mechanism for this, or quantification, anyway more advanced type-level features than elm has) | 2019-01-19T08:15:14.626300 | Virgie |
Subsets and Splits