Re: [elm-discuss] Re: Convincing my team that Elm isn't just going to die like CoffeeScript

2016-11-06 Thread Peter Damoc
On Sun, Nov 6, 2016 at 12:01 AM, Zacqary Adam Xeper 
 wrote:

> How do I convince Elm skeptics that this thing is here to stay?


The Q&A session from elm-conf has a lot of great questions and great
answers addressing fears, uncertainties and doubts around Elm. I would
recommend you watch it and take notes.  :)
https://www.youtube.com/watch?v=LCNs92YQjhw

On Sun, Nov 6, 2016 at 2:52 AM, Robin Heggelund Hansen  wrote:

> 1. Elm is simple to learn. It was made for learning.
>

This is so true. I would bet that anyone can be up and running with Elm
within a week. Ossi said two weeks in the above video but I'm more
optimistic about it. ^_^
Elm has "a small number of powerful constructs" and once you got them, you
stop being limited by your understanding of the language.



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Fetch an element in a list from a parent module and render it in a child module

2016-11-06 Thread Did
Hi there,

is there a way for a parent module to "subscribe" to a child module 
"event"? Here is the thing : I want to create a contact list. For that, I 
have a component named ContactList. Inside, I display all contacts like 
this :

renderContact: Contact.Model -> Html a
renderContact contact =
li [] [Contact.view contact]

renderContacts: Model -> Html a
renderContacts model =
model.contacts
|> List.map renderContact
|> ul []

view: Html a
view =
div [] [
renderContacts model
]

You can see that a contact is rendered by the Contact module, like this :

type alias Model = {
firstname  : String
   ,name   : String
   ,phonenumber: String
}

view: Model -> Html a
view model =
 span[]
 [
 a [style contactfield] [text <| model.firstname ++ " " ++ 
model.name]
,span [style contactfield] [text <| model.phonenumber]
 ]

I would like to interact with the "a" element so that when the user click 
on it, it displays details about the selected contact. I started to write 
something like this :

type alias Model = {
id: Int
   ,firstname  : String
   ,name   : String
   ,phonenumber: String
}

view: Model -> Html a
view model =
 span[]
 [
 a [style contactfield, on "click" (Json.map fetchDetail 
decodename), attribute "data-value" model.id)] [text <| model.firstname ++ 
" " ++ model.name]
,span [style contactfield] [text <| model.phonenumber]
 ]

Here, my model has improved with a new property : id. But the Contact 
module is not aware of any list of contacts, so I can't apply any filter in 
order to fetch the desired contact. Is there a way to simply realize this? 
Or maybe I'm on a totally wrong way...

Thanks!

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Animation not very smooth.

2016-11-06 Thread Gaëtan André
OK I solved my problem.

Culling foodElements (little green circles) to the screen led to less webgl 
calls which solved the smoothness problem.

Webgl api calls are costly. Maybe a a way to reduce the number of calls in 
my case could have been to use a geometry shader to instantiate multiple 
food elements. Anyway culling at application level works fine.

Thanks for your help.

Le samedi 5 novembre 2016 11:27:52 UTC+1, Gaëtan André a écrit :
>
> viewGrid was reworked as you suggested (cf. gist) but the the problem is 
> still the same.
>
> Sorry I had not share the cpu profiles from Chrome the first time, I do it 
> now. As you can see, the problem is that sometimes, a loop call takes a lot 
> longer than others to compute (because of gc it seems).
>
> On Chrome it is basically annoying but still playable, on Firefox it is 
> not playable.
>
> Thanks,
>
> Le jeudi 3 novembre 2016 02:33:35 UTC+1, Nick H a écrit :
>>
>> I am guessing your viewGrid function is slowing your code down. This 
>> function is creating a new mesh and passing it to the GPU on every 
>> animation frame.
>>
>> The solution is to make sure your WebGL.Drawable (line 465, where it says 
>> "GL.Lines gridPoints") is a constant. So extract that into its own 
>> top-level declaration, as you have done with "mesh."
>>
>> On Wed, Nov 2, 2016 at 1:30 PM, Gaëtan André  wrote:
>>
>>> Hello everybody,
>>>
>>> I am working on cloning Agar.io (https://agar.io/) using functionnal 
>>> languages. 
>>> Everything was going well except that my cell movements are not very 
>>> smooth. 
>>> I first blamed the network connection, but after hacking a standalone 
>>> front-end it seems like Elm might have something to do with it.
>>>
>>> From were I am, I don't know where to go to improve fluidity.
>>>
>>> I am subscribing to AnimationFrame.diffs to give the pace of the render 
>>> loop.
>>>
>>> Here is a gist of my code:
>>> https://gist.github.com/rvlander/0b956d5d8d0a70f37f6206cb6f9af367
>>>
>>> Thanks,
>>>
>>> -- 
>>> 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 elm-discuss...@googlegroups.com.
>>> 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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Interactive maps with Elm 0.17 : recommendation?

2016-11-06 Thread dedo
Thanks, Richard & Simon.

@Richard - if I try to port your code to 0.17, how easy or difficult might 
that be? I'm running into various not-yet-documented 0.18 changes e.g. in 
Task.perform.

On Thursday, November 3, 2016 at 11:55:18 AM UTC-5, Richard Feldman wrote:
>
> I have a proof of concept of using the Polymer Google Maps element in Elm: 
> https://github.com/rtfeldman/elm-google-maps
>
> I haven't really documented what I did terribly well, and I haven't used 
> it for a serious project, but seemed to work well...hope it's at least 
> somewhat helpful. :)
>

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Convincing my team that Elm isn't just going to die like CoffeeScript

2016-11-06 Thread Francesco Orsenigo

CoffeeScript and Elm address two vastly different problems.

CoffeeScript addressed "Writing JS is a pain in the ass": it was syntactic 
sugar and the need for it drastically lessened with ES6.
CS was killed by the new JS extensions.

Elm addresses run time errors and JS Fatigue, neither of which JS can 
address organically. In fact, the more JS evolves, the more its syntax is 
extended, the worse JS Fatigue becomes.

IMHO, Elm will fade only when there will be another language that 
simplifies the whole build pipeline and is more appealing to newbies.

At the last Melbourne Meetup we had twice as many RSVPs as the Clojure 
meetup and three times as many as the Haskell one.

>

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Interactive maps with Elm 0.17 : recommendation?

2016-11-06 Thread dedo
Thanks, Richard & Simon.

That polymer track looks really promising!

On Thursday, November 3, 2016 at 11:55:18 AM UTC-5, Richard Feldman wrote:
>
> I have a proof of concept of using the Polymer Google Maps element in Elm: 
> https://github.com/rtfeldman/elm-google-maps
>
> I haven't really documented what I did terribly well, and I haven't used 
> it for a serious project, but seemed to work well...hope it's at least 
> somewhat helpful. :)
>

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Animation not very smooth.

2016-11-06 Thread Nick H
Glad you were able to find a solution!

Elm WebGL support is primitive and unofficial. If you run into performance
issues, the culprit is probably the elm-webgl package and not the
underlying language/platform.

On Sun, Nov 6, 2016 at 4:56 AM, Gaëtan André  wrote:

> OK I solved my problem.
>
> Culling foodElements (little green circles) to the screen led to less
> webgl calls which solved the smoothness problem.
>
> Webgl api calls are costly. Maybe a a way to reduce the number of calls in
> my case could have been to use a geometry shader to instantiate multiple
> food elements. Anyway culling at application level works fine.
>
> Thanks for your help.
>
>
> Le samedi 5 novembre 2016 11:27:52 UTC+1, Gaëtan André a écrit :
>>
>> viewGrid was reworked as you suggested (cf. gist) but the the problem is
>> still the same.
>>
>> Sorry I had not share the cpu profiles from Chrome the first time, I do
>> it now. As you can see, the problem is that sometimes, a loop call takes a
>> lot longer than others to compute (because of gc it seems).
>>
>> On Chrome it is basically annoying but still playable, on Firefox it is
>> not playable.
>>
>> Thanks,
>>
>> Le jeudi 3 novembre 2016 02:33:35 UTC+1, Nick H a écrit :
>>>
>>> I am guessing your viewGrid function is slowing your code down. This
>>> function is creating a new mesh and passing it to the GPU on every
>>> animation frame.
>>>
>>> The solution is to make sure your WebGL.Drawable (line 465, where it
>>> says "GL.Lines gridPoints") is a constant. So extract that into its own
>>> top-level declaration, as you have done with "mesh."
>>>
>>> On Wed, Nov 2, 2016 at 1:30 PM, Gaëtan André 
>>> wrote:
>>>
 Hello everybody,

 I am working on cloning Agar.io (https://agar.io/) using functionnal
 languages.
 Everything was going well except that my cell movements are not very
 smooth.
 I first blamed the network connection, but after hacking a standalone
 front-end it seems like Elm might have something to do with it.

 From were I am, I don't know where to go to improve fluidity.

 I am subscribing to AnimationFrame.diffs to give the pace of the render
 loop.

 Here is a gist of my code:
 https://gist.github.com/rvlander/0b956d5d8d0a70f37f6206cb6f9af367

 Thanks,

 --
 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 elm-discuss...@googlegroups.com.
 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 elm-discuss+unsubscr...@googlegroups.com.
> 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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Uri encoding (Implementing /Programming Phoenix/ with Elm web sockets)

2016-11-06 Thread Brian Marick
TL/DR: What library do I use to convert `…##...=`   into   `...%23%...%3D`   in 
order to communicate with Elixir Phoenix via 
`ws://localhost:4000/socket/websocket?auth_token=...%23%...%3D` 
?

---

In the /Programming Phoenix/ book 
https://pragprog.com/book/phoenix/programming-phoenix 
, the sample app uses 
token-based authentication, with the client establishing its authenticity at 
connect-time, rather than at channel-joining time. Phoenix allows params to be 
passed at connect-time via `?foo=bar” format in the URI.  Neither 
fbonetti/elm-phoenix-socket nor NoRedInk/elm-phoenix seem to give you a way to 
do that, other than constructing the URI yourself. Which is OK - I can submit a 
pull request once I get it working. 

However, quick browsing through `package.elm-lang.org 
` doesn’t find me a quick library to do uri 
encoding. I find only 
https://github.com/williamwhitacre/elm-encoding/blob/master/Encoding/URL.elm 
 
, which is listed as not having been updated to 0.17. 

Am I overlooking a library, or should I try to port `elm-encoding`?

P.S. I know that I could deviate from the book and do the authentication at 
channel-join time, but I think it would be good for Elm if it were 
friction-free to work along with the book’s example, just using Elm instead of 
JS. 

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Uri encoding (Implementing /Programming Phoenix/ with Elm web sockets)

2016-11-06 Thread Brian Marick
Sigh. https://twitter.com/jessemcnelis  
pointed me to http://klaftertief.github.io/elm-search/?q=uriencode 
 - which works just fine. 

Sorry for the inconvenience.

> On Nov 6, 2016, at 6:23 PM, Brian Marick  wrote:
> 
> TL/DR: What library do I use to convert `…##...=`   into   `...%23%...%3D`   
> in order to communicate with Elixir Phoenix via 
> `ws://localhost:4000/socket/websocket?auth_token=...%23%...%3D` 
> ?
> 
> ---
> 
> In the /Programming Phoenix/ book 
> https://pragprog.com/book/phoenix/programming-phoenix 
> , the sample app uses 
> token-based authentication, with the client establishing its authenticity at 
> connect-time, rather than at channel-joining time. Phoenix allows params to 
> be passed at connect-time via `?foo=bar” format in the URI.  Neither 
> fbonetti/elm-phoenix-socket nor NoRedInk/elm-phoenix seem to give you a way 
> to do that, other than constructing the URI yourself. Which is OK - I can 
> submit a pull request once I get it working. 
> 
> However, quick browsing through `package.elm-lang.org 
> ` doesn’t find me a quick library to do uri 
> encoding. I find only 
> https://github.com/williamwhitacre/elm-encoding/blob/master/Encoding/URL.elm 
> 
>  , which is listed as not having been updated to 0.17. 
> 
> Am I overlooking a library, or should I try to port `elm-encoding`?
> 
> P.S. I know that I could deviate from the book and do the authentication at 
> channel-join time, but I think it would be good for Elm if it were 
> friction-free to work along with the book’s example, just using Elm instead 
> of JS. 
> 
> -- 
> 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 elm-discuss+unsubscr...@googlegroups.com 
> .
> 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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Probably a *very* basic question ...

2016-11-06 Thread dedo
Help! This is driving me crazy ... 

I have Python/flask at the back end, Elm at front. The landing page is, 
say, http://localhost:5000. 

My Html.App.program is set up with an init Cmd wrapped around a 

Http.get decoderA "localhost:5000/initialData" 

of back-end data, . That works fine, browser url stays at landing page.

My user next clicks a button and triggers a Cmd with a different callback, 
wrapped around

Http.get decoderB "localhost:5000/nextData/bar"

and this time the back-end call happens, the response comes back, the 
correct Msg is invoked, the right *update* state transition happens, and 
then -- spontaneously -- the URL bar goes to "localhost:5000/?" -- with the 
question mark -- and a spurious GET is sent to the back end, resetting the 
page to the initial.

Any ideas appreciated!

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Probably a *very* basic question ...

2016-11-06 Thread OvermindDL1
What are they clicking on?  Can you show a simplified example that 
demonstrates the issue?

What it sounds like though, it they are clicking maybe an "a" element that 
has a "src" attribute set and you are reacting to a message on it, that you 
are not preventing default?



On Sunday, November 6, 2016 at 8:08:04 PM UTC-7, dedo wrote:
>
> Help! This is driving me crazy ... 
>
> I have Python/flask at the back end, Elm at front. The landing page is, 
> say, http://localhost:5000. 
>
> My Html.App.program is set up with an init Cmd wrapped around a 
>
> Http.get decoderA "localhost:5000/initialData" 
>
> of back-end data, . That works fine, browser url stays at landing page.
>
> My user next clicks a button and triggers a Cmd with a different callback, 
> wrapped around
>
> Http.get decoderB "localhost:5000/nextData/bar"
>
> and this time the back-end call happens, the response comes back, the 
> correct Msg is invoked, the right *update* state transition happens, and 
> then -- spontaneously -- the URL bar goes to "localhost:5000/?" -- with the 
> question mark -- and a spurious GET is sent to the back end, resetting the 
> page to the initial.
>
> Any ideas appreciated!
>

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Probably a *very* basic question ...

2016-11-06 Thread Ian Mackenzie
Is the button inside a  that is causing it to trigger a form submission 
when clicked?

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Probably a *very* basic question ...

2016-11-06 Thread dedo
That was it, Ian. 

You just saved me from tearing the remaining 30% of my hair out.

Thanks!!!

On Sunday, November 6, 2016 at 9:49:10 PM UTC-6, Ian Mackenzie wrote:
>
> Is the button inside a  that is causing it to trigger a form 
> submission when clicked?

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] How do you test a TEA `update` function?

2016-11-06 Thread Francesco Orsenigo
How do you write unit tests to ensure that an `update : Msg -> Model -> ( 
Model, Cmd Msg )` function is producing the correct commands?
What if the function is supposed to produce several commands batched 
together?

Same thing for a `view : Model -> Html Msg`.
Suppose I want to test whether, given a particular model, it will display 
the correct number of list items.
Do people write tests for this?
Right now the only way to write this kind of tests I can think of is 
creating the whole html tree as I expect it to be rendered, and comparing 
it via == with the function output.

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: How do you test a TEA `update` function?

2016-11-06 Thread Simon
I've often worried about the commands bit.
For the view side, you need to test that you are deriving the right data to 
render, while it is Evan that needs to test that, given certain data, 
expected DOM elements get produced?

On Monday, 7 November 2016 07:44:36 UTC+1, Francesco Orsenigo wrote:
>
> How do you write unit tests to ensure that an `update : Msg -> Model -> ( 
> Model, Cmd Msg )` function is producing the correct commands?
> What if the function is supposed to produce several commands batched 
> together?
>
> Same thing for a `view : Model -> Html Msg`.
> Suppose I want to test whether, given a particular model, it will display 
> the correct number of list items.
> Do people write tests for this?
> Right now the only way to write this kind of tests I can think of is 
> creating the whole html tree as I expect it to be rendered, and comparing 
> it via == with the function output.
>

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.