Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-05-01 Thread Dwayne Crooks
No I haven't. Thanks for sharing. I'll keep an eye on it but I doubt I'd add it to the project. On Sunday, April 30, 2017 at 9:03:09 PM UTC-4, Dustin Farris wrote: > > Also, have you seen elm-plot? > > https://terezka.github.io/elm-plot/ > > I haven't played with it yet, but it looks pretty

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Dustin Farris
Also, have you seen elm-plot? https://terezka.github.io/elm-plot/ I haven't played with it yet, but it looks pretty neat. Might help with some of your features that used highcharts? Dustin Sent from my iPhone > On Apr 30, 2017, at 8:10 PM, Dwayne Crooks wrote: >

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Dustin Farris
Ah, your version is way better!Love the groupBy function.  Cheers! Dustin Sent from my iPhone > On Apr 30, 2017, at 8:10 PM, Dwayne Crooks wrote: > > I posted here as the other thread seems to be closed off from replies. > > For this particular app I'm

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Dwayne Crooks
I posted here as the other thread seems to be closed off from replies. For this particular app I'm writing/porting the SPA from scratch to Elm and the formatting issue was the first small hiccup I ran into. As suggested in the other thread I went ahead and wrote the code I needed in Elm. Here

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Witold Szczerba
Noah, just re-read the Dwayne's original post. He has some app in React and he's trying Elm to replace it. One of his first bump was the little, (trivial maybe) issue with formatting. He's used to use that very library for it and the question was how should the integration look like. Using ports

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Noah Hall
Witold, that's a ridiculous response. Please re-read my reply. Without fully knowing the context of the problem, you suggested using Native. This is not something we encourage in the Elm community. There are valid reasons as to why not. When recommending it, is it best to know _everything_ about

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Witold Szczerba
Noah is always right. He's just a Elm Rock Star, he knows the best. is that realy what be said to me or did I miss the point? I have no idea what I was thinking when I dreaded to "lecture" him. Oh, by the way, Dwayne's attempt to follow those golden rules failed. He must have missed something

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Erik Lott
Noah is right. You don't want to reach for Native for this type of integration. If this can't be smoothly integrated with ports (we've all felt that pain), the next best option is to write the elements of the plug-in that you need in elm. On Sunday, April 30, 2017 at 1:37:04 PM UTC-4, Noah

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Noah Hall
Witold, with all due respect, I am one of the people who has written the _most_ Native code. I know a thing or two about it. You do not need to lecture me, and my warning should be heeded. Like I said, there are _some_ cases where a Native binding makes sense. They are few and far between. These

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Witold Szczerba
Noah, this is exactly the kind of problem to be solved by native binding. Dwayne wants to use his formatting library. This is a classic example of pure function. Nothing is going to crash if you wrap exception in Result and check types. Good advices of self reimplementig everything from scratch

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Noah Hall
Witold, this it not the advice that we give to people exploring such problems in Elm. There are many reasons why Native bindings are bad. A single error in your JS will cause the _entire_ application to crash unrecoverably. Wrapping things as a result will not help you catch those errors. Writing

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Witold Szczerba
Ports and subscriptions are for executing actions with effects, in my opinion. Native bindings for pure functions are nothing bad. Just keep away from exceptions, use Result in case of possible troubles. 30.04.2017 4:00 PM "Dwayne Crooks" napisał(a): > Thanks guys. > >

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-30 Thread Dwayne Crooks
Thanks guys. I explored Noah's approach to see how the solution would turn out. But I didn't like it. The code change required to format a list of floats as money is ridiculous. Here's what I started with https://gist.github.com/dwayne/550341a5b27ba3c03ce7eba92d33873d#file-0-start-elm. And

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-29 Thread Witold Szczerba
I would use native binding for such a thing. Last week I had to format money as well and found "toFixed" missing in Elm, so I've created a native module for that (few lines of code). It's perfect, just remember: output always depends on nothing but input and never let exceptions blow your Elm

Re: [elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-29 Thread Noah Hall
The recommended approach is to rewrite the logic you need into Elm. Otherwise, what you can do is make your model store the current money, then pull it back in through a port. Store the input money, as a placeholder until it has been calculated and recieved back into Elm. It should look something

[elm-discuss] Ports seem contrived when trying to format a value as money

2017-04-29 Thread Dwayne Crooks
I'm porting an application from React/Redux to Elm and I'm having trouble figuring out how to format a value as money. In the original application we used http://openexchangerates.github.io/accounting.js/. So naturally I wanted to make use of that same library when writing the Elm version.