[elm-discuss] Re: Announcing elm-lang/navigation for "routing in single-page apps"

2016-05-25 Thread Emilien Taque
AFAIK There isn't any circularity problem where you consider browser 
location as the reference, push changes to it through history API and let 
it flow from here through your app.

Le jeudi 26 mai 2016 06:59:05 UTC+2, Ryan Rempel a écrit :
>
> Ah, it is good to know that, in the transition from signals to 
> subscriptions, our old friend, the initial value, has not ceased to be 
> special!
>
> --
> Ryan Rempel
>

-- 
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: Announcing elm-lang/navigation for "routing in single-page apps"

2016-05-25 Thread Ryan Rempel
Ah, it is good to know that, in the transition from signals to subscriptions, 
our old friend, the initial value, has not ceased to be special!

--
Ryan Rempel

-- 
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] Re: what's the preferred way to implement the submit mentioned in elm guide?

2016-05-25 Thread Magnus Rundberget
Looks a lot better to me, nice and testable too ! 

- You could consider having Error as a generic tag and let it take a  String. 
That way you could populate with an error message in your validate function. 
That would make the viewValidation function slightly simpler.

Btw you probably don't want to print out the password when displaying the error 
msg :-) sort of defeats the purpose of using input type password to hide it.

-- 
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: Announcing elm-lang/navigation for "routing in single-page apps"

2016-05-25 Thread Magnus Rundberget
Tx for this !


The final piece I've been waiting for before upgrading one of my apps. I 
think I'll go ahead and rip out the existing router package I'm using 
(which has served me well enough btw) and see if I can't manage fine with 
just these two building block.

shame it's 01:30 over here, but there's always tomorrow :-)

cheers
-magnus



On Thursday, 26 May 2016 00:02:03 UTC+2, Evan wrote:
>
> On Friday, Noah and I worked on "updating elm-history" so that folks can 
> do "routing" with Elm 0.17. The results are these libraries:
>
>- elm-lang/navigation 
>
>- evancz/url-parser 
>
>
> I think they will cover the core functionality in a way that also promotes 
> healthy architecture. If you disagree, I ask that you *use* these 
> libraries before you share your opinion (or ideally the particular scenario 
> you are having trouble with).
>
>
> Details
>
> The elm-lang/navigation library is the core thing. It lets you get 
> notified about changes to the address bar. This may be the user typing in 
> there or pressing the forward and back buttons on the browser. It also lets 
> you "navigate to new URLs" so you can go to new URLs without reloading any 
> assets.
>
> The elm-lang/navigation library is designed such that you can parse URLs 
> however you want. You can see a basic example of that here 
> . The 
> evancz/url-parser library is meant to handle more complex cases. You can 
> see a bit of that in this example 
> .
>
> My URL parser is intended to be a baseline for exploration. There are 
> probably cases it does not cover well. My goal right now is to point us 
> towards good API design, not to be *the* URL parser.
>
>
> Thanks
>
> Big thanks to Noah for working through all this with me! And thank you to 
> Aaron who helped review and talk through the API we ended up with. These 
> were fun to work on :D
>

-- 
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] Announcing elm-lang/navigation for "routing in single-page apps"

2016-05-25 Thread Evan Czaplicki
On Friday, Noah and I worked on "updating elm-history" so that folks can do
"routing" with Elm 0.17. The results are these libraries:

   - elm-lang/navigation
   
   - evancz/url-parser
   

I think they will cover the core functionality in a way that also promotes
healthy architecture. If you disagree, I ask that you *use* these libraries
before you share your opinion (or ideally the particular scenario you are
having trouble with).


Details

The elm-lang/navigation library is the core thing. It lets you get notified
about changes to the address bar. This may be the user typing in there or
pressing the forward and back buttons on the browser. It also lets you
"navigate to new URLs" so you can go to new URLs without reloading any
assets.

The elm-lang/navigation library is designed such that you can parse URLs
however you want. You can see a basic example of that here
. The
evancz/url-parser library is meant to handle more complex cases. You can
see a bit of that in this example
.

My URL parser is intended to be a baseline for exploration. There are
probably cases it does not cover well. My goal right now is to point us
towards good API design, not to be *the* URL parser.


Thanks

Big thanks to Noah for working through all this with me! And thank you to
Aaron who helped review and talk through the API we ended up with. These
were fun to work on :D

-- 
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: proof of concept share/import feature for elm-lang.org/try

2016-05-25 Thread Fernando Alegre

FWIW, I'd definitely want such feature. I think it is really useful for my 
use cases (schools and such).


On Wednesday, May 25, 2016 at 11:29:21 AM UTC-5, Matteo Bertini wrote:
>
> I have a proof of concept share/import feature for elm-lang.org/try
>
> It uses the location.hash trick as in play.rust, was so simple I'm now 
> thinking that this is perhaps an unwanted feature.
>
> Here is the patch:
> https://github.com/elm-lang/elm-lang.org/commit/cd735fb82955dd86579f0350e74d0beb5b481d93
>  
> if there is some interest I can make a pull request and refine it (add a 
> shortener and a length check, for example).
>
> Cheers,
> Matteo
>
> PS
> the branch is hacked to work opening locally the prova/index.html file.
>

-- 
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] Nested components and async JS via ports

2016-05-25 Thread Simon


I have something like

type Msg = ParentMsg Id Child.Msg

My data is in Dicts and my views look like

Dict.map \i v -> Child.view v |> Html.map (ParentMsg i)

On Wednesday, 25 May 2016 15:05:34 UTC+2, Erik Simmler wrote:

I have a rather gross implementation of what I'm hoping to achieve. I don't 
> really see a way to do this without writing Native code, which is highly 
> unfortunate: https://github.com/tgecho/elm-custom-task-example
>
> On Friday, May 20, 2016 at 2:03:42 PM UTC-4, Erik Simmler wrote:
>>
>> Thanks! ...but I don't think I explained my question very well. I'll try 
>> to come up with some sort of explanatory sample code when I have some time 
>> back at my computer, but in the meantime...
>>
>> In your sample, you're only nesting the component once. In my case I have 
>> more than one child of the same type (e.g. the nested counter/gif 
>> examples). I'm looking for a good way to return a Cmd from a child to 
>> javascript through a port, do some async work in JS and route a Msg with 
>> the result back to the same child.
>>
>> The Gif/Http/Task workflow seems to be really close to the result I want 
>> which is why I brought it up.
>>
>>
>> On Friday, May 20, 2016 at 12:57:38 PM UTC-4, Peter Damoc wrote:
>>>
>>> Keep your ports in one file and import that file throughout your 
>>> project. 
>>>
>>> Here is a gist with a simple example:
>>> https://gist.github.com/pdamoc/bf346e232ae2466923c18101122e3690
>>>
>>> download and  
>>>
>>> $ elm-make Main.elm --output elm.js
>>>
>>> agree to the install of the packages and after the elm.js is produced, 
>>> open index.html
>>>
>>> you should be able to see the classic counter and it should work as 
>>> expected with one small change, the update of the counter is done with a 
>>> round trip through JS. 
>>>
>>> The way I've set up this to work is by creating a port `toJS` where I 
>>> send String 
>>> in index.html, I check to see if the String is "Increment" and send back 
>>> through `fromJS` either +1 or -1 
>>>
>>> In Component I subscribe to `fromJS` and feed this +1 or -1 back into 
>>> the counter update. 
>>>
>>> As you can notice in Main... there is no knowledge in the parent about 
>>> what the Component is actually doing. All the parent does is map things and 
>>> pass around messages just like in any other regular Elm Architecture thing. 
>>>
>>> One last thing. Please note in Ports.elm that the Cmd and Sub you have 
>>> there are generic. 
>>>
>>> This way, the Ports.elm doesn't need to import anything. 
>>> Also, as I've demonstrated in Main.elm you can subscribe to those ports 
>>> from other parts of the App, even with different purposes. I've subscribed 
>>> in Main just to snoop on what's going on there. :) 
>>>
>>>
>>>
>>> On Fri, May 20, 2016 at 5:59 PM, Erik Simmler  wrote:
>>>
 Does anyone have a good pattern for handling multiple nested components 
 that need to communicate with JS via ports/subscriptions?

 I have a list of items, and I'm trying to allow any of these children 
 to send a message through a port and receive the result back via a 
 subscription. I have the outgoing port and incoming subscription wired up 
 and functioning (using `Sub.batch` similarly to 
 https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/4-gif-list.elm#L150),
  
 but any message I get back through the port from JS land is duplicated for 
 each child.

 Furthermore, I can't come up with a nice way to get them tagged and 
 directly properly without moving the ports up to the containing component 
 and "manually" wrapping/unwrapping the commands and messages, which seems 
 like an unfortunate level of coupling.

 In the elm-architecture-tutorial repo, the Gif component requests a new 
 url by returning a command created by `getRandomGif` (
 https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/Gif.elm#L53).
  
 In the second nesting example, the only relevant place that I can see any 
 mapping occurring is the usual `Cmd.map` at 
 https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/4-gif-list.elm#L93.
  
 Yet, when the `FetchSucceed` comes back, it is properly wrapped in a 
 `SubMsg Int` message.

 This seems to be exactly what I want, but I can't figure out how it 
 works. How I can replicate this effect on my own or am I just barking up 
 the wrong tree? 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.

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

-- 
You received this message because you are subscribed to the Google 

[elm-discuss] proof of concept share/import feature for elm-lang.org/try

2016-05-25 Thread Matteo Bertini
 I have a proof of concept share/import feature for elm-lang.org/try

It uses the location.hash trick as in play.rust, was so simple I'm now 
thinking that this is perhaps an unwanted feature.

Here is the patch:
https://github.com/elm-lang/elm-lang.org/commit/cd735fb82955dd86579f0350e74d0beb5b481d93
 
if there is some interest I can make a pull request and refine it (add a 
shortener and a length check, for example).

Cheers,
Matteo

PS
the branch is hacked to work opening locally the prova/index.html file.

-- 
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] Trigger child action from parent

2016-05-25 Thread Peter Damoc
There are two basic patterns that I've seen:

You keep the child oblivious to parent actions and just extend the update
signature to signify that it sends something upstream

update : Msg -> Model -> (Model, Cmd Msg, Upstream)

Here is an example of this:
https://github.com/pdamoc/elm-architecture-tutorial/blob/master/examples/4/Counter.elm

OR

you use a Context for a specialized view that talks in the language of the
parent/ancestor

type alias Context parentMsg =
{ toParent : Msg -> parentMsg
, someActionName : parentMsg
...
}

viewWithContext : Context parentMsg -> Model -> Html parentMsg


e.g. Here is the Counter view:

type alias Context parentMsg =
{ toParent : Msg -> parentMsg
, remove : parentMsg
}

view : Model -> Html Msg
view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [ countStyle ] [ text (toString model) ]
, button [ onClick Increment ] [ text "+" ]
]

viewWithContext : Context parentMsg -> Model -> Html parentMsg
viewWithContext context model =
div []
[ App.map context.toParent (view model)
, button [ onClick context.remove ] [ text "X" ]
]

and in the parent (CounterList) you do something like

viewCounter (id, model) =
Counter.viewWithContext (Counter.Context (Modify id) (Remove id) ) model


view model =
div [] (List.map viewCounter model.counters)





On Tue, May 24, 2016 at 7:27 PM, TheGryzor123  wrote:

> I created a child component that is supposed to display notifications
> coming from the parent.
>
> I know how to initialize and listen to a child but here I would like to
> tell him to execute actions for me.
>
> What do you suggest me to do?
>
> --
> 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.
>



-- 
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.


Re: [elm-discuss] Accessing Elm Reactor on EC2

2016-05-25 Thread Devendra Gera
Another approach could be to use SSH port forwarding, like:

ssh -L localhost:8000:localhost:8000 youru...@your.ec2.host

and access elm-reactor at http://localhost:8000 on your machine, while
the above ssh session is up. This has the advantage of not exposing
elm-reactor to the world, and it works even if your home IP address
changes.

Cheers,
--gera.

On Wed, May 25, 2016 at 10:58 AM, Matthew Bray  wrote:
> Two things:
>
> * Ask elm-reactor to bind to all addresses, not just localhost, using
> "elm-reactor -a 0.0.0.0".
> * On EC2, for your instance's security group, make sure there is a rule
> allowing inbound TCP traffic on port 8000.
>
> Note that you incur the (small?) risk of someone exploiting an unknown
> vulnerability in elm-reactor to take over your server - remember elm-reactor
> is just a development tool.  You can mitigate this by only allowing access
> via your home IP address in the security group rule.
>
> On Wed, 25 May 2016 at 09:35 Stephen Oates 
> wrote:
>>
>> I am wondering how to access the Elm-Reactor when the server is remote? I
>> have installed elm and run "elm-reactor" but when I go to my EC2s instace
>> address on port 8000 I cannot connect to anything. I have checked the port
>> settings and even tried changing them but no luck.
>>
>> Does anyone have any suggestions on what I need to do?
>>
>> --
>> 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.

-- 
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] Accessing Elm Reactor on EC2

2016-05-25 Thread Stephen Oates
Thanks so much Matt!

On Wednesday, 25 May 2016 18:58:23 UTC+10, Matt Bray wrote:
>
> Two things:
>
> * Ask elm-reactor to bind to all addresses, not just localhost, using 
> "elm-reactor -a 0.0.0.0".
> * On EC2, for your instance's security group, make sure there is a rule 
> allowing inbound TCP traffic on port 8000.
>
> Note that you incur the (small?) risk of someone exploiting an unknown 
> vulnerability in elm-reactor to take over your server - remember 
> elm-reactor is just a development tool.  You can mitigate this by only 
> allowing access via your home IP address in the security group rule.
>
> On Wed, 25 May 2016 at 09:35 Stephen Oates  > wrote:
>
>> I am wondering how to access the Elm-Reactor when the server is remote? I 
>> have installed elm and run "elm-reactor" but when I go to my EC2s instace 
>> address on port 8000 I cannot connect to anything. I have checked the port 
>> settings and even tried changing them but no luck.
>>
>> Does anyone have any suggestions on what I need to do?
>>
>> -- 
>> 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.


Re: [elm-discuss] Accessing Elm Reactor on EC2

2016-05-25 Thread Matthew Bray
Two things:

* Ask elm-reactor to bind to all addresses, not just localhost, using
"elm-reactor -a 0.0.0.0".
* On EC2, for your instance's security group, make sure there is a rule
allowing inbound TCP traffic on port 8000.

Note that you incur the (small?) risk of someone exploiting an unknown
vulnerability in elm-reactor to take over your server - remember
elm-reactor is just a development tool.  You can mitigate this by only
allowing access via your home IP address in the security group rule.

On Wed, 25 May 2016 at 09:35 Stephen Oates 
wrote:

> I am wondering how to access the Elm-Reactor when the server is remote? I
> have installed elm and run "elm-reactor" but when I go to my EC2s instace
> address on port 8000 I cannot connect to anything. I have checked the port
> settings and even tried changing them but no luck.
>
> Does anyone have any suggestions on what I need to do?
>
> --
> 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.


Re: [elm-discuss] Making new Cmds

2016-05-25 Thread Wil C
That worked, thanks. I guess I should hold off telling people stuff.

Wil

On Wednesday, May 25, 2016 at 12:00:48 AM UTC-7, Janis Voigtländer wrote:
>
> Task.perform never identity (Task.succeed NewMsg)
>
> with never from 
> http://package.elm-lang.org/packages/elm-community/basics-extra
> ​
>
> 2016-05-25 8:53 GMT+02:00 Wil C :
>
>> It turns out it doesn't. What's the correct way to do this?
>>
>> Wil
>>
>> On Tuesday, May 24, 2016 at 10:48:33 AM UTC-7, Janis Voigtländer wrote:
>>>
>>> This is not doing what you almost certainly think it does.
>>> ​
>>>
>>> 2016-05-24 18:44 GMT+02:00 Wil C :
>>>
 It's just an aside, in case someone searches for it. Here's how to make 
 new commands:

 Cmd.map (\_ -> NewMsg) Cmd.none

 It wasn't obvious to me.

 Wil

 -- 
 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...@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.


Re: [elm-discuss] Elm 0.16 access

2016-05-25 Thread Peter Damoc
Hi Mark,

Elm is in development and minor releases can still break things in a big
way.
This is what happened with the switch from 0.16 to 0.17.
This release got rid of Signals which have been with Elm since its
conception.

Lua's development is in a different stage where you can do minor releases
without big changes and you can still use most of the old code unchanged.

I empathize with the sensation of someone puling the rug from under you
and, having gone through several porting sessions I can tell you that it
looks worst than it actually is.
I'm grateful for the changes made with 0.17 and I personally believe that
something of this magnitude will never happen again in Elm.

Keeping 0.16 available risks delaying further development because resources
would have to be split and allocated to maintaining that branch. Elm is way
too young to afford that kind of split.

That being said, the guide is getting better every day, Evan's tutorials
 already describe a
lot of the functionality in the new paradigm and tutorials/examples from
other people keep popping up.

0.17 is a good time to board the Elm train. :)



On Tue, May 24, 2016 at 7:26 PM, Mark Hamburg  wrote:

> I was talking with coworkers about my team's experiments with Elm and I
> found myself having to blunt their interest because of the current state of
> Elm 0.17 — documentation still has holes, tutorials haven't had a chance to
> arise, some functionality is still missing relative to 0.16, etc. This
> wouldn't have been a problem in some other languages I've advocated for in
> the past — e.g., Lua — because I could have said "Elm 0.17 is out and it
> looks like a big step forward. However, some pieces are missing and there
> isn't a lot of material about it yet, so depending on what you want to do,
> you may find it easier right now to start with 0.16 while the community
> transitions." Except I can't really say that because access to 0.16 has
> become much harder. For example, one can no longer just go to the web site
> and browse the documentation for 0.16. (Or if one can, it's pretty buried.)
> Contrast this with Lua where the 5.1 (released in 2006) reference manual is
> available at online at lua.org and older versions are available as
> archives. This leaves me with a problem when it comes to advocating for Elm
> and when I explain the situation to people their response is along the
> lines of suggesting that the Elm community can't be trusted not to pull the
> rug out from under one.
>
> So, while I'm mostly interested in seeing 0.17 get fleshed out, I think
> having a link on the front page of elm-lang.org that would take one back
> to the 0.16 world would be a good thing while 0.17 matures.
>
> Mark
>
> --
> 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.
>



-- 
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.