workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
Adding it in general cases means you can't check for exhaustiveness
2019-02-28T11:58:37.066600
Kris
elmlang
general
I'm referring to just the cases where the function is a compile time constant value though
2019-02-28T11:59:19.068100
Jae
elmlang
general
because of stuff like ``` foo a b = case (a, b) of (x, x) -> .. ```
2019-02-28T11:59:25.068300
Kris
elmlang
general
also you'd need some way to disambiguate if you mean binding `a` to `someConstantValue` or having it equal to `someConstantValue`
2019-02-28T11:59:26.068400
Shondra
elmlang
general
(syntactically)
2019-02-28T12:00:00.068800
Shondra
elmlang
general
Ah, I understand. Yeah that makes sense
2019-02-28T12:00:18.069500
Jae
elmlang
general
Yeah, there's no reason for not allowing that for compile time stuff, other than it being ugly
2019-02-28T12:00:31.069900
Kris
elmlang
general
erlang/elixir have that feature, they use the `^` operator
2019-02-28T12:01:01.070300
Shondra
elmlang
general
`case x of ^y` means if x equals y, but then again, in erlang/elixir there is no exhaustive checking
2019-02-28T12:01:52.071200
Shondra
elmlang
general
You can do it in haskell with template haskell ``` someQ = ... something equivalent to 5... case x of $(someQ) -> "5" ```
2019-02-28T12:02:51.072800
Kris
elmlang
general
(TemplateHaskell is Haskell's compile time macro system)
2019-02-28T12:03:17.073300
Kris
elmlang
general
I understand the desire to minimize the amount of syntax but right now I wish I had something like that so that I can reuse the same constant string in multiple case statements to reduce the risk of typos
2019-02-28T12:03:53.074100
Jae
elmlang
general
Would it make sense to use `if ... then ... else` ?
2019-02-28T12:04:56.074700
Carman
elmlang
general
Yeah I can sympathize
2019-02-28T12:05:00.074800
Kris
elmlang
general
Perhaps you can factor that out in some other way
2019-02-28T12:05:12.075300
Kris
elmlang
general
<@Carman> That's a good point. In this instance I can do that. Thanks!
2019-02-28T12:05:48.076000
Jae
elmlang
general
Hey there -- I'm a bit disappointed that the built in elm/browser and elm/html mouse events don't decode the various fields available on the JS event and am considering which package to use as an alternative. Is there one folks here prefer or recommend? I think I'm leaning towards <https://github.com/mpizenberg/elm-pointer-events>
2019-02-28T12:47:25.079500
Elvis
elmlang
general
Haskell has another way to do this: the PatternSynonyms extension. See <https://ocharles.org.uk/posts/2014-12-03-pattern-synonyms.html>
2019-02-28T14:14:09.079700
Paula
elmlang
general
So you could write: ``` someConstant = 5 pattern SomeConstant = someConstant case x of SomeConstant -&gt; whatever ```
2019-02-28T14:20:04.080000
Paula
elmlang
general
Ah, true, I’d forgotten about those. They’re great
2019-02-28T14:29:15.080600
Kris
elmlang
general
There is something that has been bothering me for a long time, is there a way to model my Elm app as a state machine so that the compiler can know that the app is already in some state and I can skip checking for impossible states? For example: (1) an action can be dispatched only if the user presses a button, (2) that button is shown only if the data has been loaded from the server, (3) therefore I don't have to check if the data is loading in the update for that action. I know doing that in Elm is probably impossible but I'm really interested in learning about tools that enable that.
2019-02-28T15:34:55.084000
Dayna
elmlang
general
It's tricky if your system is asynchronous like Elm. Consider the following scenario: 1. A user clicks a button when the app is in state `A`. This fires a (slow) HTTP request in the background 2. While the request is happening, the user clicks another button, transitioning the app to state `B` 3. The HTTP request finally completes, triggering a message
2019-02-28T15:39:43.086000
Carman
elmlang
general
Normally you'd only expect the message to come in when the app is in state `A` but because messages are asynchronous it could definitely come in during state `B` (or `C`, etc)
2019-02-28T15:40:44.087000
Carman
elmlang
general
I think that in a state machine with asynchronous events, any message _could_ happen in any state
2019-02-28T15:41:49.087800
Carman
elmlang
general
Well if modelling such state transitions was possible then surely you could model the possible transitions that can happen during loading of the request
2019-02-28T15:42:59.089700
Dayna
elmlang
general
if your `Model` is an enum you could do something like ``` case (model, msg) of (ModelStateOne stateOne, MsgOne) -&gt; -- handle this case (model, Cmd.none) _ -&gt; (model, Cmd.none) ``` it’s not as clean as you’re hoping, but it could work
2019-02-28T15:43:21.090200
Alleen
elmlang
general
enum =&gt; custom type
2019-02-28T15:43:37.090400
Alleen
elmlang
general
i’m too used to Rust right now
2019-02-28T15:43:42.090600
Alleen
elmlang
general
Sure, but I'm more interested in a way to model the transitions upfront and then have the compiler force me to prove that the model is in the correct state (request loaded etc)
2019-02-28T15:44:38.091800
Dayna
elmlang
general
The only practical solution I can think of right now is to put the button click message inside the model and when the request is loaded to partially apply the response data to the message so that when the view renders the response: (1) view is forced to pattern match on the response to extract the message it should send and (2) the update will also get the response data from the message, not the model and it will be confirmed to exist. This is all very theoretical and hacky, of course, but I can see myself playing with the idea
2019-02-28T15:49:12.096400
Dayna
elmlang
general
Right, so the issue is that you have two values - model and msg - and you need to combine their types in some way :thinking_face:
2019-02-28T15:49:45.097400
Nana
elmlang
general
The more I think about it, the better it sounds :smile: I'd imagine a model with `article : WebData (Article, { editArticle : Msg })` where the editArticle message constructor is actually `Article -&gt; Msg` but the update function will partially apply the data when it's returned from the server. The view will pattern match on the article in the model to extract the message for the edit button and the update will grab the article by pattern matching the message.
2019-02-28T15:56:52.101700
Dayna
elmlang
general
So, if your model only represents legal states, and you write a transition, you can’t possibly have a problem. You can’t write a transition that accepts an illegal state, or creates one. Can you tell us more about the problems you’re solving and why you focused on this idea of a state machine?
2019-02-28T15:59:04.103400
Leoma
elmlang
general
The problem is that 90% of the code I write (and I imagine most boring CRUD apps are like that) is requesting data, showing stuff on the screen and sending requests when the user presses something. On every `XButtonClicked` message I have to pattern match on the request to get the data and since the request could be loading, I have to add a branch like in <@Alleen>’s example
2019-02-28T16:01:10.105800
Dayna
elmlang
general
<@Dayna> you could get the data from the view like `onClick (DoStuff loadedData)` but I think that can cause some concurrency issues?
2019-02-28T16:03:41.108900
Nana
elmlang
general
That's also a way to do it, but I think the theoretical API I showed above is a bit more reliable and also it doesn't involve the view knowing what data the update needs
2019-02-28T16:04:32.109800
Dayna
elmlang
general
Seems it'd be nice if there were an easy generic way to escape variables in patterns though, to say that they should be evaluated rather than bound.
2019-02-28T16:16:11.110500
Paula
elmlang
general
<@Dayna> you could also use websockets and subscribe to graphql queries :)
2019-03-01T02:15:00.119000
Valeria
elmlang
general
How do I make this code typecheck? ``` type alias Foo = { hello : Int } updateFoo : Foo -&gt; Int -&gt; Foo updateFoo foo num = { foo | hello = num } type Things = Good Foo | Bad Foo makeUpdater : Things -&gt; Int -&gt; (a -&gt; Int -&gt; a) -&gt; Things makeUpdater things newNum updater = case things of Good foo -&gt; updater foo newNum Bad foo -&gt; things ```
2019-03-01T03:20:29.120100
Deane
elmlang
general
The compiler tells me this: ``` The 1st argument to `updater` is not what I expect: 35| -&gt; updater foo newNum ^^^ This `foo` value is a: Foo But `updater` needs the 1st argument to be: a ```
2019-03-01T03:20:48.120400
Deane
elmlang
general
But updater IS being used correctly, no?
2019-03-01T03:21:06.120700
Deane
elmlang
general
<@Deane> `type` is not the same as `type alias`
2019-03-01T03:25:43.121200
Lynne
elmlang
general
You have defined new type and given it a `Maybe` constructor (shadowing the one imported implicitly)
2019-03-01T03:26:33.122000
Lynne
elmlang
general
Also, even if you used `type alias` it would not work because you would be returning `Foo` but `makeUpdater` says it should be `Maybe Foo`
2019-03-01T03:28:09.123200
Lynne
elmlang
general
right, my example doesn't demonstrate the issue I thought it did
2019-03-01T03:28:38.123800
Deane
elmlang
general
I'll try to come up with another one
2019-03-01T03:28:49.124100
Deane
elmlang
general
anyone got experience with an elm SPA and googles crawler? I am seeing the following error in the console: `Uncaught SyntaxError: Unexpected token ,` Would be nice if i could rule out elm as the problem here
2019-03-01T03:30:29.125200
Selene
elmlang
general
<@Lynne> I've "corrected" the example to show the right error
2019-03-01T03:31:31.125900
Deane
elmlang
general
<@Deane> I pointed to the problem in my last statement :slightly_smiling_face: You return `Foo` but `makeUpdater` says it should be `Things` (either `Good Foo` or `Bad Foo`)
2019-03-01T03:34:20.126700
Lynne
elmlang
general
So you should have written, for example, `Good &lt;| updater foo newNum` in your first branch
2019-03-01T03:35:17.127400
Lynne
elmlang
general
And I think it still won't compile because `a` is too generic in your case and compiler will force you changing signature of `updater` to `(Foo -&gt; Int -&gt; Foo)`. If you want a generic signature you should write something like: ``` type Things a = Good a | Bad a makeUpdater : Things a -&gt; Int -&gt; (a -&gt; Int -&gt; a) -&gt; Things a ```
2019-03-01T03:37:41.129300
Lynne
elmlang
general
I agree with <@Johna> - if you are asking the question... roll your own. In my experience, extensible means trying to fit too many use cases. Is usually better to do exactly what you need.
2019-03-01T04:04:43.129600
Gale
elmlang
general
Thank you !
2019-03-01T04:07:43.129900
Yolando
elmlang
general
:point_up:
2019-03-01T04:11:56.130100
Johna
elmlang
general
Hi. I currently trying to upgrade from 0.18 to 0.19 and ran into a package dependency thing. I used elm-upgrade for the job and now I swapped the packages which don't support the new elm (sortable-data-tables and date-format) manually for their new forks: "evancz/elm-sortable-table": "1.0.1 &lt;= v &lt; 2.0.0", -&gt; "billstclair/elm-sortable-table": "1.1.1 &lt;= v &lt; 2.0.0", "mgold/elm-date-format": "1.6.0 &lt;= v &lt; 2.0.0" -&gt; "ryannhg/date-format": "1.6.0 &lt;= v &lt; 2.0.0"
2019-03-01T04:52:08.132900
Daysi
elmlang
general
now I'm stuck in this situation:
2019-03-01T04:54:57.133600
Daysi
elmlang
general
so elm-upgrade says "dependencies are fine", `elm make` says "dependencies are not good"
2019-03-01T04:55:40.134600
Daysi
elmlang
general
can someone point me in the right direction?
2019-03-01T04:56:00.134900
Daysi
elmlang
general
Help is appreciated
2019-03-01T04:56:09.135300
Daysi
elmlang
general
<https://www.markuslaire.com/github/elm-dependencies-analyzer/> is a tool to help you work out dependency issues
2019-03-01T04:56:25.136000
Jin
elmlang
general
<@Lynne> yes, you're correct when you say "And I think it still won't compile because `a` is too generic in your case and compiler will force you changing signature of `updater` to `(Foo -&gt; Int -&gt; Foo)`"
2019-03-01T04:56:41.136400
Deane
elmlang
general
And yes looks like the solution is basically that `Things` will become `Things a`
2019-03-01T04:57:29.137000
Deane
elmlang
general
thanks!
2019-03-01T04:57:30.137200
Deane
elmlang
general
elm-upgrade will only check that your dependencies are Elm 0.19 ready, afaik. Elm will check if the dependency constraints fit.
2019-03-01T04:58:10.137400
Jin
elmlang
general
You are welcome <@Deane>
2019-03-01T04:58:21.137700
Lynne
elmlang
general
thanks! but the tool says "Only application elm.json is supported, not package elm.json. If you would find it useful to also support package elm.json, please open an issue at GitHub repository." when I upload my elm.json
2019-03-01T04:58:36.137800
Daysi
elmlang
general
I thought elm-upgrade automatically upgraded the file to the correct structure but maybe there is an error?
2019-03-01T04:59:32.138000
Daysi
elmlang
general
You have to put in the elm.json of the full application, not of one of the depemdencies.
2019-03-01T04:59:33.138200
Jin
elmlang
general
I did
2019-03-01T04:59:41.138400
Daysi
elmlang
general
maybe, yes. your elm.json must be of type application
2019-03-01T04:59:52.138600
Jin
elmlang
general
and your versions there must be fixed, no ranges
2019-03-01T05:00:10.138800
Jin
elmlang
general
If nothing helps, remove all dependencies from your `elm.json` and install them again. Not ideal but not that long.
2019-03-01T05:00:36.139000
Velia
elmlang
general
Hey beautiful people. I have the task at hand of given a sentence in a string, get all urls in the sentence. I found out that elm/Url parser accepts things like <http://word> as valid urls, which doesn't work for us. In writing a Url parser I arrived at a point where I have a big list of domain extension names (.com, .org, .gov) and need to match against that. I'd like to do it without backtracking to keep things fast, so I'm thinking of building a *prefix tree* out of my list and will create my parser out of that. Is there a better way to do the matching against the list? If not, could anyone recommend a library to build prefix trees? The rluiten/trie doesn't seem to allow the mapping from Trie -&gt; Parser that I need.
2019-03-01T05:41:00.144300
Tawnya
elmlang
general
<@Tawnya> Is not `Parser.oneOf [keyword ".com", keyword ".org", keyword ".gov"]` sufficient?
2019-03-01T06:06:45.145200
Lynne
elmlang
general
But from what I understand `Parser.oneOf [ keyword ".com", keyword ".<http://co.uk|co.uk>" ]` would fail for `.<http://co.uk|co.uk>` values
2019-03-01T06:10:53.146400
Tawnya
elmlang
general
Unless I used backtracking.
2019-03-01T06:11:02.146600
Tawnya
elmlang
general
Is that right?
2019-03-01T06:11:16.146800
Tawnya
elmlang
general
Not sure, why would it? .com and .<http://co.uk|co.uk> don't have a common "superstring"
2019-03-01T06:13:40.147600
Lynne
elmlang
general
Meaning there is no string for which both .com and .<http://co.uk|co.uk> are substrings
2019-03-01T06:14:01.148000
Lynne
elmlang
general
From what I see from `Parser.Advanced.keyword`'s definition, it does not progress if there is no match, so no backtracking is needed
2019-03-01T06:16:35.148800
Lynne
elmlang
general
:thumbsup: Nice. Thanks!
2019-03-01T06:24:50.149100
Tawnya
elmlang
general
Hello everyone! I have an image that I am loading with `img [ src "/images/myImage.png"] []`. When I `Browser.Navigation.pushUrl` for a new url, the link breaks. Why might this be the case?
2019-03-01T08:07:40.150800
Donya
elmlang
general
ah, nm, it started working all of a sudden. strange!
2019-03-01T08:10:04.151100
Donya
elmlang
general
Hey! I'm trying to publish my package, but I'm getting this: ``` I will now verify that everything is in order... ● Found README.md ● Found LICENSE ● All packages start at version 1.0.0 ✗ Version 1.0.0 is not tagged on GitHub! -- NO TAG ---------------------------------------------------------------------- Packages must be tagged in git, but I cannot find a 1.0.0 tag. These tags make it possible to find this specific version on GitHub. To tag the most recent commit and push it to GitHub, run this: git tag -a 1.0.0 -m "new release" git push origin 1.0.0 The -m flag is for a helpful message. Try to make it more informative! ``` The tag is there (<https://github.com/tad-lispy/elm-springs/releases/tag/1.0.0>) so what's going on?
2019-03-01T08:45:56.152500
Dorsey
elmlang
general
I believe this is some sort of caching issue with the github api.
2019-03-01T08:49:20.153400
Virgie
elmlang
general
Shall I just try again later?
2019-03-01T08:52:08.153700
Dorsey
elmlang
general
try that first, you can also force untag and then tag again
2019-03-01T08:55:29.154300
Virgie
elmlang
general
i use 0.19 to `elm build` a module and it tells me
2019-03-01T09:06:01.155000
Daysi
elmlang
general
can one not use explicit imports of that kind anymore?
2019-03-01T09:06:40.155900
Daysi
elmlang
general
Elm told me to write `import Bla exposing (Blubb(..))` instead of `(Blubb(Foo))` just before that. I corrected it but now Elm says something isn't right in an Elm package that should work ... So I wanted to ask.
2019-03-01T09:08:36.158100
Daysi
elmlang
general
in 0.19 you either import all variants/constructors, or none of them.
2019-03-01T09:09:16.158600
Virgie
elmlang
general
this makes sense if you pattern match on a value of the custom type: you need all constructors to make the pattern match exhaustive
2019-03-01T09:09:47.159300
Virgie
elmlang
general
on the other hand it is now a little harder to see where a name comes from
2019-03-01T09:10:17.159800
Virgie
elmlang
general
Hello folks, I was trying to write a `port` and did not write it correctly I guess, so the compiler told me : ``` Hint: Ports are not a traditional FFI for calling JS functions directly. They need a different mindset! Read &lt;https://elm-lang.org/0.19.0/ports&gt; to learn how to use ports effectively. ``` But the page looks empty to me. Is it just me or ? Thank you :slightly_smiling_face:
2019-03-01T09:48:14.161500
Toni
elmlang
general
There are several links in the compiler hints that are broken :disappointed:
2019-03-01T09:49:11.161900
Carman
elmlang
general
Here's the official guide page on ports: <https://guide.elm-lang.org/interop/ports.html>
2019-03-01T09:49:27.162500
Carman
elmlang
general
oh, sorry to hear that, can I open an issue or help in some way ?
2019-03-01T09:49:36.162800
Toni
elmlang
general
thanks for the link
2019-03-01T09:49:51.163000
Toni
elmlang
general
Hmm looking at the repo it looks like it's present but empty :thinking_face: <https://github.com/elm/elm-lang.org/blob/master/src/pages/0.19.0/ports.elm>
2019-03-01T09:55:23.163500
Carman
elmlang
general
<@Toni> here's a basic example :slightly_smiling_face: <https://ellie-app.com/4HH7pySpmpVa1>
2019-03-01T10:01:46.163800
Nana