workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
that's `"debois/elm-dom"`
2019-04-25T01:00:29.403100
Earlean
elmlang
general
ah, i see that now, thanks
2019-04-25T01:01:58.403300
Lorriane
elmlang
general
Can I expose a type alias (record) constructor in a module?
2019-04-25T04:13:40.404400
Erlene
elmlang
general
I can export the type alias, but that doesn't export the constructor it seems.
2019-04-25T04:13:50.404700
Erlene
elmlang
general
you mean sth like ``` module X exposing (MyRec) type alias MyRec = {v: String, b: String} ```
2019-04-25T04:14:35.404800
Floy
elmlang
general
?
2019-04-25T04:14:37.405000
Floy
elmlang
general
I should be perfectly doable, AFAIR, to have in module that imported that something like: ``` import X type alias Model = {rec: MyRec} model = {rec = {v="1", b="1"} model2 = {rec = MyRec "1" "1"} ```
2019-04-25T04:15:06.405200
Floy
elmlang
general
I was trying to write: ``` MyRec "first" "second" ```
2019-04-25T04:23:07.406700
Erlene
elmlang
general
Type alias constructors are always public, you can't export the type only. `exposing (MyTypeAlias)` should be enough
2019-04-25T04:23:10.406900
Dayna
elmlang
general
That does not seem to work.
2019-04-25T04:23:17.407000
Erlene
elmlang
general
did you import it, where you’re trying to use it?
2019-04-25T04:27:25.407200
Huong
elmlang
general
Yes, I did, just as the example above.
2019-04-25T04:45:46.407800
Erlene
elmlang
general
Hello everyone,
2019-04-25T04:46:20.408100
Calista
elmlang
general
You have to also expose `MyRec` when importing `X`: `import X exposing (MyRec)` or write `X.MyRec "first" "second"`
2019-04-25T04:48:16.409400
Lynne
elmlang
general
oh, the example is incomplete. Three variations that should work: ```import X type alias Model = {rec: X.MyRec} model = {rec = {v="1", b="1"} model2 = {rec = X.MyRec "1" "1"}``` or ```import X exposing (MyRec) type alias Model = {rec: MyRec} model = {rec = {v="1", b="1"} model2 = {rec = MyRec "1" "1"}```
2019-04-25T04:48:20.409600
Huong
elmlang
general
or ```import X exposing (..) type alias Model = {rec: MyRec} model = {rec = {v="1", b="1"} model2 = {rec = MyRec "1" "1"}```
2019-04-25T04:48:33.410000
Huong
elmlang
general
I am trying to compile ELM on freeBSD system, I followed this article steps <https://www.codementor.io/jwazne/install-elm-on-freebsd-fltzbcsiu> , but I can't complete the last command which is `runhaskell BuildFromSource.hs 0.18`
2019-04-25T04:48:34.410300
Calista
elmlang
general
<https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236805> here’s a .shar file for elm 0.19
2019-04-25T04:49:59.410600
Huong
elmlang
general
probably a good idea to install the pre-compiled ghc and cabal packages, too
2019-04-25T04:50:24.410800
Huong
elmlang
general
There is no .shar for elm 0.18 because I have some uncompatible dependencies with 0.19
2019-04-25T04:51:52.411000
Calista
elmlang
general
You could have a look at this: <https://bitbucket.org/psagers/elm-freebsd>
2019-04-25T04:53:12.411200
Huong
elmlang
general
<@Lynne> I tried using a qualified option, but I still got the complaint my type alias constructor was not available.
2019-04-25T04:59:38.411600
Erlene
elmlang
general
<@Huong> sorry 'bout incompleteness
2019-04-25T05:01:36.411800
Floy
elmlang
general
Well, either you don't expose it in the module definition of `X` or there is something else preventing Elm from discovering the right module
2019-04-25T05:01:46.412000
Lynne
elmlang
general
Double check that you have `module X exposing (MyRec)` in the `X.elm`
2019-04-25T05:02:29.412200
Lynne
elmlang
general
Hmm, yes, you're right, this simple example works!
2019-04-25T05:03:38.412600
Erlene
elmlang
general
I need to come up with the actual case, where it doesn't.
2019-04-25T05:04:08.412800
Erlene
elmlang
general
Please do
2019-04-25T05:04:29.413000
Lynne
elmlang
general
Ah, perhaps the reason might be I have an indirection.
2019-04-25T05:04:45.413200
Erlene
elmlang
general
So in module Y I import X, and then have:
2019-04-25T05:04:55.413400
Erlene
elmlang
general
``` type alias MyRec = X.MyRec ```
2019-04-25T05:05:14.413600
Erlene
elmlang
general
But it could be that my type alias constructor is different.
2019-04-25T05:05:28.413800
Erlene
elmlang
general
The actual type alias is: ``` type alias ListItem m = { ... } ```
2019-04-25T05:05:50.414000
Erlene
elmlang
general
Ok, so you have a type parameter
2019-04-25T05:06:06.414200
Lynne
elmlang
general
Yeah.
2019-04-25T05:06:11.414400
Erlene
elmlang
general
Then not writing it may very well be the reason of the compiler's complaints
2019-04-25T05:06:52.414700
Lynne
elmlang
general
If only I new how to write it :slightly_smiling_face:
2019-04-25T05:09:11.414900
Erlene
elmlang
general
`type alias MyRec m = X.MyRec m`?
2019-04-25T05:09:36.415100
Lynne
elmlang
general
(if you ever need defining your own alias; it is probably easier to just expose it)
2019-04-25T05:10:22.415300
Lynne
elmlang
general
I suppose something like that, but I need to have a good look at what m is. I have things like `Html m`, so that `m`, but I never have an `m` by itself.
2019-04-25T05:11:40.415500
Erlene
elmlang
general
elm reactor seems to enjoy serving me stale assets
2019-04-25T05:14:40.415900
Adrian
elmlang
general
is there an easy way to avoid this?
2019-04-25T05:14:45.416100
Adrian
elmlang
general
In case of a record `m` can be a record which is extended by your `ListItem` or type of some field in `ListItem`. In first case you would see something like ``` type alias ListItem m = { m | anotherField : String } ``` in the second ``` type alias ListItem m = {someField : m } ```
2019-04-25T05:14:48.416200
Lynne
elmlang
general
it's probably browser caching, I suppose
2019-04-25T05:15:18.416600
Adrian
elmlang
general
If you never provide anything concrete in place of `m` and `ListItem m` is your creation then most likely you don't need `m` at all. In case of `Html m` it means type of messages produced by `Html` nodes if you meant the `elm/html` module of course.
2019-04-25T05:16:02.416800
Lynne
elmlang
general
`elm reactor` is not really a tool for long-term development
2019-04-25T05:17:35.417400
Lynne
elmlang
general
You'd better switch to something more suitable and convenient :slightly_smiling_face:
2019-04-25T05:17:46.417700
Lynne
elmlang
general
good point!
2019-04-25T05:18:35.418200
Adrian
elmlang
general
Does anybody understand why in `Http` package id for tracking is a string supplied by the consumer? What would be the behaviour in case in different parts of the program same string gets accidentally supplied? Why won’t `Http.request` just return the opaque id which would be guaranteed to be unique?
2019-04-25T06:45:04.420000
Loida
elmlang
general
I am wondering if it was an intentional decision due to some use cases or just an accident
2019-04-25T06:46:30.420400
Loida
elmlang
general
Given that it's a pure function...how would it get this unique id?
2019-04-25T06:47:33.420600
Earlean
elmlang
general
Http module is stateful <https://github.com/elm/http/blob/2.0.0/src/Http.elm#L953-L961>. The id can be just an int which starts from 0 and gets increased on each request creation.
2019-04-25T06:51:15.420800
Loida
elmlang
general
Or it can be the `Process.Id`
2019-04-25T06:51:55.421000
Loida
elmlang
general
So if I made two calls to `Http.request`with the same parameters I would get two different results?
2019-04-25T06:55:33.421200
Earlean
elmlang
general
or two results that were equal but actually different?
2019-04-25T06:56:08.421400
Earlean
elmlang
general
You do get 2 different commands, don’t you?
2019-04-25T06:56:20.421600
Loida
elmlang
general
no, it's a pure function. You get the same result for the same parameters
2019-04-25T06:58:35.421900
Earlean
elmlang
general
I can make two calls to `Http.request` with the same parameters, ignore the return value of the second call and return the result of the first call to the runtime twice in a Cmd.batch and the result will be the same
2019-04-25T06:59:49.422100
Earlean
elmlang
general
All functions in Elm are referentially transparent (at least from the perspective of your Elm code)
2019-04-25T07:01:20.422300
Earlean
elmlang
general
<https://ellie-app.com/5n3LY26BBY7a1>
2019-04-25T07:05:54.422500
Loida
elmlang
general
It’s a function, not a data. And you can’t compare functions. I understand it as commands are not equal.
2019-04-25T07:07:14.422700
Loida
elmlang
general
I’ll have a little time today and will ping you if I get something working. :slightly_smiling_face:
2019-04-25T07:08:43.422900
Jeanene
elmlang
general
Not sure I see how this is different from having `Id` for which equality does not work.
2019-04-25T07:08:53.423100
Loida
elmlang
general
the cmds are interchangable even if you can't check them for equality
2019-04-25T07:09:28.423300
Earlean
elmlang
general
the `Id` would also need to be interchangable
2019-04-25T07:09:50.423500
Earlean
elmlang
general
which means that the problem you're address still exists
2019-04-25T07:10:16.423700
Earlean
elmlang
general
Ok, I see
2019-04-25T07:10:42.423900
Loida
elmlang
general
Thanks
2019-04-25T07:10:44.424100
Loida
elmlang
general
Thank you for informations, I will try it. <@Huong>
2019-04-25T08:10:43.424600
Calista
elmlang
general
are there any differences to these two snippets? ``` let partialFunc = myFunc x in List.map partialFunc someList ``` vs. ``` List.map (myFunc x) someList ```
2019-04-25T09:58:44.002100
Vilma
elmlang
general
is storing the partial func in a variable and use it in the `List.map` more efficient or something like that?
2019-04-25T09:59:17.002500
Vilma
elmlang
general
<@Vilma> not in that specific case
2019-04-25T09:59:49.002800
Nana
elmlang
general
<@Nana> could you explain when it is beneficial?
2019-04-25T10:00:32.003200
Vilma
elmlang
general
well, you can use `let` to avoid calculating the same thing multiple times
2019-04-25T10:06:51.004500
Nana
elmlang
general
but `List.map (myFunc x) someList` will only call `myFunc` once, then the new function that `myFunc` returns will be called for each item
2019-04-25T10:09:11.005700
Nana
elmlang
general
I see
2019-04-25T10:14:50.006100
Vilma
elmlang
general
and the compiler is free to do these kinds of microoptimisations itself so they're not really worth spending time thinking about.
2019-04-25T10:19:43.007800
Earlean
elmlang
general
I am following the architecture from elm-spa-example where every page has its own set of model, view and update. In my app there is a header with a button that opens a modal that has some state, any idea where I can store the messages / model of the header and modal?
2019-04-25T12:24:13.009200
Dayna
elmlang
general
this may help: <https://discourse.elm-lang.org/t/how-to-implement-modal-dialogs-in-an-elm-spa/1823>
2019-04-25T12:31:32.009400
Miyoko
elmlang
general
and this one: <https://medium.com/front-end-weekly/programming-in-elm-modals-in-a-pure-environment-bc2cf98fbc33>
2019-04-25T12:31:53.009600
Miyoko
elmlang
general
<@Francis> I got about halfway there…but I’ll have to put that on the backburner for a while. I essentially got a `GetPresign` cmd -&gt; decode presign response &amp; update my model record with that data, then pass that into a `SendUpload` cmd… It’s a little frustrating b/c the resources for building that are so slim. Lotta bota3/python resources…
2019-04-25T13:03:45.010800
Jeanene
elmlang
general
Well the links didn't help much but I think I figured out a solution. My model is a custom type `type Model = Login Login.Model Session | Home Home.Model Session`. I have decided to keep the modal state in the session so that it's accessible everywhere. If I want to update the session then I run the Session.update inside Login.update for example and modify the session inside login that way.
2019-04-25T13:47:13.013200
Dayna
elmlang
general
Probably a super noob question but got me thinking: can you use union types that hold values and read / set them without commands instead of using records?
2019-04-25T13:49:36.014600
Wenona
elmlang
general
You can pattern match/destructure a value and then make a new one. I’m not clear what you mean by “without commands”.
2019-04-25T13:51:01.015400
Leoma
elmlang
general
You can also expose a map function for that type so that any module can modify it without exposing internals.
2019-04-25T13:51:40.015600
Dayna
elmlang
general
What I’m trying to do is something like this: <https://gist.github.com/glinesbdev/1b7d40cf88ba77ad8cc4fe354a463087>
2019-04-25T13:57:21.015900
Wenona
elmlang
general
What about ``` gridAttributes grid = [ displayGrid , case Grid of GridTemplateColumn str-&gt; style "grid-template-columns" str GridTemplateRow str -&gt; style "grid-template-rows" str ... etc ] ```
2019-04-25T14:08:51.016100
Dayna
elmlang
general
``` s : Grid -&gt; Maybe String s grid = case grid of GridTemplateColumn (Just string) -&gt; Just string GridTemplateRow (Just string) -&gt; Just string ... _ -&gt; Nothing ```
2019-04-25T14:22:01.016400
Leoma
elmlang
general
Ah yeah, that makes sense. My next question is where are those values getting set? I see that you're reading them there but how would they come to hold its `str` value?
2019-04-25T14:50:15.016600
Wenona
elmlang
general
You will need to construct a Grid value when you call the gridAttributes function. If you define a custom type and export it with `(..)` other modules can import it and call any of the constructors of the Grid type to get a value
2019-04-25T14:54:31.016800
Dayna
elmlang
general
Sounds like a similar lack of documentation I ran into. The path of least resistance was the sdk with a port. That’s where I eventually settled and it works well enough. Thanks for the update.
2019-04-25T15:37:48.019200
Francis
elmlang
general
if someone could give me a help on this: <https://discourse.elm-lang.org/t/decoding-several-json-fields-into-a-specific-data-structure/3552> I’d be grateful :slightly_smiling_face:
2019-04-25T16:25:34.019900
Vilma
elmlang
general
<https://ellie-app.com/5ndvNfbv8Qba1>
2019-04-25T16:42:18.020200
Huong
elmlang
general
Well, I know the question may be a little obvious, but I wonder if Elm is "strong" in 2019 to be learned and used in production?
2019-04-25T17:10:44.020800
Shona
elmlang
general
You beat me to it :stuck_out_tongue:
2019-04-25T17:18:44.021000
Wenona
elmlang
general
Is there a canonical way to write a function to do an http request that can be used in multiple Elm apps? In particular the bits that mess with Model and Msg, or are those types absolutely locked to the app?
2019-04-25T17:30:16.023300
Robbyn
elmlang
general
Being new myself, type signatures are a little different than what I’m used to in other languages. Does `Decoder (Dict String (List String))` Mean a Decoder of a String dictionary of a String list?
2019-04-25T17:33:31.023400
Wenona
elmlang
general
The `msg` part of `Http.get : { url : String, expect : Expect msg } -&gt; Cmd msg` doesn't have to be a Msg, it can be anything. For example you could have it return `Cmd (Result Http.Error String)` and then do Cmd.map in your apps.
2019-04-25T17:39:06.023600
Dayna
elmlang
general
Ok, you can push some stuff down to a common set of functions, but you still need some boilerplate to make Models and Msgs. I'd have to think really hard about a solution that didn't need that and still maintained good type safety.
2019-04-25T17:45:25.024000
Robbyn
elmlang
general
Anything that has a lower case type are “generic”, or that’s how I think of them. You can substitute them for other things. But keep in mind that you’ll have to change how you would normally deal with “normal” stuff like the Cmd Msg pattern, as mentioned by gigobyte.
2019-04-25T17:49:33.024200
Wenona