workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | <@Dede> it's certainly something you can do. But it breaks the debugger and can make it harder to know what happens when a Msg is passed to `update` | 2019-02-06T23:14:07.036600 | Earlean |
elmlang | general | Breaks the debugger completely, or just produces opaque closure values all over? | 2019-02-06T23:26:10.036800 | Dede |
elmlang | general | The debugger can't serialise functions do storing functions in msgs or the model breaks the debugger | 2019-02-07T00:36:37.037100 | Earlean |
elmlang | general | `UpdateInput Email "some@email"` is an operation that avoids having functions in the msg | 2019-02-07T00:37:52.037300 | Earlean |
elmlang | general | You just need a type for the form that has constructors for each field and provide a mapping between the field indentification value and a function to update the model | 2019-02-07T00:38:57.037500 | Earlean |
elmlang | general | Hi all. Am I right in thinking there's no way to combine extensible records (à la _Intersection Types_ in TypeScript or _multiple bounds_ in Java even)? | 2019-02-07T04:15:12.039700 | Corinne |
elmlang | general | None | 2019-02-07T04:18:56.041200 | Corinne |
elmlang | general | You can do something like this:
```
type alias WithId m =
{ m | id : Int }
type alias WithName m =
{ m | name : String }
type alias User =
WithId (WithName { age : Int })
``` | 2019-02-07T04:22:22.041500 | Karissa |
elmlang | general | Interesting! Is that then compatible with just a plain record of `{name="foo", id="bar"}` ? | 2019-02-07T04:24:33.041700 | Corinne |
elmlang | general | Your example would be:
```
type alias Named a = { a | name : String }
type alias Aged a = { a | age : Int }
type alias NamedAndAged = Named (Aged {})
``` | 2019-02-07T04:24:45.041900 | Karissa |
elmlang | general | there `NamedAndAged` is basically a `{ name : String, age : Int }`. | 2019-02-07T04:25:16.042200 | Karissa |
elmlang | general | awesome! | 2019-02-07T04:25:25.042400 | Corinne |
elmlang | general | Thanks, I'll try this out | 2019-02-07T04:25:33.042600 | Corinne |
elmlang | general | I'm curious what the type of `NamedAndAged` would be when used as a constructor function | 2019-02-07T04:26:02.042800 | Karissa |
elmlang | general | It would be cool to support something like `Named & Aged` to avoid excess aliases (there could be a lot of combinations...) | 2019-02-07T04:26:18.043000 | Corinne |
elmlang | general | If you can do `NamedAndAged "Bob" 42` | 2019-02-07T04:26:35.043300 | Karissa |
elmlang | general | Oh you can combined them and still be generic like:
`type alias NamedAndAged a = Named (Aged a)` | 2019-02-07T04:27:26.043500 | Karissa |
elmlang | general | and then `type alias User = NamedAndAged { id : Int }` for example. | 2019-02-07T04:27:52.043700 | Karissa |
elmlang | general | never actually used these trick in a application though. | 2019-02-07T04:28:13.043900 | Karissa |
elmlang | general | But it was fun to find out you could do it. | 2019-02-07T04:28:27.044100 | Karissa |
elmlang | general | Hmm, I tried this in the elm repl, it seems elm doesn't provide constructor functions for records defined like this. | 2019-02-07T04:31:47.044400 | Karissa |
elmlang | general | ```
> type alias Named a = { a | name : String }
> type alias Aged a = { a | age : Int }
> type alias NamedAndAged a = Named (Aged a)
> type alias User = NamedAndAged { id : Int }
> User
-- NAMING ERROR ------------------------------------------------------------ elm
I cannot find a `User` constructor:
8| User
^^^^
These names seem close though:
EQ
Err
Just
False
Hint: Read <https://elm-lang.org/0.19.0/imports> to see how `import`
declarations work in Elm.
> type alias Test = { test : Int }
> Test
<function> : Int -> Test
``` | 2019-02-07T04:33:33.044600 | Karissa |
elmlang | general | Give me a minute to hop onto my laptop. | 2019-02-07T04:37:12.045500 | Danika |
elmlang | general | I don't think extensible records get a constructor the same way records do | 2019-02-07T04:46:14.046100 | Danika |
elmlang | general | they dont | 2019-02-07T04:46:25.046300 | Liza |
elmlang | general | that is main disadvantage | 2019-02-07T04:46:42.046500 | Liza |
elmlang | general | I wonder how useful/necessary they (extensible records) are in practice | 2019-02-07T04:47:32.046700 | Danika |
elmlang | general | I guess these type aliases are not meant to be used to define values, but rather to constraint function signatures. | 2019-02-07T04:47:37.046900 | Karissa |
elmlang | general | At least that's the only use of extensible record I know of. | 2019-02-07T04:48:15.047100 | Karissa |
elmlang | general | <https://github.com/justgook/platformer/blob/revision3/lib/elm-tiled/src/Tiled/Object.elm#L22-L28> - here is example - on how i moved away from `extensible record` to custom types | 2019-02-07T04:50:01.047300 | Liza |
elmlang | general | It seems like a hacky use to get some sort of typeclass functionality to work. I think you're better off avoiding extensible records unless you have a really obvious usecase for them | 2019-02-07T04:50:17.047500 | Danika |
elmlang | general | ^ You can generally just make your own type that covers all your use cases if you think about it hard enough | 2019-02-07T04:50:38.047700 | Danika |
elmlang | general | >I wonder how useful/necessary they (extensible records) are in practice
<https://github.com/justgook/platformer/blob/revision3/lib/elm-tiled/src/Tiled/Tileset.elm#L455> - btw - here is example on real-live usage of them.. but maybe is point move to some custom type .. | 2019-02-07T04:52:28.048000 | Liza |
elmlang | general | and missing constructor is other problem.. for creating such data - you need to write constructor by your self, and as 0.19 you cannot “inject” new fields to record - they become kind of pointless.. | 2019-02-07T04:54:42.048400 | Liza |
elmlang | general | `merge: TilesDataPlain {} -> a -> TilesDataPlain a` kind of not not possible today | 2019-02-07T04:54:56.048600 | Liza |
elmlang | general | 0.18 was - `merge {prop1,prop2} rest = {rest | prop1 = prop1, prop2= prop2}` | 2019-02-07T04:57:27.049000 | Liza |
elmlang | general | now You must reconstruct that record fully, and as you don’t know structure of `a` you can’t do it any more.. | 2019-02-07T04:58:50.049200 | Liza |
elmlang | general | extensible record:
0.18 - better not
0.19 - don’t - that is pain | 2019-02-07T04:59:25.049400 | Liza |
elmlang | general | Also, I think i'm seeing that `NamedAndAged` isn't compatible with `Named` | 2019-02-07T05:03:52.049700 | Corinne |
elmlang | general | Are you doing this for any specific purpose, or just curiosity | 2019-02-07T05:07:55.050000 | Danika |
elmlang | general | You can turn that `UpdateInput (String -> Model -> Model) String` into an `UpdateInput Model` easily:
```
view model =
-- ...
onInput (\full_name -> UpdateInput { model | full_name = full_name })
-- ...
``` | 2019-02-07T05:14:50.050200 | Tamra |
elmlang | general | It seemed very much like the right thing to do in order to abstract away from concrete types in an algorithm. Perhaps the same reason you'd code to interfaces in an OOP | 2019-02-07T05:24:32.050400 | Corinne |
elmlang | general | > It seems like a hacky use to get some sort of typeclass functionality to work.
Elm doesn't work like Haskell or something. Its totally OK to have `Maybe.map` and `List.map` as completely separate functions, instead of have Maybe and List implement some Functor (in this example) typeclass like you would in Haskell.
Elm doesn't have this sort of ad hoc polymorphism (we were talking about this yesterday in <#C192T0Q1E|beginners> I think). | 2019-02-07T05:37:32.050700 | Danika |
elmlang | general | I think this is an obvious answer. But assuming identical functionality do `browser.element .document .application` and `platform.worker` produce different sized bundles? | 2019-02-07T08:32:03.051800 | Danika |
elmlang | general | Not really. `Platform` doesn't require `elm/browser` and `elm/html`, so you save out on a couple of dependencies and indirect dependencies. Even with function-level dead code elimination, I think `browser` bundles will still be a little larger | 2019-02-07T08:52:03.051900 | Huong |
elmlang | general | Using extensible records to model an inheritance hierarchy tends to be clunky in Elm. | 2019-02-07T09:22:39.052400 | Carman |
elmlang | general | There are a few other ways to get similar flexibility, depending on what your problem is | 2019-02-07T09:22:56.052600 | Carman |
elmlang | general | <@Earlean> Thanks. The reason I am playing with the closures is that it isolates the update logic closer to the use point; I don’t love the profusion of entries in `update` and `view` that come with lots of form elements. The secondary tag style doesn’t really solve that. | 2019-02-07T09:26:08.052800 | Dede |
elmlang | general | 1. Your problem might be able to be solved with a _regular custom type_, possibly with a type variable
2. You may want to _compose_ some custom types. This approach is nice because it allows you to nest just like the extensible record but the `a` can be _anything_, not just a record.
3. You may want to _derive_ a common structure from disparate types | 2019-02-07T09:26:29.053000 | Carman |
elmlang | general | <@Tamra> Due to the asynchronous nature of updates, you can get in trouble closing over the model available to you at the time you click the button. | 2019-02-07T09:26:45.053200 | Dede |
elmlang | general | Example of approach 2
```
type Named a = Named String a
type Aged a = Aged Int a
type alias NamedAndAged a = Named (Aged a)
``` | 2019-02-07T09:28:02.053400 | Carman |
elmlang | general | `type Aged a = Aged Int a` - you mean | 2019-02-07T09:29:05.053600 | Liza |
elmlang | general | good catch. fixed :+1: | 2019-02-07T09:29:32.054000 | Carman |
elmlang | general | An actual value might look like:
```
Named "city hall" (Aged 42 myBuilding)
``` | 2019-02-07T09:31:10.054200 | Carman |
elmlang | general | This approach is very flexible and allows you to do some things with Elm's parametric polymorphism but can be annoying to unwrap, particularly when you're nesting deeply | 2019-02-07T09:31:52.054400 | Carman |
elmlang | general | I find it's most helpful when wrapping some extra context around a value | 2019-02-07T09:32:17.054600 | Carman |
elmlang | general | such as `Maybe User` or `Toggleable User` | 2019-02-07T09:32:42.054800 | Carman |
elmlang | general | You can see some more examples in this discourse thread: <https://discourse.elm-lang.org/t/extension-types/2762/3> | 2019-02-07T09:34:45.055000 | Carman |
elmlang | general | I wrote a bit about approach 3 (derive data) here: <https://thoughtbot.com/blog/gamedev-with-elm-types#composition-vs-inheritance> | 2019-02-07T09:35:27.055200 | Carman |
elmlang | general | <@Dede> 'isolating the update logic' also couples it to the view, the general recommendation is for Msgs to describe events that happened and `update` handles what to do in response to that event. | 2019-02-07T09:49:07.055600 | Earlean |
elmlang | general | Eg. You may want to do something in addition to updating the model in response to input on a field | 2019-02-07T09:50:43.055800 | Earlean |
elmlang | general | In general I think that advice is sound. It’s only in this specific case where “update text to equal text” is such a recurrent pattern that the signal/noise ratio started to feel too low to me. But as you can tell by my putting out the question, I’m not super confident in the call :wink: | 2019-02-07T09:50:46.056000 | Dede |
elmlang | general | And yeah, i see what you mean about potentially wanting to do something more (autocomplete results fetch, etc.) than just update the text field on the model. | 2019-02-07T09:51:18.056200 | Dede |
elmlang | general | Doing `UpdateInput Email "some@email"` allows you to move the 'noise' in to a function and put it in a module and not worry about it much. | 2019-02-07T09:54:09.056400 | Earlean |
elmlang | general | I can't create new channels? I wanted to make a #purescript one for occasional lost souls. | 2019-02-07T09:54:37.056900 | Niesha |
elmlang | general | Fair enough. I think I’m sold. Thank you. | 2019-02-07T09:55:19.057000 | Dede |
elmlang | general | Nope, only <@Deja> can. | 2019-02-07T09:55:21.057200 | Timika |
elmlang | general | Time to wait then. | 2019-02-07T09:56:00.057400 | Niesha |
elmlang | general | ```type alias Point3d = Point2dPlus { z : Int }``` I would create it as `type alias Point3d = Point2dPlus Z` where `type alias Z = Int` | 2019-02-07T10:00:58.057600 | Liza |
elmlang | general | How can a soul who enjoys purescript be lost? :wink: | 2019-02-07T10:09:35.057900 | Antonette |
elmlang | general | They're lost on this slack :smile: | 2019-02-07T10:10:39.058100 | Niesha |
elmlang | general | When you're lost, just follow the `>>=`. | 2019-02-07T10:12:37.058300 | Antonette |
elmlang | general | :stuck_out_tongue_winking_eye: | 2019-02-07T10:12:45.058500 | Antonette |
elmlang | general | <@Niesha> We have a bit of a surplus of channels, at the moment, most of which see no use whatsoever. As a result, we tend to create channels when we notice that a certain topic is beginning to drown out regular conversation in the existing channels | 2019-02-07T10:31:26.058900 | Huong |
elmlang | general | So start talking about purescript more? | 2019-02-07T10:32:24.059100 | Niesha |
elmlang | general | If the goal is to drown out regular conversation, that's unlikely to result in a channel :wink: | 2019-02-07T10:34:12.059500 | Huong |
elmlang | general | But that's the requirement for a new channel, right? | 2019-02-07T10:42:01.059800 | Niesha |
elmlang | general | Or is that more of a "don't overdo it" | 2019-02-07T10:43:44.060000 | Niesha |
elmlang | general | Anyone have thoughts on naming incoming/outgoing ports. I’ve settled on “elmToJs” and “jsToElm” which is descriptive, but not super satisfying.
I’m not a fan of inbound/outbound, because when I’m on the JS side I have to send stuff back through the “inbound,” which causes me some cognitive dissonance. | 2019-02-07T11:11:30.061600 | Cammy |
elmlang | general | <@Cammy> small nit but `toElm` and `toJS` might be better then? `jsToElm` when you are already in JS and know where you are is redundant | 2019-02-07T11:17:52.062700 | Randee |
elmlang | general | That’s a good point. Still feel like we can name better. | 2019-02-07T11:18:16.063000 | Cammy |
elmlang | general | hopefully you wrap the port communication in higher level functions/api and dont have to think about it too much | 2019-02-07T11:20:08.063600 | Randee |
elmlang | general | This is similar to what I do, usually some version of `toFoo` and `fromFoo` I also tend to use separate pairs of ports for independent systems in JS. So I might have `toStorage` and `fromStorage` or `toWebSocket` and `fromWebSocket` | 2019-02-07T11:25:09.064000 | Claretta |
elmlang | general | I name them by what they do | 2019-02-07T11:42:15.064400 | Agustin |
elmlang | general | Yeah, it works. I’m not totally satisfied with t tho. | 2019-02-07T12:07:55.065100 | Cammy |
elmlang | general | Talking about some topic more with the express purpose of artificially drowning out regular conversation just so a channel will be created is definitely not what I'm recommending here. If we notice a bunch of people seem eager to discuss a topic, and we feel like it would be helpful to give them a specific space to discuss, then we're more than happy to give them a space. Good examples of this are <#C0RSQNQ92|graphql> and <#C4F9NBLR1|elm-ui> which have plenty of action.
I don't feel like there is enough discussion about purescript to warrant creating a channel for it and seeing it die within a few weeks. It seems to pop up every now and then, and that seems perfectly fine to me. Last but not least, we do prefer keeping (new) channels on this Slack to be about Elm. That doesn't seem controversial, given that this is the Elm slack. | 2019-02-07T12:11:42.065300 | Huong |
elmlang | general | I do `toJs` and `fromJs` on the Elm side, and then I often compose a `toElm` helper on the JS side. | 2019-02-07T12:22:58.066000 | Ashton |
elmlang | general | ```
function toElm(type, payload) {
app.ports.fromJs.send({
type: type,
payload: payload
})
}
``` | 2019-02-07T12:23:42.066900 | Ashton |
elmlang | general | you could even just do `const toElm = app.ports.fromJs.send` | 2019-02-07T12:45:38.067400 | Danika |
elmlang | general | Yeah but `toElm("hello", null)` is still less typing than `toElm({type: "hello", payload: null})`, altho I guess character count isnt anyone’s priority. | 2019-02-07T15:40:39.069100 | Ashton |
elmlang | general | You can also enforce (as much as js will let you, at least) the structure of the data sending. My example doesn’t do that, you’re right! | 2019-02-07T15:50:18.070400 | Danika |
elmlang | general | How i transform Http.get into Task? (cant finf it in the docs) | 2019-02-07T16:11:22.071600 | Olene |
elmlang | general | You can’t turn a `Cmd` into a `Task`, only the other way around. There is <https://package.elm-lang.org/packages/elm/http/latest/Http#task> to create a `Task` describing a Http request. | 2019-02-07T16:14:37.072900 | Jin |
elmlang | general | <@Olene> You can use `Http.task` | 2019-02-07T16:19:17.073500 | Brady |
elmlang | general | <https://github.com/elm/http/blob/2.0.0/src/Http.elm#L820> | 2019-02-07T16:22:12.075700 | Brady |
elmlang | general | is it normal to do this? (they say that "This should be quite rare.") my goal is to send get data from some API but i need to send couple of requests that are depends one on the one before | 2019-02-07T16:22:34.076000 | Olene |
elmlang | general | Yes that's what it is intended for | 2019-02-07T16:23:08.076500 | Brady |
elmlang | general | If you need to use `Cmd`s (e.g. for process tracking) and also chain requests you have to keep track of the results of each request in you model. | 2019-02-07T16:25:36.078500 | Jin |
elmlang | general | <@Karrie> Did you ever have any luck on this? `Dom.setViewport` works in my situation but I am interested in a solution for the lack of easing( i.e. it’s jumping). | 2019-02-07T16:32:02.080400 | Estela |
elmlang | general | <@Olene> <https://package.elm-lang.org/packages/prikhi/http-tasks/latest/Http-Tasks#get> | 2019-02-07T16:32:54.081400 | Earnest |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.