workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
Hi, has anybody somewhere worked with Processes? I mean, is it possible to apply them as workers for heavy elm functions?
2019-01-14T03:20:23.298500
Victorina
elmlang
general
I’ll check these packages, thanks all for your helps.
2019-01-14T03:22:10.298600
Raymonde
elmlang
general
I think those are still on the main thread (as opposed to a background worker)
2019-01-14T03:25:33.302000
Jake
elmlang
general
Not directly. I guess it's planned for the future. Currently you can make separate Elm programs and wire them up using ports. You will have to do encoding and decoding. To start a headless Elm process use `Platform.worker` as described here: <https://package.elm-lang.org/packages/elm/core/latest/Platform#worker>
2019-01-14T03:42:41.303000
Dorsey
elmlang
general
You will have to manage the threads from JS code.
2019-01-14T03:43:24.303200
Dorsey
elmlang
general
Is anyone else having problems editing Elm code with the latest version of linter in Atom (2.3.0)? Since upgrading today, the linter no longer signals Elm compiler messages. If I downgrade Atom's linter to 2.2.0 (`apm install [email protected]`) things work again. Looking at the release notes of linter ("Remove support for legacy linter APIs"), I wonder if this is a problem with language-elm relying on deprecated APIs
2019-01-14T12:11:04.307100
Tynisha
elmlang
general
Yes, same here. I didn't notice the linter being updated though, but that would probably explain it :+1:
2019-01-14T12:12:17.307200
Elyse
elmlang
general
Suppose I had a function which throws away data, such that I can do `tossA : Foo A -&gt; Foo a` What is the term for converting a type to a type variable (A -&gt; a) ? Is there one? If I want to discuss or or remind a reader that A -&gt; a, how do I state that clearly? “Note that the type parameter whent from … to a type variable?”
2019-01-14T12:38:04.309100
Leoma
elmlang
general
shot in the dark, but maybe you'd call that "unbinding"
2019-01-14T12:42:10.309700
Elina
elmlang
general
Most of the time, such a function forces you to return an "empty state" version of `Foo` (e.g. `List Int -&gt; List a` must return `[]`)
2019-01-14T13:45:05.311500
Carman
elmlang
general
I wonder if describing that behavior might be helpful when trying to explain the type change
2019-01-14T13:46:43.312100
Carman
elmlang
general
You could destructure the record in a function in such a way that the fields become required, but that's not quite the same. doThing : MyRecord -&gt; Result doThing { field1, field2 } = {{function code here}}
2019-01-14T13:52:45.312300
Hyacinth
elmlang
general
Eh, but that's not the same as requiring every field in the record.
2019-01-14T13:53:20.312500
Hyacinth
elmlang
general
Could you use a custom type for the use case that you're trying to do?
2019-01-14T13:54:08.312700
Hyacinth
elmlang
general
Currently in pieces across a number of my tabs.
2019-01-14T17:49:59.313600
Grisel
elmlang
general
I’ll spin up a private Gist and DM you.
2019-01-14T17:50:21.314400
Grisel
elmlang
general
Does elm note allow apostrophies at the end of function names anymore -&gt; `name'` ?
2019-01-14T18:15:23.315200
Danika
elmlang
general
<@Danika> yep, it was removed in 0.18
2019-01-14T18:15:50.315500
Earlean
elmlang
general
Ah okay
2019-01-14T18:17:52.317100
Danika
elmlang
general
`'` is an uncommonly allowed in variable names in most languages that people come to Elm from, it's common use lead people to ask whether there was something special about it which put people off.
2019-01-14T18:18:18.317200
Earlean
elmlang
general
Removing it also encourages people to think of better names
2019-01-14T18:18:39.317700
Earlean
elmlang
general
or replace it with `_` :angel:
2019-01-14T18:19:42.318000
Danika
elmlang
general
well perhaps you could help me with a naming problem then ^^
2019-01-14T18:19:52.318400
Danika
elmlang
general
yep, elm-upgrade did that automatically for the 0.18 upgrade
2019-01-14T18:20:08.318800
Earlean
elmlang
general
but `_` is very commonly allowed in variable names across languages so people don't have the same reaction to it
2019-01-14T18:20:47.319800
Earlean
elmlang
general
I have a type `Param = Note Int | Frequency Float | ...` for midi note and note frequency and some other things. I'd like to have the very standard `mtof` (midi to frequency) and `ftom` functions as utils for a package I'm working on. But it also seems reasonable to have the same functions for generic Int/Float types. Do you think `mtof_` would be fine for the generic function?
2019-01-14T18:23:47.322100
Danika
elmlang
general
Personally I don't like having raw numbers in my programs. I tend to wrap everything in a custom type that represents the unit
2019-01-14T19:05:33.324800
Carman
elmlang
general
So I'd probably have a custom type that looks something like ``` type Frequency = Hertz Float -- OR type Hertz = Hertz Float ```
2019-01-14T19:07:11.325700
Carman
elmlang
general
I usually put these in their own modules, often a with a function to unwrap the raw value although that's not needed as much as you might expect
2019-01-14T19:08:04.326400
Carman
elmlang
general
I don't see much utility in `Frequency (Hertz Float)` compared to `Frequency Float`, the Float is already wrapped why wrap it again?
2019-01-14T19:10:42.327400
Danika
elmlang
general
That first one isn't double wrapping. It just has a different name for the type and the constructor, allowing you to add other units in the same category
2019-01-14T19:12:21.328200
Carman
elmlang
general
e.g. ``` type Frequency = Hertz Float | MegaHertz Float | ... ```
2019-01-14T19:12:40.328900
Carman
elmlang
general
I usually don't do that though
2019-01-14T19:12:52.329300
Carman
elmlang
general
I stick with `type Hertz = Hertz Float`
2019-01-14T19:13:09.329800
Carman
elmlang
general
I understand that, but I already have `Frequency Float` which is part of ```type Params = Value Float | Note Int | Frequency Float | ... ``` So what you propose would be ```type Hertz = Hertz Float type Params = Value Float | Frequency (Hertz Float) | ... ``` no?
2019-01-14T19:15:20.331900
Danika
elmlang
general
In my particular case I think `Frequency Float` already gives enough information that this is in hz (given the context of the rest of the package) and any more specificity doesn't really bring any extra benefit.
2019-01-14T19:16:52.333100
Danika
elmlang
general
What does the `Params` type represent?
2019-01-14T19:19:29.334300
Carman
elmlang
general
are these URL parameters? Inputs from a form?
2019-01-14T19:19:52.334700
Carman
elmlang
general
I think we're probably going way beyond the scope of what I originally asked but.. ```type Node = Node { id : NodeID, type_ : NodeType, params : Dict String Param }``` `Param` represents some parameter of an audio node on a graph.
2019-01-14T19:21:13.335600
Danika
elmlang
general
Do you do any math on param values? Or just output them directly?
2019-01-14T19:24:18.336400
Carman
elmlang
general
There will inevitably be math on param values yes
2019-01-14T19:25:53.336700
Danika
elmlang
general
I assume some operations will only work on frequencies, not on any param type right?
2019-01-14T19:27:26.337600
Carman
elmlang
general
indeed
2019-01-14T19:27:42.337800
Danika
elmlang
general
For those functions, I really like to be able to have signatures like `freqOp : Hertz -&gt; Hertz` rather than `freqOp : Float -&gt; Float`
2019-01-14T19:29:45.339400
Carman
elmlang
general
That is a valid point
2019-01-14T19:31:29.339700
Danika
elmlang
general
Depending on how the program is structured, maybe there's a conversion step somewhere between a `Params` and `Hertz`. Alternatively maybe `Params` wraps a `Hertz` like you showed earlier.
2019-01-14T19:35:16.340800
Carman
elmlang
general
Definitely something to think about. In any case its nearly 1 so I should sleep! Thanks for the input :slightly_smiling_face:
2019-01-14T19:40:42.341400
Danika
elmlang
general
ls
2019-01-14T19:42:35.341500
Ruthann
elmlang
general
bloody slack always takes window focus when it loads :stuck_out_tongue: <@Earlean> several times!
2019-01-14T21:51:33.343600
Ruthann
elmlang
general
It's a classic meme from the IRC days
2019-01-14T21:54:14.343800
Earlean
elmlang
general
I'm trying to figure out elm/parse but I think I'm finding the types a little confusing. I've written up a (hopefully) clear gist with my problem at <https://gist.github.com/bstro/2436e7d3214e4f22544f872a56ad0512> … hoping someone with some experience with `elm/parse` might be able to take a look? It seems like a relatively simple problem to solve overall, I'm just unfamiliar with types in general, let alone parser combinators.
2019-01-14T22:22:15.345600
Santina
elmlang
general
`<http://Parser.int|Parser.int>` will fail on dot. Instead of consuming digits one by one until it faces something else it just fails if complete string cannot be converted to integer
2019-01-15T01:34:47.345900
Lynne
elmlang
general
Strategy here is to use `chompWhile` and then combine chomped characters into a number
2019-01-15T01:35:22.346100
Lynne
elmlang
general
So basically your complete parser has to be built around your `dotDigit`
2019-01-15T01:36:55.346300
Lynne
elmlang
general
Regarding the compilation errors. The first one says you are trying to return parsers which are capable of decoding into different types (from `Parser Int` to `Index` and from `Parser (Int, List Int)` to `Index`). All elements of a list should be of the same type
2019-01-15T02:04:17.346500
Lynne
elmlang
general
Second one says that you are providing wrong value at right hand side of `|.`: it is expecting `Parser ignore` but you are giving it `Parser.andThen &lt;function&gt;`
2019-01-15T02:05:34.346700
Lynne
elmlang
general
You should use `|&gt;` when piping into `andThen`
2019-01-15T02:05:48.346900
Lynne
elmlang
general
<https://ellie-app.com/4stpQV6wb8xa1>
2019-01-15T02:16:32.347100
Lynne
elmlang
general
hmm, `String.toTitleCase` doesn't capitalize åäö :disappointed:
2019-01-15T03:09:32.347900
Nana
elmlang
general
I guess a PR would be in order?
2019-01-15T03:09:58.348300
Nana
elmlang
general
`String.toUpper` works correctly though
2019-01-15T03:10:58.348600
Nana
elmlang
general
<@Nana> As a temp workaround does CSS `text-transform: capitalize;` work for you?
2019-01-15T03:16:12.349400
Hoa
elmlang
general
aha, here's the source: ``` toTitleCase : String -&gt; String toTitleCase ws = let uppercaseMatch = Regex.replace (regexFromString "\\w+") (.match &gt;&gt; toSentenceCase) in ws |&gt; Regex.replace (regexFromString "^([a-z])|\\s+([a-z])") (.match &gt;&gt; uppercaseMatch) ``` `[a-z]` only matches precisely a - z
2019-01-15T03:25:30.351000
Nana
elmlang
general
hmm weird, even replacing it with `(.)` won't capitalize åäö! so there must be another problem as well
2019-01-15T03:54:58.352000
Nana
elmlang
general
\w does not match those, so that needs to change as well.
2019-01-15T03:55:43.352400
Timika
elmlang
general
aah right
2019-01-15T03:56:00.352600
Nana
elmlang
general
ah, finally got it working. didn't quite understand how the original worked so I made this instead: ``` toTitleCase : String -&gt; String toTitleCase = Regex.replace (Regex.fromString "^(.)| (.)" |&gt; Maybe.withDefault Regex.never) (.match &gt;&gt; String.toUpper) ``` seems good enough?
2019-01-15T04:13:13.353600
Nana
elmlang
general
Maybe `\s` instead of just a space? Alternatively, `\S+` to match everything that is not a white space, and transform those chunks, similar to the way it was before?
2019-01-15T04:15:10.354100
Timika
elmlang
general
aha! here's another version then, which more closely follows the behavior of the original, but works for extended alphabet: ``` toTitleCase : String -&gt; String toTitleCase ws = let uppercaseMatch = Regex.replace (Regex.fromString "\\S+" |&gt; Maybe.withDefault Regex.never) (.match &gt;&gt; String.toSentenceCase) in ws |&gt; Regex.replace (Regex.fromString "^([a-zà-ÿ])|\\s+([a-zà-ÿ])" |&gt; Maybe.withDefault Regex.never) (.match &gt;&gt; uppercaseMatch) ```
2019-01-15T04:22:07.355500
Nana
elmlang
general
(I found `[a-zà-ÿ]` was suggested to match all characters when googling)
2019-01-15T04:22:58.356200
Nana
elmlang
general
hmm `[a-zà-ÿ]` doesn't work for Cyrillic though
2019-01-15T04:29:05.356800
Nana
elmlang
general
it's quite a quest to find the correct Regex selector :stuck_out_tongue:
2019-01-15T04:29:47.357800
Nana
elmlang
general
This is super tricky stuff, even though it does not look like it on the surface. I wonder if locales play a role here too. Different languages might capitalize differently, even though it’s the same character.
2019-01-15T04:29:55.358000
Timika
elmlang
general
Would not it be easier to split string by space and then manually capitalize each word with `String.toUpper`?
2019-01-15T04:35:54.359500
Lynne
elmlang
general
Related: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase>
2019-01-15T04:36:13.359900
Timika
elmlang
general
<@Lynne> that's basically what my simpler version does
2019-01-15T04:36:21.360200
Nana
elmlang
general
But you want to harness regular expressions? :slightly_smiling_face:
2019-01-15T04:36:45.360500
Lynne
elmlang
general
&gt; Also notice that conversion is not necessarily a 1:1 character mapping, as some characters might result in two (or even more) characters when transformed to upper-case. Therefore the length of the result string can differ from the input length.
2019-01-15T04:37:07.361000
Timika
elmlang
general
I guess I could have done it with String.split yeah, it was just that the original used Regex :stuck_out_tongue:
2019-01-15T04:37:17.361300
Nana
elmlang
general
I can see the benefit of it... if only it worked
2019-01-15T04:37:39.361600
Lynne
elmlang
general
<@Lynne> this works pretty well: ``` toTitleCase : String -&gt; String toTitleCase = Regex.replace (Regex.fromString "^(.)|\\s(.)" |&gt; Maybe.withDefault Regex.never) (.match &gt;&gt; String.toUpper) ``` It uppercases any character which is after line-start or a space, and should work for all alphabets (depending on how `String.toUpper` works)
2019-01-15T04:39:58.363400
Nana
elmlang
general
I would go mad though if I saw such code in project :smile:
2019-01-15T04:42:37.364800
Lynne
elmlang
general
<@Lynne> yeah regex is weird, how's this then? :slightly_smiling_face: ``` toTitleCase : String -&gt; String toTitleCase phrase = phrase |&gt; String.split " " |&gt; List.map String.toSentenceCase |&gt; String.join " " ``` good enough for PR?
2019-01-15T04:48:06.366000
Nana
elmlang
general
I am not maintainer of `String.Extra`, can't say if it is good or not :slightly_smiling_face:
2019-01-15T04:48:39.366600
Lynne
elmlang
general
or maybe the Regex version is faster
2019-01-15T04:48:42.366700
Nana
elmlang
general
or Regex might be slow, no idea
2019-01-15T04:48:56.366900
Nana
elmlang
general
Well, unless you run on 1k+ lists every other second it should not be a big deal
2019-01-15T04:49:25.367400
Lynne
elmlang
general
Hello folks
2019-01-15T05:34:10.367800
Sadie
elmlang
general
Once again I reach my limitation with Json decoders
2019-01-15T05:34:25.368100
Sadie
elmlang
general
I would like to handle the case where a JSON property can be a nullable or an object or missing
2019-01-15T05:34:46.368600
Sadie
elmlang
general
I started with something like this: ` |&gt; optional "test" (nullable (Decode.map Just decodeTestInfo)) Nothing`
2019-01-15T05:34:58.369000
Sadie
elmlang
general
(elm-json-decode-pipeline)
2019-01-15T05:35:06.369300
Sadie
elmlang
general
Maybe `optional "test" (nullable decodeTestInfo) Nothing` is sufficient in that case?
2019-01-15T05:36:04.369700
Sadie
elmlang
general
I think even `optional "test" (map Just decodeTestInfo) Nothing` should be sufficient
2019-01-15T05:38:53.370200
Lynne
elmlang
general
`optional` already handles null and missing fields
2019-01-15T05:39:06.370600
Lynne
elmlang
general
Unless you want null and missing cases to be represented differently in the model
2019-01-15T05:42:50.371200
Lynne
elmlang
general
Thanks <@Lynne> i am going to try that
2019-01-15T06:19:56.372300
Sadie
elmlang
general
It works
2019-01-15T06:37:55.372500
Sadie
elmlang
general
Damn. Thank you <@Lynne>, that was incredibly helpful and above and beyond what I expected. I really appreciate your help.
2019-01-15T07:34:16.372800
Santina
elmlang
general
You are welcome. Writing parsers is not an easy thing.
2019-01-15T07:47:22.373000
Lynne