workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang
|
general
|
yeah true
|
2019-01-29T04:18:58.198900
|
Nana
|
elmlang
|
general
|
I dream of an Elm with Lisp-like powers, where you can evaluate Elm expressions within a running Elm program.
|
2019-01-29T04:19:07.199100
|
Dorsey
|
elmlang
|
general
|
Ah, the source code is here: <https://github.com/girishso/elm-repl-in-browser>
|
2019-01-29T04:22:20.199400
|
Dorsey
|
elmlang
|
general
|
As I thought, it's connecting to REPL running in a container. Not ideal, but I guess good enough.
|
2019-01-29T04:23:05.199600
|
Dorsey
|
elmlang
|
general
|
Ellie also compiles server-side. The 0.19 compiler does tricks for efficiency which GHCJS can't handle.
|
2019-01-29T04:47:14.199900
|
Huong
|
elmlang
|
general
|
Oh, I see. Thanks.
|
2019-01-29T04:47:35.200100
|
Dorsey
|
elmlang
|
general
|
does anyone have a glue why the linear-algebra package does provide `add`, `sub` for vectors, but not `div` and `mul`? Am I missing something here?
|
2019-01-29T04:50:23.201800
|
Earnestine
|
elmlang
|
general
|
There is a reason why there is no vector division: <https://physics.stackexchange.com/questions/111652/can-we-divide-two-vectors>
|
2019-01-29T04:52:16.201900
|
Antonette
|
elmlang
|
general
|
As for the products, all the products you need are there.
|
2019-01-29T04:52:31.202200
|
Antonette
|
elmlang
|
general
|
<https://package.elm-lang.org/packages/elm-explorations/linear-algebra/latest/Math-Vector2#scale>
|
2019-01-29T04:52:59.202400
|
Antonette
|
elmlang
|
general
|
(product with a scalar ; if you want to divide by said scalar, you can scale by a fraction)
|
2019-01-29T04:54:05.202600
|
Antonette
|
elmlang
|
general
|
<https://package.elm-lang.org/packages/elm-explorations/linear-algebra/latest/Math-Vector2#dot>
|
2019-01-29T04:54:14.202800
|
Antonette
|
elmlang
|
general
|
:point_up_2: And if you want to multiply two vectors between one another, there's the dot product.
|
2019-01-29T04:56:01.203000
|
Antonette
|
elmlang
|
general
|
:slightly_smiling_face:
|
2019-01-29T04:56:03.203200
|
Antonette
|
elmlang
|
general
|
(does it answer your question?)
|
2019-01-29T04:56:56.203400
|
Antonette
|
elmlang
|
general
|
wait... I'll respond in a sec
|
2019-01-29T05:00:30.203600
|
Earnestine
|
elmlang
|
general
|
related: <https://github.com/elm/projects#in-browser-repl>
|
2019-01-29T05:02:21.203800
|
Velia
|
elmlang
|
general
|
:slightly_smiling_face:
|
2019-01-29T05:03:17.204000
|
Antonette
|
elmlang
|
general
|
Nice link. Thanks.
|
2019-01-29T05:04:02.204200
|
Dorsey
|
elmlang
|
general
|
Ok, I see. I already assumed there's a reason. But in practice, how would you do this:
```
mousePos : Vec2
resolution : Vec2
normalizedMousePos : Vec2
normalizedMousePos = ?
```
of course, I can write a helper:
```
v2div : Vec2 -> Vec2 -> Vec2
v2div v1 v2 =
vec2 (V2.getX v1 / V2.getX v2) (V2.getY v1 / V2.getY v2)
```
and then say:
```
normalizedMousePos = v2div mousePos resoltution
```
but maybe there's a better way..
|
2019-01-29T05:07:46.204400
|
Earnestine
|
elmlang
|
general
|
Well, there is :slightly_smiling_face:
|
2019-01-29T05:17:54.204800
|
Antonette
|
elmlang
|
general
|
cool, looking forward to hear...
|
2019-01-29T05:18:34.205000
|
Earnestine
|
elmlang
|
general
|
(or maybe not ; I'm not sure ; just a sec)
|
2019-01-29T05:18:55.205200
|
Antonette
|
elmlang
|
general
|
Maybe I wouldn't use `normalize` in the name ; `normalize` already exists and consists in turning a vector of arbitrary length into a unit vector (length == 1) without changing its angle.
|
2019-01-29T05:20:08.205400
|
Antonette
|
elmlang
|
general
|
Except for that, your v2div function is fine if that's what you want to achieve (i.e. having a vector representing the coordinates of the mouse relative to the screen width and height).
|
2019-01-29T05:21:20.205600
|
Antonette
|
elmlang
|
general
|
I'm a little curious as to what you're trying to achieve with this, but if it makes sense in your situation, go for it :slightly_smiling_face:
|
2019-01-29T05:22:01.205900
|
Antonette
|
elmlang
|
general
|
(and since there's no pre-built way to do this in the package, so there's no better way than your way as far as I know)
|
2019-01-29T05:24:02.206100
|
Antonette
|
elmlang
|
general
|
Hello
|
2019-01-29T05:24:21.206400
|
Sadie
|
elmlang
|
general
|
I am trying to port kallaspriit/elm-basic-auth to Elm 0.19
|
2019-01-29T05:24:35.206700
|
Sadie
|
elmlang
|
general
|
It is working up to the elm-test part <https://github.com/kallaspriit/elm-basic-auth/pull/2>
|
2019-01-29T05:24:47.207100
|
Sadie
|
elmlang
|
general
|
As for the naming, maybe `relativeMousePos` would make more sense.
|
2019-01-29T05:25:02.207200
|
Antonette
|
elmlang
|
general
|
When I run it I get:
```
elm-basic-auth$ elm-test
elm-test internal error: got an unexpected result from 'elm make' when validating transitive dependencies. Please report this at <https://github.com/rtfeldman/node-test-runner/issues>
```
|
2019-01-29T05:25:11.207600
|
Sadie
|
elmlang
|
general
|
If I try to run elm-make on the file I get
```
$ elm make tests/Tests.elm
-- UNKNOWN IMPORT ---------------------------------------------- tests/Tests.elm
The Tests module has a bad import:
import Test
I cannot find that module! Is there a typo in the module name?
When creating a package, all modules must live in the src/ directory.
```
|
2019-01-29T05:25:41.208000
|
Sadie
|
elmlang
|
general
|
I tried:
```
$ elm install elm-explorations/test
I found it in your elm.json file, but in the "test-dependencies" field.
Should I move it into "dependencies" for more general use? [Y/n]:
Dependencies loaded from local cache.
Dependencies ready!
rhubscher@NATIM-ThinkPad-T470s:~/elm/elm-basic-auth$ elm make tests/Tests.elm
Dependencies loaded from local cache.
Dependencies ready!
Success! Compiled 2 modules.
```
|
2019-01-29T05:26:16.208300
|
Sadie
|
elmlang
|
general
|
So I am a bit lost
|
2019-01-29T05:26:22.208600
|
Sadie
|
elmlang
|
general
|
any idea ?
|
2019-01-29T05:26:24.208800
|
Sadie
|
elmlang
|
general
|
you don't `make` your tests, you need the `elm-test` npm package.
|
2019-01-29T05:50:40.209300
|
Danika
|
elmlang
|
general
|
<https://www.npmjs.com/package/elm-test>
|
2019-01-29T05:51:09.209400
|
Danika
|
elmlang
|
general
|
This makes me think there's something funky with the elm.json or elm-stuff
|
2019-01-29T06:09:01.209800
|
Bert
|
elmlang
|
general
|
Did you try removing elm-stuff and re-running elm-test?
|
2019-01-29T06:09:29.210000
|
Bert
|
elmlang
|
general
|
That is what they are running (see the first code block)
|
2019-01-29T06:10:45.210200
|
Bert
|
elmlang
|
general
|
Oh yeah, oops!
|
2019-01-29T06:25:08.210400
|
Danika
|
elmlang
|
general
|
mhhh... this is a bit unconvenient... From other languages I'm used to have this functions.. Having a `map` function would not be bad as well... Maybe a `linear-algebra-extra` package would make sense (?)
|
2019-01-29T06:29:07.210700
|
Earnestine
|
elmlang
|
general
|
Sure :slightly_smiling_face: you can even propose it if you like (and don't find it already existing of course).
|
2019-01-29T06:30:15.210900
|
Antonette
|
elmlang
|
general
|
Also, it's possible to suggest a contribution to the existing package (through a pull request for example, maybe with an issue to start the conversation less abruptly).
|
2019-01-29T06:31:20.211100
|
Antonette
|
elmlang
|
general
|
But before that, there's nothing wrong with creating these functions in the scope of your project (they'll even give you the basic code if you want to send a PR or something).
|
2019-01-29T06:32:00.211300
|
Antonette
|
elmlang
|
general
|
jepp, also possible...
|
2019-01-29T06:32:08.211500
|
Earnestine
|
elmlang
|
general
|
or is there maybe a way to archive the thing by using the Matrix module from the package?
|
2019-01-29T06:32:43.211700
|
Earnestine
|
elmlang
|
general
|
I would start there if I were you, if only to get familiar with it.
|
2019-01-29T06:33:32.211900
|
Antonette
|
elmlang
|
general
|
Hi, I am using this package <https://package.elm-lang.org/packages/elm/browser/latest/Browser-Events> to grab onMouseMove events
|
2019-01-29T06:57:44.213300
|
Cameron
|
elmlang
|
general
|
but I would like to get position information and there is no documentation in the module's documentation on how is it possible to get position information out of the onMouseMoveEvent for example
|
2019-01-29T06:58:56.214600
|
Cameron
|
elmlang
|
general
|
anybody got any idea ?
|
2019-01-29T06:59:00.214800
|
Cameron
|
elmlang
|
general
|
<@Cameron> the idea of that API is that you provide a `Json.Decode.Decoder` that can grab the values you're interested in from the event object.
|
2019-01-29T07:00:36.216500
|
Earlean
|
elmlang
|
general
|
<https://developer.mozilla.org/en-US/docs/Web/Events/mousemove> is the documentation for the DOM mousemove event
|
2019-01-29T07:01:29.217800
|
Earlean
|
elmlang
|
general
|
<@Earlean> thanks for your response but it's wird because to decode the values I need to now how the Java script event object looks like
|
2019-01-29T07:01:36.218100
|
Cameron
|
elmlang
|
general
|
Oh now I get it
|
2019-01-29T07:02:20.218700
|
Cameron
|
elmlang
|
general
|
<@Cameron> easiest is to just type `addEventListener("click", console.log)` in the console :wink:
|
2019-01-29T07:07:11.220100
|
Nana
|
elmlang
|
general
|
then you can just click on stuff and inspect the event object
|
2019-01-29T07:07:39.220500
|
Nana
|
elmlang
|
general
|
<@Nana> I think I am going to start with this aproach to get a better feeling thanks really apriciate your help
|
2019-01-29T07:08:50.221600
|
Cameron
|
elmlang
|
general
|
How often do you all pick apart the `(model, cmd)` return pair once constructed?
|
2019-01-29T08:20:40.226400
|
Saran
|
elmlang
|
general
|
Seldom
|
2019-01-29T08:21:21.226600
|
Lynne
|
elmlang
|
general
|
Hey Folks! What's your go-to style for conditionally append items to a list?
something like
```
case (a. b) of
(False, False) -> [ a, b, c ]
(False, True) -> [ a, b, c, y ]
(True, False) -> [ a, b, c, y ]
(True, True) -> [ a, b, c, x, y]
```
I usually if/case with the different lists, but that may lead to a lot of duplication for the common static element of the lists;
I saw people having a list of `(Boolean, A)` or `Maybe A` and then call `List.filter`. What do you use? :slightly_smiling_face:
|
2019-01-29T11:40:43.237400
|
Lilli
|
elmlang
|
general
|
I'd go for list of maybes
|
2019-01-29T11:41:29.237800
|
Kris
|
elmlang
|
general
|
Hey <@Lilli> :slightly_smiling_face: I usually go for the `List (Maybe a)` (usually more readable imo) ; you may want to use `Maybe.Extra.values : List (Maybe a) -> List a` that does pretty much what you would expect from its type signature.
|
2019-01-29T11:46:26.239600
|
Antonette
|
elmlang
|
general
|
<https://package.elm-lang.org/packages/elm-community/maybe-extra/latest/Maybe-Extra#values>
|
2019-01-29T11:48:44.241200
|
Antonette
|
elmlang
|
general
|
<@Antonette> yea, i don't use it much because when you have a lot of common items you just end with too many "Just", in my example `[a, b, c]` are always there. But there are cases where it's super convenient and easy to read aswell
|
2019-01-29T11:49:28.241700
|
Lilli
|
elmlang
|
general
|
The way I do it to avoid clutter is like:
```
[ somethingAlwaysThere |> Just
, somethingAlsoAlwaysThere |> Just
, somethingOptional
]
```
|
2019-01-29T11:50:53.243100
|
Antonette
|
elmlang
|
general
|
<@Lilli> wow I don't understand what that's supposed to do at all :sweat_smile:
|
2019-01-29T11:51:02.243300
|
Nana
|
elmlang
|
general
|
that alone won't do anything :smile: it's just a matter of coding style
|
2019-01-29T11:52:08.243400
|
Lilli
|
elmlang
|
general
|
that's cute actually :smile:
|
2019-01-29T11:52:35.243600
|
Lilli
|
elmlang
|
general
|
ah I think I get it now, so would you do like that if you wanted do conditionally show an element, or conditionally add a style?
|
2019-01-29T11:54:42.243800
|
Nana
|
elmlang
|
general
|
yea, conditionally show elements, add classes, add rows to a table. Those are all possible applications
|
2019-01-29T11:56:15.244000
|
Lilli
|
elmlang
|
general
|
yeah it's tricky to make that look neat, often ends up messy
|
2019-01-29T11:57:19.244200
|
Nana
|
elmlang
|
general
|
The cutest I ever came up with in that situation :wink:
|
2019-01-29T11:58:09.245000
|
Antonette
|
elmlang
|
general
|
I also do `List (Maybe a)` w/ filtermap, but you could also do something like
```
let extras = if List.all identity [a,b] then [x, y] else if List.any identity [a,b] then [y] else []
in [a,b,c] ++ extras
```
Or even just filtermap the optionals and append them
|
2019-01-29T12:00:16.247500
|
Earnest
|
elmlang
|
general
|
I usually do something like
```
[a, b, c]
++ (if something then
[x, y]
else
[]
)
```
|
2019-01-29T12:00:55.248300
|
Nana
|
elmlang
|
general
|
I did that for a while, but I find it less readable most of the times.
|
2019-01-29T12:01:02.248400
|
Antonette
|
elmlang
|
general
|
Aaaaand that is pretty ugly, no offense.
|
2019-01-29T12:01:23.248600
|
Antonette
|
elmlang
|
general
|
yes it is :laughing:
|
2019-01-29T12:01:45.248800
|
Nana
|
elmlang
|
general
|
the thing [a,b,c] ++ extra ends up messy when the contidion if no straight forward. At least in my experience :smile:
|
2019-01-29T12:02:52.249000
|
Lilli
|
elmlang
|
general
|
Yep. Even worse when you want the extra to appear at specific points. Even worse when there are lots of them.
|
2019-01-29T12:05:38.250300
|
Antonette
|
elmlang
|
general
|
At that point I'd start writing functions that handle the conditional testing or switch to Maybe
|
2019-01-29T12:06:09.251000
|
Earnest
|
elmlang
|
general
|
And yeah if you need optional things in arbitrary positions instead of beginning or end, just use the filterMap
|
2019-01-29T12:06:34.251600
|
Earnest
|
elmlang
|
general
|
sometimes i also do something like this
```
[ (a, True)
, (b, True)
, (c, True)
, (x, #someCondition)
, (y, #someOtherCondition)
] |> filterMap filterHelper
```
This way it's easy to read when things should be there or not
|
2019-01-29T12:07:32.253300
|
Lilli
|
elmlang
|
general
|
for html nodes in particular I have this function though:
```
nodeIf : Bool -> Html msg -> Html msg
nodeIf condition ifTrue =
if condition then
ifTrue
else
text ""
```
it's kinda nice I think
|
2019-01-29T12:07:49.253700
|
Nana
|
elmlang
|
general
|
You can also do `|> List.filter Tuple.second |> List.map Tupel.first` instead of writing `filterHelper`
|
2019-01-29T12:09:08.255100
|
Earnest
|
elmlang
|
general
|
so you can just do:
```
div []
[ text "hello"
, text "world"
, nodeIf model.show (text "foo")
]
```
|
2019-01-29T12:09:22.255600
|
Nana
|
elmlang
|
general
|
Yeah that's common, also a `nodeMaybe : Maybe a -> (a -> Html msg) -> Html msg`
|
2019-01-29T12:09:39.256000
|
Earnest
|
elmlang
|
general
|
in this case you can have a neutral element `text ""` but sometimes there is no such element :sweat_smile: but yea, this is the same approach of Maybe X, where the neutral element is Nothing
|
2019-01-29T12:10:06.256200
|
Lilli
|
elmlang
|
general
|
Looks pretty ok too :slightly_smiling_face:
|
2019-01-29T12:10:43.256900
|
Antonette
|
elmlang
|
general
|
I've been thinking, I wonder if it'd be neater if html node/attribute lists were trees instead of lists, which were automatically flattened in the end
|
2019-01-29T12:11:05.257400
|
Nana
|
elmlang
|
general
|
or if Elm had a "list spread operator" like `...` in JavaScript
|
2019-01-29T12:11:59.258100
|
Nana
|
elmlang
|
general
|
a list spread operator would be pretty nice I think!
|
2019-01-29T12:12:46.258400
|
Nana
|
elmlang
|
general
|
I'm not a fan of "polluting" the dom tree with useless nodes ; at least the `List (Maybe a)` doesn't introduce long-living `Nothing` elements in a deep structure.
|
2019-01-29T12:12:53.258500
|
Antonette
|
elmlang
|
general
|
Still, if there was a value that says "this is technically an `Html msg` but don't put it in the dom tree please" I'd rather use that than a `List (Maybe a)`.
|
2019-01-29T12:14:48.260300
|
Antonette
|
elmlang
|
general
|
(like an `Hml.none` or something)
|
2019-01-29T12:15:15.261100
|
Antonette
|
elmlang
|
general
|
<@Rutha> never thought of that. So far i never encountered a situation where a tree would be clearer to read compared to a list
|
2019-01-29T12:15:16.261300
|
Lilli
|
elmlang
|
general
|
then you could do:
```
[ a
, b
, c
, ... (if condition then
[x, y]
else []
)
]
```
|
2019-01-29T12:15:26.261500
|
Nana
|
elmlang
|
general
|
Hmm. That's a great feature to have actually.
|
2019-01-29T12:15:55.262300
|
Antonette
|
elmlang
|
general
|
nodes _are_ trees :slightly_smiling_face:
|
2019-01-29T12:16:27.264100
|
Carman
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.