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 carefully thought out and tested code will.
While there are cases where a Native function helps out a lot, it
should _never_ be the first thing to reach for.


Dwayne, I suggest discussing things on the Elm Slack. It will be
easier to get to the exact use case you have for your formatting
issue.


On Sun, Apr 30, 2017 at 7:03 PM, Witold Szczerba <[email protected]> wrote:
> 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" <[email protected]> napisaƂ(a):
>>
>> 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 here's what I ended up with
>> https://gist.github.com/dwayne/550341a5b27ba3c03ce7eba92d33873d#file-1a-useports-elm,
>> https://gist.github.com/dwayne/550341a5b27ba3c03ce7eba92d33873d#file-1b-useports-html.
>>
>> P.S. The solution still doesn't quite work because all money receives the
>> first incoming subscription message causing them to display the same
>> formatted value. I didn't bother to fix it because the solution is bad
>> enough.
>>
>> I think we can safely rule out ports. Noah, do you have any thoughts on
>> the code? Did I miss anything?
>>
>> That leaves us with:
>>
>> Using a Native module. (Looks like the best compromise for my needs in the
>> short-term.)
>> Rewrite in pure Elm. (Looks like the best long-term solution.)
>>
>> Next step: I will write up a Native solution and see how that goes.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to