workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | You'll need to globally install elm 0.19 | 2019-03-13T09:20:37.931300 | Huong |
elmlang | general | in order for your build script to refer to `elm` without any path indication | 2019-03-13T09:20:56.931800 | Huong |
elmlang | general | `npx` tries to find a binary in your node_modules first, which is why this trick works. Without `npx`, it needs to be on your path, so easiest solution is to install it globally :slightly_smiling_face: | 2019-03-13T09:21:46.933000 | Huong |
elmlang | general | <@Huong> Thanks, would you use npm? | 2019-03-13T09:22:56.933500 | Donnetta |
elmlang | general | May as well if you already have it installed | 2019-03-13T09:23:22.934000 | Danika |
elmlang | general | Depends on how you and your team, and CI services prefer to work | 2019-03-13T09:23:23.934100 | Huong |
elmlang | general | I see, thanks <@Danika> <@Huong> | 2019-03-13T09:25:15.934700 | Donnetta |
elmlang | general | <@Danika>, do you know if `npm install -g elm` should work to upgrade or is there another command? | 2019-03-13T09:29:17.935400 | Donnetta |
elmlang | general | that'll work | 2019-03-13T09:30:00.935600 | Danika |
elmlang | general | Thanks <@Danika> | 2019-03-13T09:30:20.936000 | Donnetta |
elmlang | general | I have one last issue with the new datepicker <https://package.elm-lang.org/packages/CurrySoftware/elm-datepicker/latest/>. If I enter a date from the datePicker, it works fine. However, if I want to remove the date, I can't. Here is the code to update the datePicker ``` let
(( newDatePicker, mDate )) =
DatePicker.update defaultSettings datePickerMsg model.datePicker
date =
case mDate of
DatePicker.Picked changedDate ->
Just changedDate
_ ->
model.date
newOrg =
updateOrganization model.organization (ChgContractDate (formatMaybeDate date))
in
( { model | date = date, datePicker = newDatePicker, organization = newOrg }, Cmd.none )``` | 2019-03-13T10:10:20.938300 | Donnetta |
elmlang | general | I don't know how to do it so that if the people remove the date from the input, then the date should be nothing. Since the input code is in the library. With the old datepicker, it worked | 2019-03-13T10:11:40.939800 | Donnetta |
elmlang | general | To be cleared, the issue is about saving, I can remove the date saved previously manually and hit save, but when I reload the page, it is still there | 2019-03-13T10:13:24.940800 | Donnetta |
elmlang | general | also with the elm-community datepicker, I could change the date in the input and save, then the date would be preserved | 2019-03-13T10:15:42.941700 | Donnetta |
elmlang | general | is my only solution to copy the repo and change it? | 2019-03-13T10:17:54.942100 | Donnetta |
elmlang | general | Should not you provide `Nothing` to `DatePicker.initFromDates` as second argument when there is no date? | 2019-03-13T10:28:46.942500 | Lynne |
elmlang | general | I have a problem with domain modeling and "Polymorphism": the `LessThan` from the `type NatNumCondition` shadows the `LessThan` from the `type PercentCondition` and the `type AmountCondition`. What can I do? The label's names are accurate from the business perspective but should hold different types of values (NatNum, Percent and Amount). Whereas `IncreasedByPercent` should hold only `Percent` in all three distinct types. | 2019-03-13T10:37:01.944500 | Daysi |
elmlang | general | help would be appreciated. | 2019-03-13T10:37:11.945000 | Daysi |
elmlang | general | <@Lynne> The problem is that if I put noting instead of model.date, every time the user click on the input field and doesn't pick a date, it will become nothing | 2019-03-13T10:37:11.945100 | Donnetta |
elmlang | general | Ok, there is apparently more to know about this library. :slightly_smiling_face: Sorry, I don't have experience with this package and can't be helpful here. | 2019-03-13T10:41:39.946300 | Lynne |
elmlang | general | Thanks for trying | 2019-03-13T10:42:02.946900 | Donnetta |
elmlang | general | <@Daysi> You can add some prefixes or suffixes like `NatNumLessThan` or maybe refactor into something like this:
```
type BaseCondition a
= LessThan a
| GreaterThan a
| Equals a
| IncreasePercent Percent
| DecreasePercent Percent
type NatNumCondition = NatNumCondition (BaseCondition NatNum)
-- or
type alias NatNumCondition = BaseCondition NatNum
type AmountCondition
= AmountBaseCondition (BaseCondition Amount)
| IncreasedByAmount Amount
| DecreasedByAmount Amount
``` | 2019-03-13T10:43:12.948200 | Earnest |
elmlang | general | Or put them in different modules & only use them with qualifiers
```
case nnCond of NatNum.LessThan -> ...
``` | 2019-03-13T10:45:35.949500 | Earnest |
elmlang | general | yeah, I already refactored it in a similar manner (good idea btw!) but access to the condition's payload becomes unclear then: take e.g. the `AmountCondition`: you'd have to do a nested pattern match to find out is it either a `AmountBaseCondition` or `IncreasedByAmount` or `DecreasedByAmount`. | 2019-03-13T10:46:45.949600 | Daysi |
elmlang | general | could you explain? | 2019-03-13T10:47:28.949800 | Daysi |
elmlang | general | You can un-nest in a single case:
```
case cond of
AmountBaseCondition (LessThan amt) -> ...
IncreasedByAmount amt -> ...
``` | 2019-03-13T10:47:43.950000 | Earnest |
elmlang | general | but could you, since BaseCondition can be multiple things... | 2019-03-13T10:48:23.950200 | Daysi |
elmlang | general | you'd have to
```
case cond of
AmountBaseCondition (LessThan amt) -> ...
AmountBaseCondition (GreaterThan amt) -> ...
...
IncreasedByAmount amt -> ...
``` | 2019-03-13T10:49:06.950400 | Daysi |
elmlang | general | no? | 2019-03-13T10:49:13.950600 | Daysi |
elmlang | general | ```
module NatNum exposing (..)
type NatNumCondition
= LessThan NatNum
| ...
```
```
module SomewhereElse exposing (..)
import NatNum exposing (NatNum, NatNumCondition)
someFunc : NatNumCondition -> SomethingElse
someFunc c = case c of
NatNum.LessThan nn -> ...
``` | 2019-03-13T10:49:41.950800 | Earnest |
elmlang | general | yup | 2019-03-13T10:50:19.951000 | Earnest |
elmlang | general | You'll have the same number of case branches either way | 2019-03-13T10:50:33.951200 | Earnest |
elmlang | general | ahh. Hmm. :thinking_face: | 2019-03-13T10:50:42.951400 | Daysi |
elmlang | general | but all BaseConditions with the "AmountBaseCondition" thing infront... | 2019-03-13T10:51:22.951600 | Daysi |
elmlang | general | Then you can also have `Amount.LessThan amt -> ...` in the same module without conflicts | 2019-03-13T10:51:29.951800 | Earnest |
elmlang | general | Yup | 2019-03-13T10:51:41.952000 | Earnest |
elmlang | general | I guess there's no other way to do this in Elm... | 2019-03-13T10:52:06.952200 | Daysi |
elmlang | general | hmmmm | 2019-03-13T10:52:23.952400 | Daysi |
elmlang | general | I'm conflicted. Creating one entire module just for one type you need on one page of your app? :thinking_face: | 2019-03-13T10:53:22.952600 | Daysi |
elmlang | general | Well you could just have `NNLessThan` & `PCLessThan` or whatever | 2019-03-13T10:53:47.952800 | Earnest |
elmlang | general | just doesn't read as nicely | 2019-03-13T10:53:55.953000 | Earnest |
elmlang | general | that feels so weird. Maybe I'm too prejudiced from other languages and from a misunderstanding of "The life of a file" video? | 2019-03-13T10:54:16.953200 | Daysi |
elmlang | general | (aka: be lazy when deciding to create modules) | 2019-03-13T10:54:57.953400 | Daysi |
elmlang | general | :thinking_strongly: | 2019-03-13T10:55:33.953800 | Daysi |
elmlang | general | Yeah I probably wouldn't make a new module if that's the only thing that'll be in it, especially if it's only going to be used in one moudle | 2019-03-13T10:55:40.953900 | Earnest |
elmlang | general | but this would solve the naming issue ... | 2019-03-13T10:56:16.954100 | Daysi |
elmlang | general | I'd go with BaseCondition if you think you'll be writing a function like `BaseCondition a -> whatever`. Because otherwise you'd have to make 3 functions to do that for all three condition types. | 2019-03-13T10:57:35.954300 | Earnest |
elmlang | general | Otherwise I'd probably just go with some prefixes. | 2019-03-13T10:58:13.954500 | Earnest |
elmlang | general | to be typesafe, I don't wanna write `a` | 2019-03-13T10:58:58.954700 | Daysi |
elmlang | general | so I have to make three functions anyways... | 2019-03-13T10:59:12.954900 | Daysi |
elmlang | general | well, you could argue that, if it's a `BaseCondition` it's already clear that it's in this module and only holds types `NatNum`, `Percent` and `Amount` | 2019-03-13T11:00:25.955100 | Daysi |
elmlang | general | hmmmm but `a` seems so generic... I am really hesitant. | 2019-03-13T11:00:53.955300 | Daysi |
elmlang | general | The generic-ness of `a` limits the scope of what you can do with it as well | 2019-03-13T11:01:45.955500 | Earnest |
elmlang | general | so I can constuct a `BaseCondition String`. But I don't want to allow it :confused: | 2019-03-13T11:03:08.955800 | Daysi |
elmlang | general | I think using different modules is the only choice I have that is somewhat consistent :disappointed: | 2019-03-13T11:12:50.956200 | Daysi |
elmlang | general | modeling domain logic in Elm is really ugly, verbose and unelegant sadly if it's more than a ToDo app. I am disappointed. I really like the elegance of the language for simpler tasks though... | 2019-03-13T11:14:18.957200 | Daysi |
elmlang | general | <@Daysi> as opposed to Haskell or something? | 2019-03-13T11:19:03.957600 | Nana |
elmlang | general | maybe... I lately read about ad-hoc polymorphism with type-classes :thinking_face: | 2019-03-13T11:19:28.958100 | Daysi |
elmlang | general | Haskell has it | 2019-03-13T11:19:42.958300 | Daysi |
elmlang | general | this could be a use case for that! | 2019-03-13T11:20:06.958700 | Daysi |
elmlang | general | @translate | 2019-03-13T11:22:32.959100 | Latina |
elmlang | general | This article is a bit old, but worth a read | 2019-03-13T11:24:54.960700 | Danika |
elmlang | general | <https://medium.com/@eeue56/why-type-classes-arent-important-in-elm-yet-dd55be125c81> | 2019-03-13T11:24:54.960900 | Danika |
elmlang | general | > modeling domain logic in Elm is really ugly, verbose and unelegant sadly if it’s more than a ToDo app.
I would disagree here. I would even say that domain modelling is one of Elm’s strengths. I agree that Elm is no silver bullet for everything, but frankly - what technology is? Saying Elm is `really ugly, verbose and unelegant` in every case that is more than a todo-app does not cross me as a fair assessment - even if it might be true for some cases. | 2019-03-13T11:26:24.962400 | Timika |
elmlang | general | <@Latina> as far as I understood it, type-classes enable you to define a method with the same name which does the same thing for different types. It is as if you had a utility-class in Java with only static methods which you overload for each type you want. Like for example `equals` for types String, Int, Cat, Dog ... So the program uses the correct function on runtime but gives you compile time errors if you pass e.g. `Horse` to the `equals` function because you haven't defined it yet for the `type Horse`.
Correct @ anybody? | 2019-03-13T11:30:12.967400 | Daysi |
elmlang | general | That is roughly correct. :slightly_smiling_face: | 2019-03-13T11:31:59.968400 | Timika |
elmlang | general | <https://en.wikipedia.org/wiki/Ad_hoc_polymorphism> describes the general concept very well IMO. | 2019-03-13T11:33:05.970200 | Timika |
elmlang | general | <@Timika> well, I can tell you I thought like 5 days how to solve my problem which is: you have different criteria which have _specific_ dependant conditions, which in turn have _specific_ dependent Values (NatNum, Amount, Percent or Status). I didn't find one satisfying solution. I tried around 10. | 2019-03-13T11:33:08.970500 | Daysi |
elmlang | general | Maybe I don't know a trick for _dependent_ types in Elm... | 2019-03-13T11:34:22.971600 | Daysi |
elmlang | general | Type classes are Java interfaces, give or take, more than classes | 2019-03-13T11:34:57.971800 | Kris |
elmlang | general | Ah nice :smile: well, it's a start... | 2019-03-13T11:34:57.972000 | Daysi |
elmlang | general | yea, but <@Latina> think not in _instances_ since there are no instances in functional programming. Really think of static methods rather... | 2019-03-13T11:36:20.972500 | Daysi |
elmlang | general | I’m not dismissing the fact that there might not be a solution for your problem that satisfies you. :slightly_smiling_face: I’m just saying that the broad assessment that modelling domain logic in Elm is ugly verbose and inelegant in _every_ case. Nothing more nothing less. :slightly_smiling_face: | 2019-03-13T11:36:27.972800 | Timika |
elmlang | general | It is not. For ToDo apps :stuck_out_tongue_winking_eye: | 2019-03-13T11:37:07.973800 | Daysi |
elmlang | general | Elm doesn't have dependent types. Some things can't be proven by the compiler. The solution is usually to create a opaque type whose only constructor runs validations and returns a `Result`, and then fuzz-test it. While this is a run-time check, the compiler can help give you confidence that all values have been validated. | 2019-03-13T11:38:28.975200 | Carman |
elmlang | general | FWIW, any language that has Algebraic Data Types (e.g. Elm's custom types) is automatically in the "modeling things elegantly" club IMO :heart: . Add in the Haskell/Elm syntax to keep it terse (as opposed to Scala's ultra-verbose syntax) and it makes modeling super fun! :grinning_face_with_star_eyes: | 2019-03-13T11:39:00.976200 | Carman |
elmlang | general | well <@Carman> for smaller, less complex domain logic I agree. | 2019-03-13T11:39:59.977800 | Daysi |
elmlang | general | But in my company we are using it for a really complex software and it is exactly perceived as I wrote: ugly, verbose and unelegant. But ofc the compiler errors and the testing tools are really nice! | 2019-03-13T11:41:01.979800 | Daysi |
elmlang | general | <@Daysi> what language do you think has a better type system then? | 2019-03-13T11:41:50.981100 | Nana |
elmlang | general | I don't know if there are any languages that offer dependent types on the front-end. They are kind of extreme for a type system :thinking_face: | 2019-03-13T11:42:00.981400 | Carman |
elmlang | general | PS does get near though | 2019-03-13T11:42:15.982100 | Kris |
elmlang | general | Although with all the ugly hacks of haskell | 2019-03-13T11:42:21.982400 | Kris |
elmlang | general | I really WISH I could say better things. That's why I asked above if anyone has an elegant solution for my problem. Because I really like a lot about the language. | 2019-03-13T11:42:24.982500 | Daysi |
elmlang | general | maybe I am just not educated enough and miss a thing... | 2019-03-13T11:43:02.983900 | Daysi |
elmlang | general | Honestly, we don't know enough about the domain and specific issues you're facing. Personally, depending on the domain, I think it might make sense to group conditions by how the function, and say which condition types can have what kind of conditions in them. | 2019-03-13T11:43:24.984600 | Huong |
elmlang | general | Something like ```type NatNumCondition
= NatNumCompare (ComparativeCondition NatNum)
| NatNumPercentChange PercentChange
type PercentCondition
= PercentCompate (ComparativeCondition Percent)
| PercentChange PercentChange
type AmountCondition
= AmountCompare (ComparativeCondition Amount)
| AmountPercentChange PercentChange
| IncreasedByAmount Amount
| DecreasedByAmount Amount
type PercentChange
= IncreasedByPercent Percent
| DecreasedByPercent Percent
type ComparativeCondition a
= LessThan a
| Equals a
| LessThan a``` for example. | 2019-03-13T11:43:43.985000 | Huong |
elmlang | general | that was one of my approaches, yes | 2019-03-13T11:44:12.985700 | Daysi |
elmlang | general | Them again, that may be painful to work with, but that really depends on your domain, what you need to model, and perhaps more importantly, what you wish to do with it | 2019-03-13T11:44:32.986100 | Huong |
elmlang | general | I used to be able to modify libraries I added through packages. Is it something that cannot be done anymore in 0.19? I am looking for DatePicker.elm since I have the package CurrySoftware/datepicker imported, but don't seem to be able to access it. | 2019-03-13T11:45:34.987300 | Donnetta |
elmlang | general | I just wish I could model the domain without thinking about name spaces/shadowing, modules and all the stuffs. Just pure domain logic. But in this case, this seems to be impossible... | 2019-03-13T11:46:09.988600 | Daysi |
elmlang | general | You can still put the code in a folder and add that folder to the source-directories :slightly_smiling_face: | 2019-03-13T11:46:21.988900 | Huong |
elmlang | general | let's continue in a thread | 2019-03-13T11:46:39.989600 | Huong |
elmlang | general | *pulls out sad violin in order to play on it* | 2019-03-13T11:46:41.989800 | Daysi |
elmlang | general | Does anybody know how to avoid losing my `id` of the div with Elm app?
I am using `Browser.element`, creating `<div id="root"></div>` in `index.html` and initializing Elm app in it. But after it is initialized, I always lose `id="root"` from that element which I need to use later. | 2019-03-13T11:49:39.991400 | Nickole |
elmlang | general | add it to the root element of your view function? | 2019-03-13T11:51:15.992600 | Danika |
elmlang | general | <@Nickole> I think you just need to add `Html.Attributes.id "root"` in Elm | 2019-03-13T11:51:15.992700 | Nana |
elmlang | general | <@Nana> But it will add it just to the child element and I need to keep it for the whole `div` where Elm app runs :thinking_face: | 2019-03-13T11:52:47.993800 | Nickole |
elmlang | general | So, I think disambiguating between the different constructors you need to accurately represent your domain logic in terms of custom types, is something you can't really get around.. _generally_. It's honestly quite amazing what you _can_ encode in the type system, but it's not always clear how to best go about that, exactly. This really does depend on what you want to _do_ with stuff!
Examples of stuff you can do with types:
- elm-css has some pretty amazing things that make it so `display none` is valid but `fontSize none` is not
- <https://gist.github.com/zwilias/ccd72ee7925b27e8c41176ebe7d33564> a balanced binary tree- you cannot construct a binary tree using those types that is NOT properly balanced
- <https://github.com/zwilias/tic-tac-toe> a game of tic tac toe where the type system guarantees quite a few semantics of the game
That said, it is not always a great idea to encode all of the semantics in your domain into the types - very often, what you need is a module whose interface encodes those semantics, while the types themselves allow some more leeway. An example of this is a `type PositiveInt = Positive Int` - as long as their is a constructor `fromInt : Int -> Maybe PositiveInt` and the actual constructor isn't exposed, you _can_ make a whole bunch of guarantees already! | 2019-03-13T11:54:15.994800 | Huong |
elmlang | general | <@Danika> Yes, but as I mentioned above, I want to keep it on a higher level. That’s probably not possible anymore | 2019-03-13T11:54:21.995000 | Nickole |
elmlang | general | Indeed, it seems odd that the div loses its id in the first place | 2019-03-13T11:54:55.996000 | Danika |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.