workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | But how do you run your app? What you see in the browser is some bundle. Who is producing this bundle? | 2019-02-14T05:25:26.298300 | Lynne |
elmlang | general | <@Florencia> I mentioned exactly that two lines above :slightly_smiling_face: | 2019-02-14T05:25:51.298900 | Lynne |
elmlang | general | Welcome to the thread | 2019-02-14T05:25:57.299300 | Lynne |
elmlang | general | Yeah.. I was just double checking it's not inside ~/.elm | 2019-02-14T05:26:13.299700 | Teri |
elmlang | general | (the cached optimized stuff) | 2019-02-14T05:26:23.299900 | Teri |
elmlang | general | <@Lynne> ah, you're right! I totally skipped your comment :sweat_smile: | 2019-02-14T05:27:11.300300 | Florencia |
elmlang | general | Hmm | 2019-02-14T05:28:38.300900 | Teri |
elmlang | general | I am doing something wrong, but I don’t see why:
```
type Msg
= SomeMsg
| SubMsg SubMsgType
type SubMsgType
= Msg1 Bool
| Msg2 String
view: Model -> Html Msg
view model =
div []
[ input [type_ "radio", onClick (SubMsg (Msg1 True))] []
, input [type_ "text", onInput (SubMsg Msg2)] []
]
```
fails with, the first argument to `SubMsg` is not what I expect.
This `Msg2` value is a:
String -> SubMsgType
But `SubMsg` needs the 1st argument to be:
SubMsgType | 2019-02-14T05:42:06.302600 | Salvador |
elmlang | general | I am using create-elm-app | 2019-02-14T05:42:58.302700 | Teri |
elmlang | general | sorry I missed this thread :man-facepalming: | 2019-02-14T05:43:04.302900 | Teri |
elmlang | general | Np | 2019-02-14T05:43:10.303100 | Lynne |
elmlang | general | If I remember correctly it is using webpack | 2019-02-14T05:43:18.303300 | Lynne |
elmlang | general | Yes indeed | 2019-02-14T05:43:24.303500 | Teri |
elmlang | general | And I am pretty sure it is not watching your `~/.elm` folder | 2019-02-14T05:43:43.303700 | Lynne |
elmlang | general | But it's also just running the elm compiler - and I think elm does these optimizations - not webpack | 2019-02-14T05:43:48.303900 | Teri |
elmlang | general | I tried restarting everything | 2019-02-14T05:43:58.304100 | Teri |
elmlang | general | Agreed | 2019-02-14T05:44:03.304300 | Teri |
elmlang | general | Still no luck? | 2019-02-14T05:44:05.304500 | Lynne |
elmlang | general | no | 2019-02-14T05:45:37.304900 | Teri |
elmlang | general | Ok,I don't know | 2019-02-14T05:47:41.305600 | Lynne |
elmlang | general | `onInput (SubMsg << Msg2)` should do it | 2019-02-14T05:48:27.306400 | Lynne |
elmlang | general | beat me to it :smile: | 2019-02-14T05:48:38.306800 | Danika |
elmlang | general | Damn, I knew it had to be something simple. Thanks! | 2019-02-14T05:49:04.307300 | Salvador |
elmlang | general | Thank you for the support though | 2019-02-14T05:49:08.307400 | Teri |
elmlang | general | this was very helpful already | 2019-02-14T05:49:12.307600 | Teri |
elmlang | general | I often forget about composition tbh, oops! | 2019-02-14T05:51:58.308100 | Danika |
elmlang | general | Hey folks!
Considering a json like :
```{
"results": [
{
"type": "type1",
..
},
{
"type": "type2",
..
},
{
"type": "type2",
..
}
]
}```
that I'd like to map to something like:
```type alias Results =
{ type1 : {..}
, type2: List {..}
}```
The question is: do you see a way to map this easily, or should I use an intermediate representation? | 2019-02-14T07:05:59.309000 | Jonna |
elmlang | general | looks like <https://package.elm-lang.org/packages/elm-community/json-extra/latest/Json-Decode-Extra#when> is my answer | 2019-02-14T07:12:06.310800 | Jonna |
elmlang | general | sort of | 2019-02-14T07:12:09.311000 | Jonna |
elmlang | general | Oooh this is an interesting one | 2019-02-14T07:14:02.311900 | Danika |
elmlang | general | Is the shape/length of results known | 2019-02-14T07:15:20.313200 | Danika |
elmlang | general | I’m guessing not | 2019-02-14T07:15:26.313700 | Danika |
elmlang | general | I've been scratching my head for 1 or 2 hours, and I always end up needing to first decode somehow the list, then building the record | 2019-02-14T07:15:27.313800 | Jonna |
elmlang | general | there is a indeed a length field for the number of results | 2019-02-14T07:15:58.314900 | Jonna |
elmlang | general | do you want to make an ellie with an example type and json? I would like to give it a try | 2019-02-14T07:16:25.315600 | Sharon |
elmlang | general | Yes my suggestion would be decode the list and then fold that into a record. Although I would probably make the resulting record
```
{ type1: List { ... }
, type2: List { ... }
}```
Unless you know for a fact there is only ever one `type1` in your results array | 2019-02-14T07:17:49.317300 | Danika |
elmlang | general | Yeah make an ellie this could be a fun thing to figure out ^^ | 2019-02-14T07:20:03.317700 | Danika |
elmlang | general | it's a 0.18 app | 2019-02-14T07:24:37.318100 | Jonna |
elmlang | general | as far as i know, ellie is 0.19 only | 2019-02-14T07:24:55.318400 | Jonna |
elmlang | general | boo | 2019-02-14T07:25:11.318600 | Danika |
elmlang | general | <https://ellie-app.com/4JVmhfg68qJa1> | 2019-02-14T07:25:20.318800 | Jonna |
elmlang | general | won't change the logic | 2019-02-14T07:25:30.319000 | Jonna |
elmlang | general | and you’re sure there’s only ever one `foo` type in your results json? | 2019-02-14T07:26:57.319600 | Danika |
elmlang | general | yes, it has to be here | 2019-02-14T07:29:18.320200 | Jonna |
elmlang | general | > I always end up needing to first decode somehow the list, then building the record
is that a problem, though? | 2019-02-14T07:31:40.320800 | Sharon |
elmlang | general | well, it sucks but if there is no alternative... honnestly, the json is so bad I'm on the verge to sen dit to a port and deal with it there... | 2019-02-14T07:32:46.321800 | Jonna |
elmlang | general | <@Jonna> <https://ellie-app.com/4JVQbY2vgRBa1> an alternative, maybe not as ideal as you hoped, or maybe it is. Do with it what you want :sweat_smile: | 2019-02-14T07:58:29.323500 | Sharon |
elmlang | general | I'm wondering if for Navigation I can directly send out a `LinkClicked` msg via an `onClick` html attribute, or whether one always needs an a tag to send out the ´LinkClicked´ msg | 2019-02-14T08:00:46.324800 | Donya |
elmlang | general | For my use case, I wanted to navigate to an internal page when a row in a table is clicked, but there is no simple way to wrap a table row in an anchor tag | 2019-02-14T08:07:00.325600 | Donya |
elmlang | general | <@Donya> that should work | 2019-02-14T08:09:37.326000 | Nana |
elmlang | general | <@Nana> ah, maybe I can call `pushUrl` on `onClick`? | 2019-02-14T08:12:07.326700 | Donya |
elmlang | general | <@Nana> okay, i got it to work. ´onClick´ sends out an Update ´Msg´ which in turn calls ´Nav.pushUrl´ to send out a UrlChanged Cmd, and then it`s all good! | 2019-02-14T08:24:13.328200 | Donya |
elmlang | general | What is the expected behaviour of the integer division operator `//` for large numbers? The documentation does not mention anything about integer division not working about the numbers above the maximum safe int. E.g. this in the Repl:
`599616000000 // 8 => 1937555968 : Int`
where I expected the result `74952000000` | 2019-02-14T10:01:27.332000 | Kathlyn |
elmlang | general | Where if I do:
```
> toFloat 599616000000 / toFloat 8 |> round
74952000000 : Int
``` | 2019-02-14T10:02:11.332300 | Kathlyn |
elmlang | general | Expected behaviour is whatever happens in javascript I suppose | 2019-02-14T10:05:12.332900 | Danika |
elmlang | general | Well there is no such thing as an Integer in Javascript so you tell me | 2019-02-14T10:07:08.333500 | Kathlyn |
elmlang | general | <https://package.elm-lang.org/packages/elm/core/latest/Basics#Int> <@Kathlyn> | 2019-02-14T10:09:36.333700 | Huong |
elmlang | general | Cool thanks | 2019-02-14T10:10:37.333900 | Kathlyn |
elmlang | general | What is the best way to handle url updates when the app is separated into multiple modules? Are there any nice examples around? | 2019-02-14T12:58:14.335400 | Verena |
elmlang | general | <#C192T0Q1E|beginners> | 2019-02-14T14:10:05.335900 | Leopoldo |
elmlang | general | Late to the party: somewhere, the docs recommend writing a function that takes a depth and returns a fuzzer of things up to that depth. | 2019-02-14T14:39:50.336000 | Milda |
elmlang | general | Quick naming question, since I suspect more than one person here has gone down this path. I created a search interface. I want to model the `SearchResults` type as a union type that looks something like this:
```
type SearchResults
= Loading
| Results Foo
```
The question is what would you call `Foo`. For some context, it's a record that holds information like the hits, the current page, how many total results there are, etc. | 2019-02-14T17:47:00.338800 | Marcus |
elmlang | general | FWIW, right now, my model has a `searchResults` property that is a `Maybe SearchResults`. I'm moving that to a Union type. | 2019-02-14T17:47:46.339700 | Marcus |
elmlang | general | I could go with something like `SearchResultsData`, but that feels wrong. | 2019-02-14T17:48:14.340200 | Marcus |
elmlang | general | Does anyone have any ideas? | 2019-02-14T17:48:20.340400 | Marcus |
elmlang | general | Just brainstorming here. | 2019-02-14T17:48:34.340700 | Marcus |
elmlang | general | hello, anyone worked with `Http.Error` before? I m facing issue
```
createErrorMessage : Http.Error -> String
createErrorMessage httpError =
case httpError of
Http.BadUrl message ->
message
Http.Timeout ->
"Server is taking too long to respond. Please try again later."
Http.NetworkError ->
"It appears you don't have an Internet connection right now."
Http.BadStatus response ->
(response.status)
Http.BadBody response ->
response
```
This is not a record, so it has no fields to access!
460| (response.status)
^^^^^^^^
This `response` value is a:
Int
But I need a record with a status field! | 2019-02-14T17:55:00.342000 | Leopoldo |
elmlang | general | I always use `(List eachData)` | 2019-02-14T17:55:15.342100 | Noelle |
elmlang | general | `Results (List Pokemon)` | 2019-02-14T17:55:25.342300 | Noelle |
elmlang | general | <@Noelle> I'd do that too, except there's a lot of metadata that tags along with the results, like how many total pages there are, which page we are on, available facets, etc. | 2019-02-14T17:56:52.342600 | Marcus |
elmlang | general | `SearchResultsData` is a fine name for that type | 2019-02-14T17:57:24.342800 | Earlean |
elmlang | general | Can this work?
```type alias Metadata = { totalPages : Int, ... }``` | 2019-02-14T17:58:48.343000 | Noelle |
elmlang | general | Then, `Results (List Metadata)` | 2019-02-14T17:58:57.343300 | Noelle |
elmlang | general | LOL. Yeah, I'm not coming up with anything better. | 2019-02-14T17:58:59.343500 | Marcus |
elmlang | general | <@Leopoldo> <https://package.elm-lang.org/packages/elm/http/latest/Http#Error> yep it's an `Int` | 2019-02-14T17:59:08.343900 | Earlean |
elmlang | general | In elm/http 1.0 is was a `Response string` (<https://package.elm-lang.org/packages/elm/http/1.0.0/Http#Error>) | 2019-02-14T18:00:00.344300 | Earlean |
elmlang | general | I’m not sure why it was changed, I sometimes use <https://package.elm-lang.org/packages/jzxhuang/http-extras/latest/Http-Detailed> now to get the details | 2019-02-14T18:01:11.345200 | Rosalee |
elmlang | general | Hmmmm... Maybe I'm not following you. The search results are comprised of a single record of metadata and a list of the records for the actual hits. It would look something like this:
```
type alias Foo =
{ metadata: Metadata
, products: List Product
}
```` | 2019-02-14T18:01:49.345300 | Marcus |
elmlang | general | I would typically change the naming strategy slightly and do something like:
```
type SearchRequest
= Loading
| Successful SearchResults
| Error SearchError
``` | 2019-02-14T18:04:10.345500 | Claretta |
elmlang | general | I like that | 2019-02-14T18:04:33.345700 | Marcus |
elmlang | general | Ohh I misunderstood | 2019-02-14T18:05:03.345900 | Noelle |
elmlang | general | Quick question about union types and JSON decoding. I moved all of my HTTP code into a module. Within that module, I have a method called `getSearchResults`. That method builds the URL to call to get the search results. The line that does the work is:
```
Http.send msg (Http.get url searchDecoder)
```
searchDecoder looks something like this:
```
searchDecoder : Decoder SearchResultsData
searchDecoder =
Decode.succeed SearchResultsData
|> required "hitCount" int
```
That's simplified, but you get the idea.
What I actually want is for searchDecoder to return a SearchResults type, where its definition looks like:
```
type SearchResults
= Loading
| Results SearchResultsData
| Error String
```
I haven't wrapped the results of an http call in a union type yet. Can anyone point me to an example or clue me in on the right syntax? | 2019-02-14T18:13:58.351500 | Marcus |
elmlang | general | Side note, I realize that searchDecoder won't directly return a SearchResults type, but ultimately the call to `getSearchResults` hits a case in my `update` and I want the type that accompanies the update to be the union type. | 2019-02-14T18:15:48.352700 | Marcus |
elmlang | general | <@Marcus> `Http.send` has the type `send : (Result Error a -> msg) -> Request a -> Cmd msg` the key to your problem is the function ` (Result Error a -> msg) ` | 2019-02-14T18:18:46.353500 | Earlean |
elmlang | general | Ah, I think I see. | 2019-02-14T18:21:19.355400 | Marcus |
elmlang | general | ```
resultToSearchResults result = case result of
Ok value ->
Results value
Err error ->
Error error
``` | 2019-02-14T18:21:50.356000 | Earlean |
elmlang | general | I'll give that a shot. Seems clear enough. | 2019-02-14T18:23:27.357600 | Marcus |
elmlang | general | oh, actually. The `error` variable there isn't a string, you'll need to also have a function to convert the `Http.Error` in to a `String` | 2019-02-14T18:24:10.358300 | Earlean |
elmlang | general | That's no problem. So long as the large bits of plumbing are wired up, I can fill in the gaps. | 2019-02-14T18:24:43.359000 | Marcus |
elmlang | general | <@Earlean> What would the type annotation be on that function? | 2019-02-14T18:27:38.359400 | Marcus |
elmlang | general | `resultToSearchResults: (Result Http.Error SearchResultData) -> SearchResult` | 2019-02-14T18:28:50.360100 | Earlean |
elmlang | general | Sweet. Thanks. | 2019-02-14T18:29:09.360300 | Marcus |
elmlang | general | I'm a little out of my depth on this one. | 2019-02-14T18:46:00.363500 | Marcus |
elmlang | general | I think I've got this narrowed down. Last question. When I call `getSearchResults`, I want to tell it which Msg to call. I'm trying this type definition:
```
getSearchResults : SearchQuery -> (SearchResults -> msg) -> Cmd msg
```
where my `Msg` type resembles:
```
type Msg
= NewResults SearchResults
...
```
My intention is to call it like:
```
getSearchResults searchQuery NewResults
```
I'm getting type errors. Do the type annotations above look sane? | 2019-02-14T19:01:10.366900 | Marcus |
elmlang | general | Note that the implementation of `getSearchResults` is in a module. `Msg` and the calls to `getSearchResults` are in my main module. | 2019-02-14T19:02:23.368100 | Marcus |
elmlang | general | <@Marcus> you could also go with this package: <https://package.elm-lang.org/packages/krisajenkins/remotedata/latest/RemoteData>
it's a generic datatype for remote data, plus some nice functions like `fromResult`, `map2` etc. | 2019-02-14T19:04:48.369400 | Nana |
elmlang | general | I'll check it out. I want to get my approach working though. I feel like seeing it through is going to make something click in my understanding of Elm. There's something in the wiring of this that I'm close to understanding, but not quite there. | 2019-02-14T19:06:10.370500 | Marcus |
elmlang | general | <@Marcus> what type error do you see? | 2019-02-14T19:12:39.371100 | Earlean |
elmlang | general | The compiler usually provides very good error messages, read the errors carefully | 2019-02-14T19:13:33.372100 | Earlean |
elmlang | general | Good question. It's shifted around as I've been working on it. | 2019-02-14T19:14:05.372500 | Marcus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.