workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
:wink:
2019-02-06T04:38:46.972300
Antonette
elmlang
general
Looks like this is taken care of already :wink:
2019-02-06T04:39:08.972400
Antonette
elmlang
general
cannot find ping example,..
2019-02-06T04:40:07.972800
Liza
elmlang
general
but my examples will be not best - im game dev - and `pings` for me is also source of data (how long singnals from server is delayed, and how much all stuff must be predicted..)
2019-02-06T04:46:04.974100
Liza
elmlang
general
but not all application running 60fps
2019-02-06T04:46:30.974500
Liza
elmlang
general
I'm trying to _proxy_ a union type and it's constructors from one module to another so that consumers of my module don't have to import the 3rd party module (it can stay an indirect dependency), but I'm getting a ``` -- BAD EXPORT ------ /[...]/src/Website.elm The (..) syntax is for exposing union type constructors. It cannot be used with a type alias like `TextVariant` though. 6| , TextVariant(..) ^^^^^^^^^^^^^^^ Remove the (..) and you should be fine! ``` The message seems perfectly clear, but is there really no way to do this?
2019-02-06T11:40:51.979100
Dorsey
elmlang
general
The definition of the `TextVariant` is as follows: ``` type alias TextVariant = Mark.Style ```
2019-02-06T11:42:02.979700
Dorsey
elmlang
general
so `type alias TextVariant = SomeUnionType`?
2019-02-06T11:42:07.980000
Danika
elmlang
general
Nope, no can do
2019-02-06T11:42:18.980200
Huong
elmlang
general
Ha, beat me to it
2019-02-06T11:42:18.980300
Danika
elmlang
general
Ok, thanks :neutral_face:
2019-02-06T11:48:02.981000
Dorsey
elmlang
general
According to <@Huong> it's not possible: <https://elmlang.slack.com/archives/C0CJ3SBBM/p1549471338980200> . I wonder if it's a technical limitation or is there some fundamental reason for that?
2019-02-06T11:52:09.981200
Dorsey
elmlang
general
It's just not something the langauge supports - you can expose an alias, but an alias is just that - another name for an existing thing. Re-exposing imports is supported in some languages, but Elm has chosen not to add that. I don't know if there's a fundamental reason. Although, perhaps, there is one case where this could get mightily confusing: let's say I have package X, where I define `type Foo = Foo | Bar` I now create package Y, where I "reexpose" that `type Foo`. Now, I publish a new major version of package X, with `type Foo = Foo | Bar | Baz`. For the sake of argument, let's say I have `"package-x": "1.0.0 &lt;= v &lt; 3.0.0"` in package Y: Now the values exposed by package Y depend on the version of package X you happen to have installed. I'm not sure how that should even show up on the package website :smile:
2019-02-06T12:04:12.981500
Huong
elmlang
general
so, you can only expose an alias, which says nothing about the implementation details of what happens in some other module or even package
2019-02-06T12:04:36.981700
Huong
elmlang
general
Thanks <@Huong>. Insightful as always :smile:
2019-02-06T12:05:45.981900
Dorsey
elmlang
general
My `Url.Parser.fragment` decoder is working, however with a url like `/#foo%20bar` it’s parsing as `foo%20bar`. I’m expecting `foo bar`. How can I decode the uri component? [Http.uriDecode](<https://package.elm-lang.org/packages/evancz/elm-http/latest/Http#uriDecode>) is gone in the new elm/http
2019-02-06T12:54:48.984000
Myung
elmlang
general
I could make a `port` just for the native `decodeURIComponent` but I feel like I’m just doing something wrong
2019-02-06T12:57:24.984700
Myung
elmlang
general
<@Myung> You are looking for `Url.percentDecode`
2019-02-06T12:58:54.986300
Bert
elmlang
general
When I use `Url.Builder.custom` to make the url, `custom Relative [] [] (Just "foo bar")` it automatically encodes the component `/#foo%20bar`
2019-02-06T12:59:41.987900
Myung
elmlang
general
<@Bert> ooo checking it out, thanks
2019-02-06T13:00:00.988800
Myung
elmlang
general
interesting, it says to use Url.Parser instead in the docs
2019-02-06T13:00:38.990000
Myung
elmlang
general
i think Url.Parser.fragment should decode by default… this is maybe an oversight?
2019-02-06T13:01:03.991000
Myung
elmlang
general
the query parameter decoders automatically do it
2019-02-06T13:01:10.991300
Myung
elmlang
general
I noticed the same thing with my app a little while ago, and Evan is looking for evidence at this point. So if you know a popular framework that automatically does URI decoding for fragments, feel free to respond in this thread.
2019-02-06T13:01:27.991800
Bert
elmlang
general
i don’t use other frameworks
2019-02-06T13:02:01.992100
Myung
elmlang
general
i think the behavior should be consistent though
2019-02-06T13:02:10.992400
Myung
elmlang
general
1) Url.Builder automatically encodes the fragment, so 2) I would expect Url.Parser to automatically decode as well
2019-02-06T13:02:48.993600
Myung
elmlang
general
Yeah. I actually don't know if path sections are decoded or not.
2019-02-06T13:03:01.994500
Bert
elmlang
general
and 3) if the query builder/parser already has this behaviour, i think the fragment builder/parser should have the same behavior
2019-02-06T13:03:12.994800
Myung
elmlang
general
so those are my official responses :smile:
2019-02-06T13:03:24.995200
Myung
elmlang
general
<@Bert> i lied, `Url.Builder` does not automatically encode
2019-02-06T13:20:55.996700
Myung
elmlang
general
`Url.Builder.custom Url.Builder.Relative [] [] (Just "foo bar")` yields `"#foo bar"`
2019-02-06T13:21:27.997200
Myung
elmlang
general
`Url.Builder.custom Url.Builder.Relative [] [] (Just (Url.percentEncode "foo bar"))` yields the intended `"#foo%20bar"`
2019-02-06T13:21:53.997600
Myung
elmlang
general
so this is okay, albeit a pain in the ass
2019-02-06T13:22:11.998100
Myung
elmlang
general
can’t imagine why the _url builder_ doesn’t do this for us
2019-02-06T13:23:07.999000
Myung
elmlang
general
but my builder/parser is working now . thank you
2019-02-06T13:23:27.999500
Myung
elmlang
general
Is it possible to create a `Url.Parser` that consumes arbitrarily deep paths and return them as a `String`? Like `/a` or `/a/b` or `/a/b/c`. I thought `Url.Parser.custom` will do that, but apparently not.
2019-02-06T15:29:30.002100
Dorsey
elmlang
general
<@Dorsey> I imagine you’d do that with something like `&lt;/&gt; string` to match `/a/b/c/*` and then do additional parsing on the total match of `a/b/c*`
2019-02-06T15:37:24.003500
Myung
elmlang
general
if you want to match a variadic path, you’d have to capture all of the paths and then handle case for 0, 1, or more
2019-02-06T15:38:24.004800
Myung
elmlang
general
:thinking_face: but wouldn't `&lt;/&gt; string` capture only `a`?
2019-02-06T15:38:34.005000
Dorsey
elmlang
general
<@Dorsey> ah sure enough, it says it only matches “one segment”
2019-02-06T15:39:43.005500
Myung
elmlang
general
never tried to do something like this
2019-02-06T15:41:36.006600
Myung
elmlang
general
Yes. I thought to do some magic with `List.foldl`, but I would need `andThen` to carry result of one parser to another.
2019-02-06T15:42:03.007800
Dorsey
elmlang
general
i’ll think about it over lunch :green_salad:
2019-02-06T15:42:06.007900
Myung
elmlang
general
yeah i was thinking about a recursive or folding parser too..
2019-02-06T15:42:26.008500
Myung
elmlang
general
Enjoy your lunch. I just ate supper :stuck_out_tongue:
2019-02-06T15:42:38.009000
Dorsey
elmlang
general
i’m thinking the solution will surprise us
2019-02-06T15:42:45.009200
Myung
elmlang
general
it _should_ be simple
2019-02-06T15:43:10.009800
Myung
elmlang
general
Let's hope it will be a happy surprise.
2019-02-06T15:43:19.010100
Dorsey
elmlang
general
haha yeah
2019-02-06T15:43:24.010400
Myung
elmlang
general
The only example where multiple segments are captured is for `map`. Maybe that's the key.
2019-02-06T15:45:10.011000
Dorsey
elmlang
general
hmm, what's the point of parsing an url and then returning it as a string? why not just use the original string then?
2019-02-06T15:51:44.011900
Nana
elmlang
general
To match against arbitrary paths, e.g. pointing to files in a filesystem. There are certain rules about what paths are valid, but the depth of the path is variadic.
2019-02-06T16:00:08.013700
Dorsey
elmlang
general
Also, I want to have the part "below" a certain path. Like: `/file/**/*.txt` to give me `File "whatever/path/was/matched.txt"`.
2019-02-06T16:01:49.015300
Dorsey
elmlang
general
:wave: Where did you learn the term variadic?
2019-02-06T16:35:14.015500
Agustin
elmlang
general
From <@Myung> <https://elmlang.slack.com/archives/C0CJ3SBBM/p1549485504004800>
2019-02-06T16:48:12.015700
Dorsey
elmlang
general
:smile:
2019-02-06T16:48:16.016000
Dorsey
elmlang
general
:joy:
2019-02-06T16:49:00.016200
Agustin
elmlang
general
<@Myung> were did you learn that term?
2019-02-06T16:49:10.016400
Agustin
elmlang
general
I think we used it correctly, didn't we?
2019-02-06T16:49:34.016600
Dorsey
elmlang
general
I ask as I’ve only seen it once before, in a Ruby PR, and the author was like “its obvious, everyone knows this” and myself and another Ruby dev both with over 10 years of experience had never heard of it before
2019-02-06T16:50:02.016800
Agustin
elmlang
general
So I’m keen to learn were it’s been introduced to others, feel like I’m missing out
2019-02-06T16:50:24.017000
Agustin
elmlang
general
Always be learning etc
2019-02-06T16:50:52.017200
Agustin
elmlang
general
I think I heard / saw the word before, but it probably wouldn't come to my mind without a prompt from Ohko. I probably couldn't explain it's meaning without some lookup.
2019-02-06T16:51:34.017400
Dorsey
elmlang
general
Once you are familiar with some term, it's difficult to asses how well known it is in general.
2019-02-06T16:52:42.017600
Dorsey
elmlang
general
<@Dorsey> i thought about it a little more, but i’m sad to say i don’t have a great recommendation
2019-02-06T18:02:45.018500
Myung
elmlang
general
if i had your problem i would use either a query param or the fragment
2019-02-06T18:03:12.019000
Myung
elmlang
general
but only because i don’t know of a “better” way to do it
2019-02-06T18:03:27.019300
Myung
elmlang
general
`/download?p=/foo/bar/file` or `/download#/foo/bar/file`
2019-02-06T18:04:20.020600
Myung
elmlang
general
Yeah, that won't work for me. I'm thinking about generating a long list of parsers using `map`.
2019-02-06T18:05:12.021600
Dorsey
elmlang
general
I'm not there yet, but I think I'm getting close.
2019-02-06T18:05:33.022400
Dorsey
elmlang
general
yeah you could have parsers that match 1 segment, 2, 3, up to N segments
2019-02-06T18:05:34.022500
Myung
elmlang
general
and then error out after that
2019-02-06T18:05:37.022700
Myung
elmlang
general
Now that I say this out loud, it sounds like the Elm way to do things
2019-02-06T18:06:11.023400
Myung
elmlang
general
kinda like you see with map map3 map4 etc
2019-02-06T18:06:24.023800
Myung
elmlang
general
Mhm.
2019-02-06T18:06:35.024100
Dorsey
elmlang
general
<@Dorsey> thanks for sharing your issue. would you mind pinging me if you come up with something else?
2019-02-06T18:07:14.024800
Myung
elmlang
general
Sure.
2019-02-06T18:07:47.025000
Dorsey
elmlang
general
<@Myung> are you affiliated with the elm/url somehow?
2019-02-06T18:11:04.025400
Dorsey
elmlang
general
Is there a way to figure out why `elm install elm/http` wants to install 1.0.0 if 2.0.0 is the latest?
2019-02-06T18:29:11.026000
Kimiko
elmlang
general
check your elm.json?
2019-02-06T18:29:56.026200
Ruthann
elmlang
general
What do I check for, exactly? `elm/http` isn't mentioned explicitly in it
2019-02-06T18:33:18.026800
Kimiko
elmlang
general
<@Kimiko> it's probably because of other packages depending on `1.0.0`. Try removing and installing everything again.
2019-02-06T18:34:28.027800
Dorsey
elmlang
general
E.g. you may have older version of `elm/core` and it depends on `http 1.0.0`.
2019-02-06T18:35:11.028400
Dorsey
elmlang
general
Ah, yes, I guess it was `elm/core` pinning the dependency. Thanks. And I guess from your reply there's no automatic way to find which package is responsible, I just have to bisect my dependencies or something?
2019-02-06T18:36:41.029400
Kimiko
elmlang
general
I don't think there is. Dependency management needs some more love, I guess :wink:
2019-02-06T18:39:43.030200
Dorsey
elmlang
general
Thanks!
2019-02-06T18:39:56.030400
Kimiko
elmlang
general
There’s a third-party project that can help with it. I’ll see if I can find it!
2019-02-06T18:42:17.030500
Lorilee
elmlang
general
<https://www.markuslaire.com/github/elm-dependencies-analyzer/>
2019-02-06T18:45:11.030700
Lorilee
elmlang
general
This is a pretty helpful project. I just used it to find updates etc
2019-02-06T18:45:25.030900
Lorilee
elmlang
general
Very cool, thanks!
2019-02-06T18:48:31.031100
Kimiko
elmlang
general
Hey, I almost got it. Actually I got it if I hardcode the type of the parser, but I want it to be parametrized. Here is the whole code (not working): ``` module Routes exposing ( Route(..) , parse , parser ) import Url exposing (Url) import Url.Parser as Parser exposing (..) type Route = Home | Content String | NotFound parser : Parser (Route -&gt; Route) Route parser = let content = Parser.custom "Content" (\path -&gt; case String.split "." path of [ base, "html" ] -&gt; Just base _ -&gt; Nothing ) variadic last = 10 |&gt; List.range 1 |&gt; List.foldl (\_ parser_ -&gt; Parser.oneOf [ parser_ , Parser.map (\parent path -&gt; parent ++ "/" ++ path ) (Parser.string &lt;/&gt; parser_) ] ) last in Parser.oneOf [ Parser.map Home <http://Parser.top|Parser.top> , Parser.map Content (variadic content) ] parse : Url -&gt; Route parse url = url |&gt; Parser.parse parser |&gt; Maybe.withDefault NotFound ```
2019-02-06T19:19:27.031700
Dorsey
elmlang
general
And here is a working example (with hardcoded type): ``` module Routes exposing ( Route(..) , parse , parser ) import Url exposing (Url) import Url.Parser as Parser exposing (..) type Route = Home | Content String | NotFound parser : Parser (Route -&gt; Route) Route parser = let content = Parser.custom "Content" (\path -&gt; case String.split "." path of [ base, "html" ] -&gt; Just (Content base) _ -&gt; Nothing ) variadic last = 10 |&gt; List.range 1 |&gt; List.foldl (\_ parser_ -&gt; Parser.oneOf [ parser_ , Parser.map (\parent child -&gt; case child of Content path -&gt; Content (parent ++ "/" ++ path) _ -&gt; NotFound ) (Parser.string &lt;/&gt; parser_) ] ) last in Parser.oneOf [ Parser.map Home <http://Parser.top|Parser.top> , variadic content ] parse : Url -&gt; Route parse url = url |&gt; Parser.parse parser |&gt; Maybe.withDefault NotFound ```
2019-02-06T19:21:31.031900
Dorsey
elmlang
general
Thanks for sharing <@Lorilee>
2019-02-06T19:23:36.032100
Dorsey
elmlang
general
The signature of `Parser.map` is really bizarre. I'm trying to wrap my head around it.
2019-02-06T19:24:51.032400
Dorsey
elmlang
general
``` -- CORRUPT BINARY - /Users/…/Lookup.elmo The binary data at /Users/…/elm-stuff/0.19.0/Lookup.elmo is corrupt. ``` Couldn’t find an issue on elm/compiler about it
2019-02-06T19:45:57.033100
Ruthann
elmlang
general
nuking elm-stuff works, wonder if this is a known/tracked issue
2019-02-06T19:46:29.033600
Ruthann
elmlang
general
i take that back, mentioned here: <https://github.com/elm/compiler/issues/1853#issuecomment-440618037>
2019-02-06T19:47:06.033800
Ruthann
elmlang
general
I have a form with (so far) 5 text input fields. Initially I had one `Msg` for each field, e.g. `EmailUpdated String`. However, I realized I could get away with a single message that packs a closure, `UpdateInput (String -&gt; Model -&gt; Model) String`. The closure then gets defined right at the relevant input, instead of over in the update function. Are there reasons this might be a bad idea?
2019-02-06T22:29:12.036100
Dede
elmlang
general
Snippet: ```type alias Model = { username : String , full_name : String , display_name : String , email : String , password : String } type Msg = SignupPressed | UpdateInput (String -&gt; Model -&gt; Model) String view model = div [] [ input [ placeholder "Full name" , value model.full_name , onInput UpdateInput (\full_name model -&gt; { model | full_name = full_name }) ] , ... ] update model msg = case msg of UpdateInput updater value -&gt; ( model |&gt; updater value, Cmd.none ) SignupPressed -&gt; ( model, Cmd.none ) ...```
2019-02-06T22:29:27.036200
Dede