workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | <@Nga> it's protection against malicious scripts, but you as a user can still see them | 2019-03-26T11:17:48.787200 | Nana |
elmlang | general | Ah, that makes sense. | 2019-03-26T11:18:12.787400 | Nga |
elmlang | general | is `type alias Model = String` the correct way to say that my model is just a string? Because something is going on about it being a `a -> String`? | 2019-03-26T13:24:33.788600 | Christia |
elmlang | general | Yes, that’s correct | 2019-03-26T13:34:28.788900 | Kris |
elmlang | general | Fwiw, you don’t even need to write that type alias | 2019-03-26T13:34:40.789400 | Kris |
elmlang | general | Elm's help for make tells me, that I can compile more than one file:
```
elm make --help
The `make` command compiles Elm code into JS or HTML:
elm make <zero-or-more-elm-files>
```
..but what is the usecase for compiling more than the Main-module ? | 2019-03-26T17:12:41.791400 | Cherish |
elmlang | general | <@Cherish> you can have multiple Elm apps, each with their own `main` function, and bundle them into a single artifact. So you get a single JS file, with dead code elimination and deduplication applied, that contains exactly what you need to use those apps on a page. | 2019-03-26T17:16:27.793200 | Huong |
elmlang | general | It's especially useful for folks who are embedding multiple small Elm apps on a single page | 2019-03-26T17:17:15.793900 | Huong |
elmlang | general | Ok, I see.. so embedding these multiple independent Elm Apps (== multiple main functions) in a page via JS is like
```
Elm.Main.init(...)
Elm.Main2.init(...)
Elm.Main3.init(...)
``` | 2019-03-26T17:20:10.795900 | Cherish |
elmlang | general | all included in one JS, the output of compiling multiple Main modules ? | 2019-03-26T17:20:40.796600 | Cherish |
elmlang | general | great, thx | 2019-03-26T17:24:15.796900 | Cherish |
elmlang | general | Is putting `let _ = Debug.log "alksdfjak" in` at the beginning of my update function supposed to log something to the console if the update function is called? | 2019-03-26T18:10:36.797800 | Christia |
elmlang | general | yes | 2019-03-26T18:13:35.798400 | Virgie |
elmlang | general | `Debug.log` takes 2 arguments and returns the 2nd argument. Could that be causing issues? | 2019-03-26T18:13:47.798900 | Chae |
elmlang | general | well, you need two arguments to `Debug.log` | 2019-03-26T18:13:52.799100 | Virgie |
elmlang | general | `Debug.log "some name" someValue` | 2019-03-26T18:13:59.799400 | Virgie |
elmlang | general | Oh right, that explains it. Thanks. | 2019-03-26T18:15:37.799700 | Christia |
elmlang | general | <@Christia> while it's common to use `Debug.log` in a `let` and ignore the return value, you're less likely to make the above mistake if you use it inline and use it's result. | 2019-03-26T18:22:37.801200 | Earlean |
elmlang | general | Oh yeah that's super handy to use it inline | 2019-03-26T18:32:25.801600 | Christia |
elmlang | general | There is some real wisdom here:
```
If we see 'lines of code' as 'lines spent', then when we delete lines of code, we are lowering the cost of maintenance. Instead of building re-usable software, we should try to build disposable software.
``` | 2019-03-26T20:16:19.801800 | Jana |
elmlang | general | Is there a way to send data through a port where a field might not exist and not have to use JSON encoders/decoders?
JavaScript:
```
app.ports.updateDeck.send({name: 'my deck', photo: null})
```
Elm:
```
port updateDeck : (Deck -> msg) -> Sub msg
type alias Deck = { name : String, photo : Maybe String }
```
That doesn’t work. Is my only option JSON encoders/decoders? | 2019-03-26T23:16:06.805100 | Jacquelyn |
elmlang | general | <@Jacquelyn> ports will automatically handle `Maybe String`, what isn't working about your code? | 2019-03-26T23:21:01.806000 | Earlean |
elmlang | general | <@Earlean> I get the following error:
```
Uncaught Error: Trying to send an unexpected type of value through port `updateDeck`:
[object Object]
at _Debug_crash (Deck.js:750)
```
But now that you tell me it should work, I’m going to see if it’s not something else causing this error… | 2019-03-27T00:59:50.806300 | Jacquelyn |
elmlang | general | In fact, I was passing `photoURL` instead of `photo`! My mistake… Thank you <@Earlean> for letting me know this should’ve worked. | 2019-03-27T01:01:42.806500 | Jacquelyn |
elmlang | general | :+1: | 2019-03-27T01:01:59.806700 | Earlean |
elmlang | general | hello, i have an error of ``` You are declaring port `fromJS` in a normal module.
13| port fromJS : (() -> msg) -> Sub msg
^^^^^^
It needs to be in a `port` module.
``` but `import port exposing (..)` seems not to find the port module, what's the correct import ? | 2019-03-27T02:39:25.807900 | Leopoldo |
elmlang | general | the module name needs to be prepended with `ports` | 2019-03-27T02:47:12.808600 | Ruthann |
elmlang | general | ie:
```
ports module abc exposing ...
port fromJS ...
``` | 2019-03-27T02:47:35.809100 | Ruthann |
elmlang | general | <https://guide.elm-lang.org/interop/ports.html#outgoing-messages> <@Leopoldo> | 2019-03-27T02:49:05.809400 | Ruthann |
elmlang | general | <@Ruthann> this popped up
`ports module Test exposing (..)`
`port fromJS : (() -> msg) -> Sub msg`
``` 15| ports module Test exposing (..)
^
I was expecting:
- an argument, like `name` or `total`
- the "has type" symbol (:) followed by a type
- an equals sign (=)
``` | 2019-03-27T02:52:05.810100 | Leopoldo |
elmlang | general | oh, wait | 2019-03-27T02:52:45.810400 | Leopoldo |
elmlang | general | sorry | 2019-03-27T02:52:45.810600 | Leopoldo |
elmlang | general | port instead of ports | 2019-03-27T02:52:50.810800 | Leopoldo |
elmlang | general | yep, my bad | 2019-03-27T02:53:27.811000 | Ruthann |
elmlang | general | 15| port module Test exposing (..)
^
I was expecting to see a lower-case variable, like `x` or `user` | 2019-03-27T02:53:31.811200 | Leopoldo |
elmlang | general | what's above line 15? | 2019-03-27T02:53:42.811400 | Ruthann |
elmlang | general | your module line should be the first line ( assuming the 15 is the line number ) | 2019-03-27T02:54:06.811900 | Ruthann |
elmlang | general | ``` import Browser
import Browser.Dom exposing (Viewport)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Json.Decode as Json
import Task
port module Test exposing (..)
port fromJS : (() -> msg) -> Sub msg
type alias Model =
{ viewport : Viewport }``` | 2019-03-27T02:54:35.812200 | Leopoldo |
elmlang | general | move your module line to the first line, your imports go under it, this isn't JS!!!! :smile: | 2019-03-27T02:55:03.812800 | Ruthann |
elmlang | general | wait.. that's only 9 lines, is there something else in those 6 lines you're not showing me | 2019-03-27T02:55:58.813200 | Ruthann |
elmlang | general | i have readjusted it, that's all the code <https://gist.github.com/afidegnum/b6e09fb8c137fe281a6be59f37a12026> | 2019-03-27T02:56:51.813600 | Leopoldo |
elmlang | general | `module Test exposing (..)` on the first line should be `port module Test exposing (..)` | 2019-03-27T02:58:05.814100 | Earlean |
elmlang | general | so port is replacing module, right ? | 2019-03-27T02:58:22.814500 | Leopoldo |
elmlang | general | you're declaring that this is a 'port module' not a regular 'module' | 2019-03-27T02:58:40.814900 | Earlean |
elmlang | general | ah, ok | 2019-03-27T02:58:46.815100 | Leopoldo |
elmlang | general | thanks a lot, everything is good now | 2019-03-27T03:00:48.815400 | Leopoldo |
elmlang | general | since a lot can be accomplished in elm, when do we use ports? | 2019-03-27T03:08:14.815700 | Leopoldo |
elmlang | general | places where we do it:
- localstorage
- opening a new tab
- saving file to disk
- calling 3rd party js lib
- focusing on html element ( can do this inside elm in 19 ) | 2019-03-27T03:12:37.816900 | Ruthann |
elmlang | general | hy everyone. is something wrong with the elm-test watch command? when i start it first time, by doing `elm-test --watch` in my project folder it shows me my tests and everything is ok - but when i make a change - and save the file - it doesnt detect that change. It doesnt watch basically .. am i doing something wrong here? Thanks :slightly_smiling_face: | 2019-03-27T05:08:13.819100 | Yang |
elmlang | general | If you're on windows, that's a known issue that got introduced by upgrading the chokidar dependency to 2.0. There's an issue for it, so it'll get resolved! | 2019-03-27T05:15:29.819200 | Huong |
elmlang | general | hmm ok, is there any temporary hack available? | 2019-03-27T05:22:01.819400 | Yang |
elmlang | general | Doing some tests right now, and I would really like to be able to make some exports visible for tests only.
Has anyone found a better solution to this thing than using repulsive names like INTERNAL or KILLSKITTEN for this kind of exported things ? | 2019-03-27T06:08:48.821200 | Caron |
elmlang | general | you mean in a package? | 2019-03-27T06:28:53.821600 | Virgie |
elmlang | general | <@Caron> I bumped into the same kind of problem and found no better solution than either work around it (not using the internals in tests) or use an ugly trick (making a module that holds the internals that only the tests see, then exposing what I wanted exposed to the outside in a public module that is just a proxy for the actual internal module). | 2019-03-27T06:33:40.824000 | Antonette |
elmlang | general | If you find a better way, I'm interested :slightly_smiling_face: | 2019-03-27T06:33:59.824300 | Antonette |
elmlang | general | I don't find a better way :disappointed: | 2019-03-27T06:39:37.824700 | Caron |
elmlang | general | Then unless you really have a good reason to put internals into tests (i.e. testing that data is constructed in the exact way you want on an opaque type) I suggest you consider the first route (making tests that work just like a user would and not look into the innards of your library). | 2019-03-27T06:41:25.826700 | Antonette |
elmlang | general | <@Virgie> no, I mean inside of an app, if you have a module that exposes some things for general purpose and some things for test only. | 2019-03-27T06:42:06.827500 | Caron |
elmlang | general | <@Antonette> I agree with you on a general basis, but I need to test the internal logic of the module itself, because it is not trivial. | 2019-03-27T06:43:32.828600 | Caron |
elmlang | general | and I don't want to package it away considering the other problems introduced by that route. | 2019-03-27T06:44:13.829700 | Caron |
elmlang | general | Ok. Since it's something inside your own app, there's no shame in exposing things you wouldn't in a library anyways. | 2019-03-27T06:44:39.830200 | Antonette |
elmlang | general | (opaque types and such are best used in libs imo) | 2019-03-27T06:44:58.830700 | Antonette |
elmlang | general | The offender is indeed an opaque type. I feel like the application is best served by having it, in order to mark clearly that thing as not for use everywhere (it used to be, and it was a mess). | 2019-03-27T06:46:21.832200 | Caron |
elmlang | general | Maybe this opaque type would be better extracted in a lib then :smiling_imp: | 2019-03-27T06:48:18.834400 | Antonette |
elmlang | general | (ok, this may very well be pushing it a bit far depending on context which I don't know) | 2019-03-27T06:48:56.835100 | Antonette |
elmlang | general | one way to do it could be:
```
type Opaque = Opaque
privateFn = stuff
testExports = { opaque = Opaque, privateFn = privateFn }
``` | 2019-03-27T06:49:19.835500 | Nana |
elmlang | general | (not technically idiot-proof but makes it pretty clear what you're allowed to use in regular code) | 2019-03-27T06:50:01.836000 | Nana |
elmlang | general | Oooh that's a nice way of doing things | 2019-03-27T06:50:41.836300 | Caron |
elmlang | general | Nice way to wrap those for tests indeed. | 2019-03-27T06:57:37.836900 | Antonette |
elmlang | general | I tried the loop variantion with some modifications and wrapped it in another loop to parse a string like this: "aAAABBBCC " and create and output: ["a", "AAA", "BBB", "CC", " "] but it ends up in an infinite loop. Any hints? <https://gist.github.com/ni-ko-o-kin/68793b1b9bd76f454028a56f2e6264cc> | 2019-03-27T07:07:04.837000 | Miguelina |
elmlang | general | It's because the parser always succeeds (chomping `""` on an empty string or end of string), so it never stops in a loop. | 2019-03-27T07:42:52.837500 | Velia |
elmlang | general | It behaves like <https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompWhile>, see the note about it never failing. | 2019-03-27T07:49:17.837800 | Velia |
elmlang | general | It should be modified to fail on empty strings, like this:
```
chompWhileSameLoop : Maybe Char -> Parser (Step (Maybe Char) ())
chompWhileSameLoop maybeChar =
case maybeChar of
Just char ->
oneOf
[ getChompedString (chompIf (\c -> char == c))
|> andThen chompWhileSameNextChar
, succeed (Done ())
]
Nothing ->
getChompedString (chompIf (\_ -> True))
|> andThen chompWhileSameNextChar
```
Because `chompIf (\_ -> True)` will then fail on end of string.
Here is the full module:
```
module Same exposing (chompWhileSame, groupSame, zeroOrMore)
import Parser exposing (..)
groupSame : Parser (List String)
groupSame =
zeroOrMore (getChompedString chompWhileSame)
zeroOrMore : Parser a -> Parser (List a)
zeroOrMore item =
loop [] (zeroOrMoreHelp item)
zeroOrMoreHelp : Parser a -> List a -> Parser (Step (List a) (List a))
zeroOrMoreHelp item revItems =
oneOf
[ succeed (\a -> Loop (a :: revItems))
|= item
, succeed ()
|> map (\_ -> Done (List.reverse revItems))
]
chompWhileSame : Parser ()
chompWhileSame =
loop Nothing chompWhileSameLoop
chompWhileSameLoop : Maybe Char -> Parser (Step (Maybe Char) ())
chompWhileSameLoop maybeChar =
case maybeChar of
Just char ->
oneOf
[ getChompedString (chompIf (\c -> char == c))
|> andThen chompWhileSameNextChar
, succeed (Done ())
]
Nothing ->
getChompedString (chompIf (\_ -> True))
|> andThen chompWhileSameNextChar
chompWhileSameNextChar : String -> Parser (Step (Maybe Char) ())
chompWhileSameNextChar str =
case String.uncons str of
Nothing ->
succeed (Done ())
Just ( c, _ ) ->
succeed (Loop (Just c))
```
Then in `elm repl`:
```
> run groupSame "aAAABBBCC "
Ok ["a","AAA","BBB","CC"," "]
: Result (List DeadEnd) (List String)
> run groupSame ""
Ok [] : Result (List DeadEnd) (List String)
``` | 2019-03-27T08:37:12.838200 | Velia |
elmlang | general | <https://www.slant.co/topics/558/~best-functional-languages-to-learn-for-web-frontend-development> | 2019-03-27T11:31:38.840500 | Celestina |
elmlang | general | I didn’t even know there were 12 | 2019-03-27T11:37:50.841000 | Kris |
elmlang | general | There are exactly 12, so clearly, they are the best. | 2019-03-27T11:42:00.841600 | Teddy |
elmlang | general | Doesn't anyone uses Elm and Firebase together ? | 2019-03-27T11:50:15.841900 | Sadie |
elmlang | general | I do with ports, or firebase rest api. there was a elm-firebase package but i dont know its current status | 2019-03-27T11:51:14.842200 | Rosa |
elmlang | general | I have as a PoC using ports and I really enjoyed it | 2019-03-27T11:51:57.842500 | Chae |
elmlang | general | Are you using the subscription API for that? | 2019-03-27T11:53:03.842700 | Sadie |
elmlang | general | I am using Firestore via ports, works fine :+1: Tried both one time fetching and subscriptions - all ok | 2019-03-27T11:55:48.842900 | Lynne |
elmlang | general | If one of you would have a bit of time to write a small article about this setup it might be really useful :+1: | 2019-03-27T12:01:34.843300 | Sadie |
elmlang | general | I made a message board with firebase + Elm. Heres the repo; this is the JS code specifically showing what the ports on the JS side look like: <https://github.com/Chadtech/Tieugra/blob/master/src/app.js> | 2019-03-27T12:14:38.843700 | Ashton |
elmlang | general | <@Sadie> Someone on my team was just working on a blog post that covers this, I'll let you know when they've finished it and we've published it. | 2019-03-27T12:19:39.843900 | Teddy |
elmlang | general | Awesome thanks | 2019-03-27T12:19:54.844100 | Sadie |
elmlang | general | Theres a pattern to how I went about using the firebase SDK, and how Ive gone about using other SDKs, which I guess is just, a direct correlation of Elm ports to fundamental operations I want to use the SDK for. | 2019-03-27T12:21:45.844300 | Ashton |
elmlang | general | And then there has to be a port back into Elm with the response. | 2019-03-27T12:22:07.844500 | Ashton |
elmlang | general | All the important logic is in Elm, and then a lot of tedious code that just ties the SDK api to Elm, for the most part. | 2019-03-27T12:22:42.844700 | Ashton |
elmlang | general | I wonder if a `Dict.get` with flipped parameters would be worth having at least in `dict-extra`. It (and `Set.member`) is consistently the one reason I resort to using `flip` | 2019-03-27T13:18:28.846200 | Florencia |
elmlang | general | ```
getIn : Dict comparable a -> comparable -> Maybe a
getIn dict key =
Dict.get key dict
``` | 2019-03-27T13:18:57.846800 | Florencia |
elmlang | general | reason being I have to do some work to get to the key, and then the code wants to be `|> Maybe.map (Dict.get dict)` but I have to do `|> Maybe.map (flip Dict.get dict)` | 2019-03-27T13:19:54.847700 | Florencia |
elmlang | general | I think there's a point to be made for changing it in the core package. We put the "thing to transform" last for pipeline friendliness. Based on my experience, it's the key that's usually being transformed, not the dict. | 2019-03-27T13:36:38.850800 | Huong |
elmlang | general | So long story short - yeah, agreed | 2019-03-27T13:36:55.851200 | Huong |
elmlang | general | Glad to hear! | 2019-03-27T13:39:12.851800 | Florencia |
elmlang | general | I think I can at least search for existing and/or create an issue, so that the Evan has it somewhere back in his head :slightly_smiling_face: | 2019-03-27T13:40:13.852800 | Florencia |
elmlang | general | Thx a lot for the great help! Much appreciated! :grinning: | 2019-03-27T14:31:43.853000 | Elisabeth |
elmlang | general | You're welcome. I just realized I misread your initial question and my function was doing the reverse of what your were asking:sweat_smile: | 2019-03-27T14:34:40.853200 | Velia |
elmlang | general | i have changed the current function to package a list of div rather so i can incorporate an additional one at <https://gist.github.com/afidegnum/8dffd22101f52283b603111f8377eb0c#file-bulkit-elm-L287>
but i tried my best to changed the previous html elements to a list even changed their type signature but it wasn't successful, please what do i change for this error to go?
```
This `pageContent` value is a:
List (Html Msg)
But all the previous elements in the list are:
Html msg
``` | 2019-03-27T15:25:35.855300 | Leopoldo |
elmlang | general | <@Leopoldo> which line does the compiler complain about? | 2019-03-27T15:27:03.856000 | Florencia |
elmlang | general | the compiler is complaining about <https://gist.github.com/afidegnum/8dffd22101f52283b603111f8377eb0c#file-bulkit-elm-L188> | 2019-03-27T15:27:40.856300 | Leopoldo |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.