workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
elmlang
general
Otherwise the dead code elimination will remove it.
2019-03-12T11:21:01.857600
Jin
elmlang
general
The whole App?
2019-03-12T11:21:14.857900
Corinne
elmlang
general
The port, so it won’t appear in `app.ports`.
2019-03-12T11:22:02.858500
Jin
elmlang
general
but `app.ports` is `undefined`
2019-03-12T11:22:13.858800
Corinne
elmlang
general
Unless.. .that's expected?
2019-03-12T11:22:31.859400
Corinne
elmlang
general
you gotta wire them up on the Elm side
2019-03-12T11:23:43.859700
Rosa
elmlang
general
Ah, right so a completely empty object for `app` is normal
2019-03-12T11:25:11.861000
Corinne
elmlang
general
If you never use any incoming port in your `subscriptions` function used in `main` nor any outgoing port in `init` or `update`, then `app.ports` will be undefined because the elm compiler will have optimized those away (as they are never called)
2019-03-12T11:25:55.861900
Mindy
elmlang
general
Cool, thanks. I guess I was expecting _something_ to be in that object, or maybe a `[]` for `ports`, but I see now
2019-03-12T11:26:58.862700
Corinne
elmlang
general
Basically, `app` is just an object that may or may not have a `ports` field and `app.ports` is an object with one field per port called in the elm side. If it is an outgoing port, it will have access to a `subscribe` and an `unsubscribe` method. If it is an incoming port it will have a `send` method.
2019-03-12T11:30:55.865500
Mindy
elmlang
general
using `/` as the italic symbol in combination with `/` as division and `//` in url's isn't possible normally. Why is `/` the symbol for italic (thought it was a single `*`, or `_`)
2019-03-12T11:39:27.865900
Virgie
elmlang
general
None
2019-03-12T11:42:42.866100
Leoma
elmlang
general
<@Virgie> <https://bear.app> parses this way :point_up:. It’s more intuitive for people who don’t understand markdown.
2019-03-12T11:42:47.866500
Leoma
elmlang
general
In my implementation, modifiers (/*) only count if the modifiers have whitespace on the left-but-not-right to open, and right-but-not-left to close.
2019-03-12T11:43:52.867000
Dede
elmlang
general
It covers most cases.
2019-03-12T11:43:55.867200
Dede
elmlang
general
`(5 / 4) ` also parses fine with that.
2019-03-12T11:44:09.867400
Dede
elmlang
general
My math is a bit off. :blush:
2019-03-12T11:44:27.867700
Leoma
elmlang
general
my guess is then that the url is parsed differently
2019-03-12T11:44:33.867900
Virgie
elmlang
general
as in, a url is not text, it is its own thing
2019-03-12T11:44:45.868200
Virgie
elmlang
general
Yes.
2019-03-12T11:44:58.868400
Leoma
elmlang
general
But it can also be styled.
2019-03-12T11:45:44.868600
Leoma
elmlang
general
None
2019-03-12T11:45:50.868800
Leoma
elmlang
general
does something like `ftp://` also parse as a url? or just `http[s]`?
2019-03-12T11:46:00.869200
Virgie
elmlang
general
I mean, once one has a the code for one, the other is easy to add. My target is very simple markdown I can explain to non-savvy users is a single example. `"*this will be bold* /this will be italic/" <http://clickme.com>"` I think most people won’t know or care about ftp.
2019-03-12T11:48:10.870100
Leoma
elmlang
general
Anyway, I have some pseudo code I like. Off to the battlefield to see where this goes. Back in a bit and thanks to everyone for their help so far.
2019-03-12T11:50:51.872600
Leoma
elmlang
general
is there any way to "namespace" a bunch of type constructors? I want to import a type `S` but have the type constructors accessed on `S`, e.g. `S.Value`. Maybe there's a clever trick that I don't know... ``` module Values exposing (S(..)) type S = A | B | C ... module Main import Values exposing (S) defaultModel = S.A ```
2019-03-12T11:51:33.873300
Kymberly
elmlang
general
To my knowledge constructors are on the same level of visibility of the type.
2019-03-12T11:53:37.874000
Hoa
elmlang
general
If you constructors have generic names consider to add a suffix or prefix to them. E.g. `type BlendMode = MultiplyMode | OverlayMode | ... ` instead of generic `Multiply` or `Overlay`.
2019-03-12T11:55:20.875600
Hoa
elmlang
general
In your example I would write `Values.A`
2019-03-12T11:56:20.876200
Hoa
elmlang
general
Constructors are namespaced by the name of their module, not their type :+1:
2019-03-12T11:58:54.876900
Carman
elmlang
general
Any package for AES Symmetric Encryption?
2019-03-12T12:07:20.878700
Brady
elmlang
general
I want to exchange keys with node.js and send encrypted messages between server and Elm app
2019-03-12T12:08:23.879600
Brady
elmlang
general
I can use ports, but I'd like to do that in Elm if possible
2019-03-12T12:08:49.880200
Brady
elmlang
general
Is there any tool that checks if dependencies listed in `elm.json` are actually used?
2019-03-12T12:11:21.881400
Dorsey
elmlang
general
<@Dorsey> <https://github.com/stil4m/elm-analyse>
2019-03-12T12:11:51.882000
Brady
elmlang
general
Elm parser question: how would one implement a grammar fragment of this form? ``` textSquence = textNoWhitespace | textSequence whitespace textNoWhitespace ```
2019-03-12T12:12:21.882800
Dede
elmlang
general
(idiomatically?)
2019-03-12T12:12:33.883200
Dede
elmlang
general
<@Brady> Other ppl are using this: <https://package.elm-lang.org/packages/billstclair/elm-crypto-aes/latest/>
2019-03-12T12:12:38.883400
Hoa
elmlang
general
Not expert, tho. Might well be it has limits :slightly_smiling_face:
2019-03-12T12:13:06.884000
Hoa
elmlang
general
<@Hoa> I was looking at that but cannot figure how to import shared key, but thanks!
2019-03-12T12:13:40.884600
Brady
elmlang
general
Thanks <@Brady> (and <@Shea> of course)
2019-03-12T12:29:42.884700
Dorsey
elmlang
general
Test case question: `/* hello*/` Does this get italics or not? :wink:
2019-03-12T12:30:46.884900
Dede
elmlang
general
So, I’m not super fussy about edge cases, but I suspect the simplest parser that mostly works will parse that as `Italic "* hello*"` (or however the type is represented)
2019-03-12T12:35:48.885200
Leoma
elmlang
general
Broader question: Elm Parser mostly advertises itself as a replacement for regexps, rather than, say, for BNF-driven parser generators (e.g. yacc/bison.) Do people use it in the latter manner as well, or mostly hand-write parsing once the Parser has handled tokenization?
2019-03-12T12:58:37.886700
Dede
elmlang
general
Update: I believe I’ve found a fast manual way to to this without Parser or Regexp. Will share if/when it works. (Very Fermat-esque statement.)
2019-03-12T14:20:42.886800
Leoma
elmlang
general
parser combinators are usually used to parse straight into an AST, so no separate lexer/parser, thing. So yeah, elm/parser type parsers are definitely used as a replacement for BNF-driven parser generators
2019-03-12T14:52:37.887100
Huong
elmlang
general
Thanks. Formally does that wind up being in the LL top-down family of parsers, then?
2019-03-12T14:57:28.887400
Dede
elmlang
general
Yeah, pretty much
2019-03-12T15:05:26.887600
Huong
elmlang
general
As a nontrivial example of something that's parsed using parser combinators: our dearly beloved `elm` compiler parses Elm using parser combinators :slightly_smiling_face:
2019-03-12T15:06:39.887800
Huong
elmlang
general
:wink:
2019-03-12T16:02:38.888100
Dede
elmlang
general
In Haskell or elm?
2019-03-12T16:48:12.888500
Dede
elmlang
general
Haskell, though Elm can be parsed using `elm/parser`, in Elm, too - `stil4m/elm-syntax` does just that
2019-03-12T16:49:33.888700
Huong
elmlang
general
I'm trying to get the error message out of `Json.Decode.fromValue`, and the docs _say_ it's a `Result String a` but when I `Debug.log` it it's `Err (Failure "Expecting an OBJECT with a field named `accessTokens`" &lt;internals&gt;)`
2019-03-12T16:51:47.890000
Kymberly
elmlang
general
are the docs misleading or am I doing something wrong there?
2019-03-12T16:52:13.890400
Kymberly
elmlang
general
``` -- decodeValue : Decoder a -&gt; Value -&gt; Result String a decodedJson = userJson |&gt; D.decodeValue (D.map3 User (D.field "name" D.string) (D.field "id" D.string) (D.field "username" D.string) ) updatedModel = case Debug.log "decodedJson" decodedJson of Ok value -&gt; -- great! Err error -&gt; -- error should be a string, right? ```
2019-03-12T16:54:02.891600
Kymberly
elmlang
general
if I add `D.Failure` to the pattern, I get some clues... ``` Missing possibilities include: Err (Field _ _) Err (Index _ _) Err (OneOf _) ```
2019-03-12T16:56:04.892100
Kymberly
elmlang
general
<@Kymberly> <https://package.elm-lang.org/packages/elm/json/latest/Json-Decode#Error>
2019-03-12T16:58:05.892500
Earlean
elmlang
general
You must be looking at the wrong package docs
2019-03-12T16:58:21.893100
Earlean
elmlang
general
dang I must've checked that I was on latest a dozen times - but prob on another package page.
2019-03-12T17:02:27.893500
Kymberly
elmlang
general
thx!
2019-03-12T17:02:29.893700
Kymberly
elmlang
general
Huh, I was looking at <https://package.elm-lang.org/packages/elm-lang/core/latest/Json-Decode>
2019-03-12T17:03:03.894200
Kymberly
elmlang
general
Yep, that's docs for the core package for Elm 0.18
2019-03-12T17:05:17.895200
Earlean
elmlang
general
oh yikes - I'll have to keep an eye for "packages/elm-lang" - it shows up in a google search. :confused:
2019-03-12T17:08:00.896100
Kymberly
elmlang
general
If you search via <https://packages.elm-lang.org> you'll only get 0.19 packages
2019-03-12T17:14:34.897200
Earlean
elmlang
general
Older packages will come up in Google searches
2019-03-12T17:15:02.897800
Earlean
elmlang
general
<@Kymberly> <https://github.com/elm/package.elm-lang.org/issues/275>
2019-03-12T17:31:54.898100
Millie
elmlang
general
Thanks.
2019-03-12T17:32:09.898200
Dede
elmlang
general
About to have dinner, but I’ll leave you with this <https://gist.github.com/z5h/493423f87f77bbdcf886159b21a3dc87> Should I feel bad I’m now using regexs? I think I’m using them responsibly.
2019-03-12T17:33:20.898400
Leoma
elmlang
general
Does it work? Is it maintainable? If so, it’s good enough for prod :wink:
2019-03-12T17:50:47.898700
Dede
elmlang
general
Eventually yes and yes. But I’m mildly um bothered by the fact the elm/parser didn’t make it easier.
2019-03-12T18:39:19.900200
Leoma
elmlang
general
I don't think that such a markdown can have very simple rules and be very practical at the same time. For example have a look at the commonMark specification that tries to give a synthesis of the reasonable rules: <https://spec.commonmark.org/0.28/#emphasis-and-strong-emphasis> Not that simple... I would not go the regexs route for performance reasons (you should test what you did on the biggest/more complex document supported by the software) and because you will have tons of edge cases that you will fix, progressively making the regexs more and more complicated, and their maintenance impossible without breaking something. Anyway, just to show that something is possible with elm/parser: <https://ellie-app.com/4XGvnPg32fYa1> The rules are very strict, and therefore most likely not very practical: • Delimiters are '/', '*' and '_' for italic, bold and underline (the '/' choice is quite risky in my opinion) • You can nest them but if one is not closed inside another, it will be cancelled That's it. I did not implement any space before/after things, line breaks or url handling. You could add an url parser before every others to handle them without conflicting with the styles. However I did not really understand what you wanted about accepting some divisions like "5/2" without conflicting. The code is a little obfuscated by the usage of `loop` to avoid stack issues (so it uses tail-call elimination),. Anyway this is just for demo purposes, and there may be bugs. The performance should be reasonable though.
2019-03-12T18:55:50.900400
Velia
elmlang
general
I just pushed a big overhaul to <https://github.com/jhbrown94/elmish-minimarkdown> It’s still not a pure Elm Parser implementation, but it’s a lot cleaner than the first pass.s
2019-03-12T19:23:06.900700
Dede
elmlang
general
(As before, right now it just supports italic and bold.)
2019-03-12T19:23:57.900900
Dede
elmlang
general
But it handles all the goofy cases reasonably well IMHO.
2019-03-12T19:24:10.901100
Dede
elmlang
general
Think this is a readable function? ``` is18 : Int -&gt; String -&gt; Bool is18 currentTime dobStr = let ( month, day, year ) = dobStr |&gt; String.split "/" |&gt; listToTuple3 in case Iso8601.toTime (year ++ "-" ++ month ++ "-" ++ day) of Ok value -&gt; -- 568025136000 is 18 years in miliseconds 568025136000 &lt; (currentTime - Time.posixToMillis value) _ -&gt; False listToTuple3 : List String -&gt; ( String, String, String ) listToTuple3 list = case list of [ a, b, c ] -&gt; ( a, b, c ) _ -&gt; ( "", "", "" ) ``` where `dobStr` is a `mm/dd/yyyy` string I suppose I could ensure that that string is formatted as a iso8601 string first, but wanna start here…
2019-03-12T19:27:35.902200
Jeanene
elmlang
general
I might do something like ``` Iso8601.toTime (year ++ "-" ++ month ++ "-" ++ day) |&gt; Result.map (\value -&gt; 568025136000 &lt; (currentTime - Time.posixToMillis value)) |&gt; Result.withDefault False ```
2019-03-12T19:31:18.902700
Hoyt
elmlang
general
Although I would probably pull that lambda into an actually function like `greaterThan18` to make it more clear what that is comparing
2019-03-12T19:33:35.903900
Hoyt
elmlang
general
Or at least something like ``` millisecondsIn18years = 568025136000 ```
2019-03-12T19:34:04.904500
Hoyt
elmlang
general
I’ll try this out tomorrow and report back!
2019-03-12T19:35:18.904900
Jeanene
elmlang
general
<@Jeanene> that milliseconds seems wrong. For example 568,015,222,000 &lt; 568,025,136,000, but it's exactly 18 years ago today
2019-03-12T20:06:51.907000
Chae
elmlang
general
today != now…I think I got the ms from `18.years.ago.to_i` in ruby :smile: :sweat_smile:
2019-03-12T20:08:17.907700
Jeanene
elmlang
general
That's a variable number due to leap years
2019-03-12T20:09:58.908400
Chae
elmlang
general
None
2019-03-13T00:55:41.908900
Leoma
elmlang
general
The regex parser lives: <https://gist.github.com/z5h/493423f87f77bbdcf886159b21a3dc87> Parsing and rendering in 216 lines, even after a painful lesson <https://github.com/elm/regex/issues/10>
2019-03-13T00:56:04.909300
Leoma
elmlang
general
Is there an easy way to get a zero value'd record without making it myself? i.e.: ```type alias Thing = { x : Int, y : Maybe String }```, then ```getZeroValue Thing``` returns ```{x=0, y=Nothing}```. I strongly feel like the answer is no, but I'm praying otherwise :stuck_out_tongue:
2019-03-13T03:08:32.911400
Nga
elmlang
general
503 God's service not available at this time
2019-03-13T03:10:01.911900
Lynne
elmlang
general
The answer is no, sorry :slightly_smiling_face:
2019-03-13T03:10:36.912200
Lynne
elmlang
general
awwww, heh. thanks
2019-03-13T03:11:14.912400
Nga
elmlang
general
<@Nga> a 'zero value' isn't meaningful for a lot of types
2019-03-13T03:17:34.913200
Earlean
elmlang
general
What would you use this behaviour for?
2019-03-13T03:18:27.914200
Earlean
elmlang
general
<@Earlean> I have a bunch of record types that define API responses. When I don't have an API response, I have it as `Maybe ApiRespObj`, but once I've received the object I transition my state from a `Maybe ApiRespObj` to just a `ApiRespObj`, so that it's easier to work with in my views. The conversion from the Maybe to the not-maybe is where I'm having a headache, because when I'm casing on my `MaybeApiRespObj` to determine whether I can convert it, if it's Nothing, I need to fall back to some zero-initd default value. It's programmed in a way that the case is never hit, but it still needs to be there because Elm needs to cover all cases.
2019-03-13T03:21:03.916500
Nga
elmlang
general
Ah, that is a common mistake. Don't convert a Maybe to a nonsense default value. Just use `Maybe.map` etc. to work with the Maybe
2019-03-13T03:24:32.918700
Earlean
elmlang
general
Right. it's a bit of a shame because I've modeled the data in such a way that it can only ever have a correct value at that point (we have a union type that declares the state of the app, whether its Loading, Loaded, an error, etc). By using Maybe's as my Loaded values it doesn't make a lot of sense since that's not actually something that can ever happen. Not sure where this indicates the real problem is with the approach we've taken.
2019-03-13T03:35:54.920500
Nga
elmlang
general
Or if it's just a limitation problem that we have to accept.
2019-03-13T03:36:33.920800
Nga
elmlang
general
A `Maybe a` that can't be Nothing should just be an `a`, right? I'm just guessing of course, but I'd look higher up if the Maybe can be avoided before giving it to the function that doesn't expect any Nothings.
2019-03-13T03:58:52.921100
Sharon
elmlang
general
<@Sharon> We have something like: `{settings = Maybe ApiSettingsResponse, profile = Maybe ApiProfileResponse}`. Can't set them to just `a` because then it's the same problem again (zero initialization before the API request returns).
2019-03-13T04:01:40.922400
Nga
elmlang
general
Settings and Profile seems like something which you get once at the very start. If that is the case it may be a good idea to postpone initialization of page/view which depends on these and only init it when you receive them. In this case you won't need `Maybe`s.
2019-03-13T04:06:02.923600
Lynne
elmlang
general
<@Nga> so if they can't be Nothing when you're `Loaded` then that's the time to unwrap them, if any of them are Nothing then you're still in the `Loading` state
2019-03-13T04:18:26.926200
Earlean
elmlang
general
I succeeded in uploading a file together with other data, I thought this might be interesting. <https://discourse.elm-lang.org/t/how-i-uploaded-a-file/3309?u=hermanverschooten>
2019-03-13T05:10:29.927500
Salvador
elmlang
general
I finally upgraded to 0,19. I tried to remove npx from my building script `npx elm make Apps/AccountDetails.elm --output ../app/assets/javascripts/passare_elm.js`, but I get an error about elm-package.json not existing (I had removed it). What do I need to do for the upgrade to be permanent? I had understood that npx was for a temporary change
2019-03-13T09:19:56.930400
Donnetta