workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
But it's a trivial function. It's not something deserving of your time.
2019-03-15T00:03:25.206100
Rosaria
elmlang
general
It doesn't enhance readability particularly.
2019-03-15T00:03:34.206300
Rosaria
elmlang
general
It doesn't add value.
2019-03-15T00:03:38.206500
Rosaria
elmlang
general
It just exists.
2019-03-15T00:03:43.206700
Rosaria
elmlang
general
And detracts from the real problem you're trying to solve.
2019-03-15T00:03:51.207000
Rosaria
elmlang
general
it usefully names the change you're making to `data`
2019-03-15T00:04:36.207600
Earlean
elmlang
general
There's nothing hidden in the syntax I'm proposing. It also usefully displays exactly what is occurring.
2019-03-15T00:05:07.208200
Rosaria
elmlang
general
Without having to have a collection of helper functions in the file / in a separate file relating to that type.
2019-03-15T00:05:26.208900
Rosaria
elmlang
general
Whether or not having a name is useful I think is fairly debatable.
2019-03-15T00:05:44.209500
Rosaria
elmlang
general
it displays what field you're updating, but doesn't explain why
2019-03-15T00:05:49.209800
Earlean
elmlang
general
Because the `=` says quite a lot about what's occurring.
2019-03-15T00:05:53.210000
Rosaria
elmlang
general
I'd say that the setter displays equal amounts of what, but no why at all.
2019-03-15T00:06:32.210900
Rosaria
elmlang
general
Neither explains the reason behind the change
2019-03-15T00:06:40.211100
Rosaria
elmlang
general
Simply that it's occurring.
2019-03-15T00:06:44.211400
Rosaria
elmlang
general
assumably the why of your update to `data` is explained in a function name of a function for `myRecord`
2019-03-15T00:07:27.212400
Earlean
elmlang
general
Let's take an example: `setAge`
2019-03-15T00:07:40.212700
Rosaria
elmlang
general
Just a generic, boring assignment setter.
2019-03-15T00:07:48.212900
Rosaria
elmlang
general
No reasoning
2019-03-15T00:07:50.213100
Rosaria
elmlang
general
No why.
2019-03-15T00:07:53.213300
Rosaria
elmlang
general
It just sets a value to be equal to another.
2019-03-15T00:07:59.213600
Rosaria
elmlang
general
`setAge` isn't a good example, `age` is not a complex data structure
2019-03-15T00:08:15.214000
Earlean
elmlang
general
there isn't any nesting in `age`
2019-03-15T00:08:29.214600
Earlean
elmlang
general
You're right, but that's the setter for the more complex data structure of `user`.
2019-03-15T00:08:32.214800
Rosaria
elmlang
general
```setAge user 5```
2019-03-15T00:08:40.215000
Rosaria
elmlang
general
Remember that this is the other side of the evil for a nested record update.
2019-03-15T00:09:13.215600
Rosaria
elmlang
general
My model contains a user object, it needs its age updated as the user has dictated
2019-03-15T00:09:34.216100
Rosaria
elmlang
general
There's nothing fancy about it
2019-03-15T00:09:38.216400
Rosaria
elmlang
general
Just an integer needs to be set.
2019-03-15T00:09:47.216700
Rosaria
elmlang
general
But this is a real use case.
2019-03-15T00:09:51.216900
Rosaria
elmlang
general
Thanks for the chat <@Earlean>. Nice to bounce ideas around. I'm going to do some other things. Have a good night/day wherever you are :slightly_smiling_face:
2019-03-15T00:14:15.217700
Rosaria
elmlang
general
I acknowledge that {foo.bar | baz = 5 } is kind of confusing in terms of whether it returns modified-foo or modified-bar. I wonder if a new syntax could solve this. Has anyone looked at something like ```{foo | bar | baz = 5}``` ?
2019-03-15T00:23:58.219500
Dede
elmlang
general
I feel like the problem is that imperative programmers have assumptions about what happens if you say `foo.bar.baz = 5` because it just mutated baz in place. New syntax could avoid preconceptions.
2019-03-15T00:25:31.221100
Dede
elmlang
general
was there a problem with ```{data | object = { object | thing = 5 }}``` ? That seems like it could be a reasonable alternative too.
2019-03-15T00:25:36.221200
Nga
elmlang
general
You have weird namespace stuff there, because in current code the first and second usage of `object` refer to different things.
2019-03-15T00:26:26.221800
Dede
elmlang
general
The second one refers to `object` in the containing scope. (So I guess my point is what you wrote has pre-existing semantics that it would be confusing to change.)
2019-03-15T00:27:04.222800
Dede
elmlang
general
Fair enough. I'd love to see Aaron's example or yours, or something like it make its way in. Googling the issue there's no shortage of people trying to work around this.
2019-03-15T00:29:33.224600
Nga
elmlang
general
&gt; That seems like it could be a reasonable alternative too. you also have to declare the second ‘object’ as a variable, either through destructuring it or in a let block. it get verbose quickly when setting records, not so when getting them. `data.object.thing`
2019-03-15T01:17:26.225900
Ruthann
elmlang
general
Hello, is there a method like next for types ? Like if I have type Color = Green | Red | Yellow, and I have Green, the next would be Red
2019-03-15T04:58:45.227300
Rubi
elmlang
general
There is no such method <@Rubi>
2019-03-15T04:59:37.227600
Lynne
elmlang
general
Thank you <@Lynne>, I'll just implement a custom one.
2019-03-15T05:00:42.228600
Rubi
elmlang
general
Hi. I have a design question: I have a type which looks like this...
2019-03-15T05:29:55.229500
Jarod
elmlang
general
now I have a constructor function `fromValue` , which takes a AmountCondition and a String. It then determines if the string should be parsed as a Percent or an Amount.
2019-03-15T05:31:14.230100
Jarod
elmlang
general
So far so good.
2019-03-15T05:31:20.230300
Jarod
elmlang
general
But now I have to pass a `type Currency = EUR | USD` to construct an `Amount`.
2019-03-15T05:32:13.230500
Jarod
elmlang
general
I want to pass the currency to the constructor function `fromValue` _only_ if needed. How can I do that?
2019-03-15T05:33:17.230700
Jarod
elmlang
general
``` type Currency = EUR | USD type Amount = Amount Currency Float amount : Currency -&gt; Float -&gt; Amount amount currency float = Amount currency float amountFromStr : Currency -&gt; String -&gt; Maybe Amount amountFromStr currency string = Maybe.map (amount currency) (String.toFloat string) ```
2019-03-15T05:37:25.231100
Jarod
elmlang
general
``` type Percent = Percent Int percentFromStr : String -&gt; Maybe Percent percentFromStr str = Maybe.map percent (String.toInt str) ```
2019-03-15T05:39:24.231500
Jarod
elmlang
general
so only the `amountFromStr` function needs one extra argument `Currency` but not the `percentFromStr` function.
2019-03-15T05:40:10.231700
Jarod
elmlang
general
Any ideas?
2019-03-15T05:41:11.231900
Jarod
elmlang
general
The trickiness lies in that the `type AmountCondition` can hold one of two types of values: an amount or a percentage.
2019-03-15T05:44:18.232100
Jarod
elmlang
general
we have one function, which can construct a `AmountCondition` which uses the constructors of an amount or an percentage. The constructor for `Amount` needs one additional argument: a currency. But only the main program knows the concrete currency. The `module AmountCondition` is unaware of what particular currency is used at runtime.
2019-03-15T05:48:42.232300
Jarod
elmlang
general
the main program only _uses_ `module AmountCondition`.
2019-03-15T05:49:25.232500
Jarod
elmlang
general
I'm having a bit of a hard time understanding. Could you make a full example on Ellie that portrays the issue you are facing?
2019-03-15T05:59:55.232700
Bert
elmlang
general
I cannot use the Html.input in Elliapp
2019-03-15T06:37:33.233200
Jarod
elmlang
general
do I do something wrong?
2019-03-15T06:37:41.233500
Jarod
elmlang
general
<@Jarod> <https://ellie-app.com/37gW7sj9wPVa1>
2019-03-15T06:44:10.234000
Nana
elmlang
general
What is the problem you are having?
2019-03-15T06:44:13.234100
Leonore
elmlang
general
I removed `Html.Attributes._type "number"` from the List of attributes. Now it works.
2019-03-15T06:51:11.234700
Jarod
elmlang
general
Here you go <https://ellie-app.com/4YNppQkxTrna1>
2019-03-15T06:51:19.234800
Jarod
elmlang
general
<@Bert>
2019-03-15T06:51:24.235000
Jarod
elmlang
general
before there was an error message:
2019-03-15T06:53:31.235600
Jarod
elmlang
general
I reduced the real scenario to the gist
2019-03-15T06:55:40.235900
Jarod
elmlang
general
@lorenz it should be `type_`
2019-03-15T06:56:35.236900
Nana
elmlang
general
`_type` wasent it `type_`?
2019-03-15T06:56:35.237000
Liza
elmlang
general
:slightly_smiling_face:
2019-03-15T06:56:40.237200
Liza
elmlang
general
in elm you cannot start variable with `_`
2019-03-15T06:57:05.237600
Liza
elmlang
general
as i remember..
2019-03-15T06:57:10.237800
Liza
elmlang
general
:scream:
2019-03-15T06:57:30.238100
Jarod
elmlang
general
your right!
2019-03-15T06:57:35.238300
Jarod
elmlang
general
lol
2019-03-15T06:57:43.238500
Jarod
elmlang
general
thanks! :slightly_smiling_face:
2019-03-15T06:58:21.238700
Jarod
elmlang
general
if you have any questions....
2019-03-15T06:59:25.238800
Jarod
elmlang
general
Thanks! So your problem was that you always need a Currency for the `conditionFromValue` function?
2019-03-15T07:08:02.239000
Bert
elmlang
general
yup! I need to pass a Currency to every function that might or might not output something with an `Amount`
2019-03-15T07:12:05.239200
Jarod
elmlang
general
Though this is possible, I search for a more elegant solution. It is a design question I think... Maybe you have an idea?
2019-03-15T07:12:54.239400
Jarod
elmlang
general
Why was `AmountCondition` defined this way? Right now it contains variants which are not mutually exclusive. For example, `GreaterThan` and `IncreasedByPercent` will be true at the same time. It makes me thinking that you could benefit from changing design if the modeling was different.
2019-03-15T07:20:21.239600
Lynne
elmlang
general
Long story short, which problem are you solving by having `AmountCondition`?
2019-03-15T07:20:56.239800
Lynne
elmlang
general
well, this would make a short story actually long. In the real app I have two other `Condition` types like `AmountCondition`. How do you mean "`GreaterThan` and `IncreasedByPercent` will be true at the same time."? They are mutually exclusive...
2019-03-15T07:25:06.240100
Jarod
elmlang
general
If a value is greater than another value by some percent, it is also just greater than that value :slightly_smiling_face:
2019-03-15T07:25:41.240300
Lynne
elmlang
general
Like 3 is 2 increased by 50% and 3 is greater than 2 - both statements are true
2019-03-15T07:26:00.240500
Lynne
elmlang
general
ah! You mean from a purely logical point of view :smile:
2019-03-15T07:26:02.240700
Jarod
elmlang
general
Yep
2019-03-15T07:26:07.240900
Lynne
elmlang
general
yes! You're right!
2019-03-15T07:26:15.241100
Jarod
elmlang
general
But the businesslogic demands this distinction :slightly_smiling_face:
2019-03-15T07:26:29.241300
Jarod
elmlang
general
So is your problem accommodating for some weird API?
2019-03-15T07:27:14.241500
Lynne
elmlang
general
yes :despair:
2019-03-15T07:27:24.241700
Jarod
elmlang
general
._.
2019-03-15T07:27:33.241900
Jarod
elmlang
general
Ok, but then just pass currency always
2019-03-15T07:27:36.242100
Lynne
elmlang
general
It is hard to do something more elegant than that given you are restricted by API
2019-03-15T07:28:07.242300
Lynne
elmlang
general
yep. I think this is the best alternative :disappointed: ugly but explicit and stupid (KISS)
2019-03-15T07:28:10.242500
Jarod
elmlang
general
Well, that's life
2019-03-15T07:28:20.242700
Lynne
elmlang
general
Nothing is perfect
2019-03-15T07:28:22.242900
Lynne
elmlang
general
you know? Programming would be such a bliss without that darn user!
2019-03-15T07:28:45.243100
Jarod
elmlang
general
:smile:
2019-03-15T07:28:47.243300
Jarod
elmlang
general
For sure
2019-03-15T07:28:53.243500
Lynne
elmlang
general
Also useless but who cares :smile:
2019-03-15T07:29:02.243700
Lynne
elmlang
general
yep!
2019-03-15T07:29:10.243900
Jarod
elmlang
general
userless = useless
2019-03-15T07:29:21.244100
Jarod
elmlang
general
:))
2019-03-15T07:29:25.244300
Jarod
elmlang
general
:+1:
2019-03-15T07:29:33.244500
Lynne