Re: [elm-discuss] why Cmd Msg named as Cmd Msg?

2016-05-31 Thread Peter Damoc
Cmd is short for Command.

This is similar to an envelope you return to the postman. You are not
actually doing the sending, you are just returning it to the postman. It is
the job of the postman (runtime) to do something with it. They might send
it or they might trash it based on some criteria.

Cmd Msg just says that if executed, this command will produce a Msg and
that Msg will get back into the Elm Architecture.

If you are coming from an imperative language, it is very important to
understand that in Elm programs nothing gets "sent" or "done" or whatever
imperative word might come into your mind. Everything is data and
everything is evaluated to some form of data.

Some of this data, like Cmd, contains instruction for execution and the
runtime will be able to use these instructions to actually do the things
you want (like requesting something from a server) but all this happens in
the runtime not in you program.



On Wed, Jun 1, 2016 at 7:51 AM, 诺铁  wrote:

> hi,
>
> at first, Cmd Msg seems to me like sending a Msg out as a Cmd, but after a
> while I understand it's saying: we send a request to something, and will
> get back a Msg in the future.  seems similar to Future Msg in some other
> languages.
>
> what doesn't the name "Cmd" mean here?
>
> --
> 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.


[elm-discuss] why Cmd Msg named as Cmd Msg?

2016-05-31 Thread 诺铁
hi,

at first, Cmd Msg seems to me like sending a Msg out as a Cmd, but after a
while I understand it's saying: we send a request to something, and will
get back a Msg in the future.  seems similar to Future Msg in some other
languages.

what doesn't the name "Cmd" mean here?

-- 
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: Discussion on improving Graphics.Collage

2016-05-31 Thread Aaron VonderHaar
Graphics was moved out of core because no one has been maintaining it for
quite a while.  If someone were to start updating it again, I think it
wouldn't take much convincing to get it included in the available packages
on elm-lang/try again.

On Sun, May 29, 2016 at 11:13 AM, Fernando Alegre  wrote:

>
> Rex: I totally concur. The move of Collage and Element out of the core was
> sad, since it no longer works in elm-lang/try. We lost a great showcase for
> Elm, especially when trying to attract people who are NOT web developers,
> which comprises the overwhelming majority of the population.
>
> Elm was great for non-developers. Elm can be great for Web developers too,
> but that should not mean stopping making it really easy for the former.
>
>
>
> On Monday, June 22, 2015 at 5:41:49 PM UTC-5, Hassan Hayat wrote:
>>
>> New thread by Max's suggestions:
>> https://groups.google.com/d/msg/elm-discuss/ltH5a9dGu1g/dTVSD6h-qTMJ
>>
>> I think that Graphics.Collage is super valuable but it is kinda old and
>> could use a good re-vamp. I don't think I'm the only one with this opinion,
>> so I hope no one minds if I start this discussion. But, before going
>> forward with the discussion, I think it's important to ask what are the
>> goals of the library?
>>
>> 1) Is it to introduce newcomers to Elm?
>> 2) Is it to make 2D games?
>> 3) Is it to replace CSS?
>> 4) Other?
>>
>>
>> The answer to this question could lead Graphics.Collage down different
>> paths.
>>
>> For example, now with the Turtle Graphics library
>> ,
>> wouldn't it be better to shift the focus there for educational purposes?
>>
>> But, that said, if Graphics.Collage is to support 2D Game Development,
>> then there are a bunch of things needed like (webgl first canvas fallback
>> renderer, better image manipulation, first-class support for particle and
>> lighting effects, etc...). Wouldn't that make things just more complicated
>> to the point that a 2D graphics renderer made for games should really just
>> be a third party library?
>>
>>
>> --
> 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] Re: Another noob question: blank page when opening html file on localhost

2016-05-31 Thread pcarbonn
OK. I finally fixed it by deleting the elm-stuff subdirectory...  At the 
next make, it reinstalled the missing packages, and it worked fine.


On Tuesday, May 31, 2016 at 10:10:37 PM UTC+2, pcarbonn wrote:
>
> Hi all,
>
> I have a similar problem as Bernd Blasius, on Windows, and I found this 
> old thread below while searching for a solution : could someone help me ? 
>  I have posted my full problem on StackOverflow 
> .
>  
>  You can find all details there.  It's my first elm program, so any help 
> would be appreciated !
>
> Thanks in advance,
> PC
>
>
> On Saturday, September 14, 2013 at 7:22:25 PM UTC+2, Alex Neslusan wrote:
>>
>> Oh, or I'm being dumb and you clearly said Ubuntu
>>
>> On Sunday, September 15, 2013 1:21:28 AM UTC+8, Alex Neslusan wrote:
>>>
>>> I'm guessing you're using Windows. Windows file linking is a bit 
>>> different, you need a file:/// prefix. For example, when I'm on my Windows 
>>> 7 computer, and I type "elm Test.elm", it generates the Test.html file in 
>>> /build. If I open Test.html in my text editor, I can see this line near the 
>>> top:
>>>
>>> 

[elm-discuss] Re: Another noob question: blank page when opening html file on localhost

2016-05-31 Thread pcarbonn
Hi all,

I have a similar problem as Bernd Blasius, on Windows, and I found this old 
thread below while searching for a solution : could someone help me ?  I 
have posted my full problem on StackOverflow 
.
 
 You can find all details there.  It's my first elm program, so any help 
would be appreciated !

Thanks in advance,
PC


On Saturday, September 14, 2013 at 7:22:25 PM UTC+2, Alex Neslusan wrote:
>
> Oh, or I'm being dumb and you clearly said Ubuntu
>
> On Sunday, September 15, 2013 1:21:28 AM UTC+8, Alex Neslusan wrote:
>>
>> I'm guessing you're using Windows. Windows file linking is a bit 
>> different, you need a file:/// prefix. For example, when I'm on my Windows 
>> 7 computer, and I type "elm Test.elm", it generates the Test.html file in 
>> /build. If I open Test.html in my text editor, I can see this line near the 
>> top:
>>
>> 

Re: [elm-discuss] Managing global state in Elm

2016-05-31 Thread Peter Damoc
The updating of the cache sounds to me like this:

1. if we have the info in cache, just supply the info without a HTTP GET
2. if we don't have the info in cache, return a different Msg that
encapsulates the msg that requested the original information and the info
required for the cache update.

Here is a quick update of the code I've previously posted to include this
caching mechanism.

https://gist.github.com/pdamoc/d492ab58023926cd4d4950f12e5e170d




On Tue, May 31, 2016 at 10:05 PM, James Wilson  wrote:

> The key part that's not coded in the gist is the use of a cache/global
> state object, however I think I  see what you're getting at - pass back up
> the chain a Req object, say, and at the top we can turn it into a Cmd
> using, say, some top level global state as well as whatever other data we
> need. This may lead to a request being made to the server or it may not.
>
> The other part of the puzzle is actually updating the cache when a request
> is made. Req.toCmd for instance could return an updated GlobalState so that
> it's able to cache "pending" states on values (so that we can avoid
> duplicating requests). To update the cache when the response actually comes
> in we could have toCmd return a Cmd.batch of 2 commands, one that will
> fail/succeed and send a message to the component that initiated the Req,
> and one that will send a message aimed at the top level cache itself.
>
> Thanks Peter, I'll definitely mull over this!
>
> On Tuesday, 31 May 2016 19:45:42 UTC+1, Peter Damoc wrote:
>>
>> ADT in Elm is one of its most powerful weapons.
>>
>> You could encapsulate your requests in a type and use this type at top
>> level to fulfill them.
>>
>> For example: instead of returning Cmd msg you return some Req msg that
>> can be turned into a Cmd msg at top level based on some context
>> information.
>>
>> Here is a gist with a skeleton of how I view this implemented:
>> https://gist.github.com/pdamoc/a47090e69b75433efa60fe4f70e6a06a
>>
>> I've sent the base of the URL as a simple String in `Req.toCmd` but you
>> can imagine a more complex type holding all kind of information (e.g.
>> cache, auth, etc ) .
>> Also, I've kept the type of the Req simple (only saved the rest of the
>> URL based on the user and the request) but one could use it to store all
>> the info needed when you will turn the Req into a Cmd.
>>
>>
>>
>>
>>
>>
>> On Tue, May 31, 2016 at 7:29 PM, James Wilson  wrote:
>>
>>> In Elm, each component basically has its own internal state (which is
>>> actually all just a slice of one global model). In my app, I also want
>>> global state that is independant of any components; for example a
>>> clientside cache of various API responses (asset details - there could be
>>> many thousands, user authentication status).
>>>
>>> I want any component to be able to call methods that make use of this
>>> global state. For example, a method to obtain details for items in the
>>> current view might first look at the global state to see if these items are
>>> cached. If they arent, the call would provide a Cmd to be issued that gets
>>> the items (and puts them in the cache), while simultaneously updating the
>>> state to indicate that they are being loaded (so that the same request
>>> again from another component doesnt trigger another call to the backend).
>>> If they are cached, they can be easily returned from there. A first shot at
>>> a signature might look something like:
>>>
>>> getItem : GlobalState -> ID -> Tag -> (GlobalState, Cmd msg)
>>>
>>>
>>>
>>> However we could partially apply functions that exist on some
>>> globalState instantiation to hdie the initial state being passed in and end
>>> up with:
>>>
>>> state.items.getItem : ID -> Tag -> (GlobalState, Cmd msg)
>>>
>>>
>>>
>>> The downside of this approach is that I have to thread this state
>>> through multiple calls that might make use of it, and thread it back up
>>> explicitly through the update functions to get it back to the top. At the
>>> top we'd then have something like (excuse any mistakes!):
>>>
>>> update msg model = case msg of
>>>SubMsg m ->
>>>  let (newSubModel, subCmds, newGlobalState) = SubComponent.update m
>>> model.subModel
>>>  in ({ model | state = newGlobalState, subModel = newSubModel}, Sub.map
>>> SubMsg subCmds)
>>>...
>>>
>>>
>>> An alternative approach is to hold this global state in an effect
>>> manager, and so in the app you'd end up using the Cmd/Sub mechanism to ask
>>> for things from the state and internally initiate API requests to update
>>> the state as necessary. We'd end up with an API more like:
>>>
>>> getItem : ID -> Tag -> Cmd msg
>>>
>>>
>>> or
>>>
>>> state.items.getItem : ID -> Tag -> Cmd msg
>>>
>>>
>>> where the returned Cmd would either lead to an item being sent to the
>>> component immediately via a cache (where Tag is a Msg type the component
>>> knows about) or after it was obtained via some backend. This would make all
>>> retrieving of state async but seem

Re: [elm-discuss] Managing global state in Elm

2016-05-31 Thread James Wilson
The key part that's not coded in the gist is the use of a cache/global 
state object, however I think I  see what you're getting at - pass back up 
the chain a Req object, say, and at the top we can turn it into a Cmd 
using, say, some top level global state as well as whatever other data we 
need. This may lead to a request being made to the server or it may not.

The other part of the puzzle is actually updating the cache when a request 
is made. Req.toCmd for instance could return an updated GlobalState so that 
it's able to cache "pending" states on values (so that we can avoid 
duplicating requests). To update the cache when the response actually comes 
in we could have toCmd return a Cmd.batch of 2 commands, one that will 
fail/succeed and send a message to the component that initiated the Req, 
and one that will send a message aimed at the top level cache itself.

Thanks Peter, I'll definitely mull over this!

On Tuesday, 31 May 2016 19:45:42 UTC+1, Peter Damoc wrote:
>
> ADT in Elm is one of its most powerful weapons. 
>
> You could encapsulate your requests in a type and use this type at top 
> level to fulfill them. 
>
> For example: instead of returning Cmd msg you return some Req msg that can 
> be turned into a Cmd msg at top level based on some context information. 
>
> Here is a gist with a skeleton of how I view this implemented:
> https://gist.github.com/pdamoc/a47090e69b75433efa60fe4f70e6a06a
>
> I've sent the base of the URL as a simple String in `Req.toCmd` but you 
> can imagine a more complex type holding all kind of information (e.g. 
> cache, auth, etc ) . 
> Also, I've kept the type of the Req simple (only saved the rest of the URL 
> based on the user and the request) but one could use it to store all the 
> info needed when you will turn the Req into a Cmd. 
>
>
>
>
>
>
> On Tue, May 31, 2016 at 7:29 PM, James Wilson  > wrote:
>
>> In Elm, each component basically has its own internal state (which is 
>> actually all just a slice of one global model). In my app, I also want 
>> global state that is independant of any components; for example a 
>> clientside cache of various API responses (asset details - there could be 
>> many thousands, user authentication status).
>>
>> I want any component to be able to call methods that make use of this 
>> global state. For example, a method to obtain details for items in the 
>> current view might first look at the global state to see if these items are 
>> cached. If they arent, the call would provide a Cmd to be issued that gets 
>> the items (and puts them in the cache), while simultaneously updating the 
>> state to indicate that they are being loaded (so that the same request 
>> again from another component doesnt trigger another call to the backend). 
>> If they are cached, they can be easily returned from there. A first shot at 
>> a signature might look something like:
>>
>> getItem : GlobalState -> ID -> Tag -> (GlobalState, Cmd msg)
>>
>>
>>
>> However we could partially apply functions that exist on some globalState 
>> instantiation to hdie the initial state being passed in and end up with:
>>
>> state.items.getItem : ID -> Tag -> (GlobalState, Cmd msg)
>>
>>
>>
>> The downside of this approach is that I have to thread this state through 
>> multiple calls that might make use of it, and thread it back up explicitly 
>> through the update functions to get it back to the top. At the top we'd 
>> then have something like (excuse any mistakes!):
>>
>> update msg model = case msg of
>>SubMsg m ->
>>  let (newSubModel, subCmds, newGlobalState) = SubComponent.update m 
>> model.subModel
>>  in ({ model | state = newGlobalState, subModel = newSubModel}, Sub.map 
>> SubMsg subCmds)
>>...
>>
>>
>> An alternative approach is to hold this global state in an effect 
>> manager, and so in the app you'd end up using the Cmd/Sub mechanism to ask 
>> for things from the state and internally initiate API requests to update 
>> the state as necessary. We'd end up with an API more like:
>>
>> getItem : ID -> Tag -> Cmd msg
>>
>>
>> or
>>
>> state.items.getItem : ID -> Tag -> Cmd msg
>>
>>
>> where the returned Cmd would either lead to an item being sent to the 
>> component immediately via a cache (where Tag is a Msg type the component 
>> knows about) or after it was obtained via some backend. This would make all 
>> retrieving of state async but seems to simplify the interface (perhaps at 
>> the cost of more complexity in implementing the effect manager).
>>
>> Which approach do people think is best for working with global state 
>> (neither is an option if you have a better way!)? Do you get away with not 
>> needing this kind of thing (and if so, how)? I'd love to hear back, 
>> especially from those that have had experience building larger apps in Elm!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails fro

Re: [elm-discuss] Managing global state in Elm

2016-05-31 Thread Peter Damoc
ADT in Elm is one of its most powerful weapons.

You could encapsulate your requests in a type and use this type at top
level to fulfill them.

For example: instead of returning Cmd msg you return some Req msg that can
be turned into a Cmd msg at top level based on some context information.

Here is a gist with a skeleton of how I view this implemented:
https://gist.github.com/pdamoc/a47090e69b75433efa60fe4f70e6a06a

I've sent the base of the URL as a simple String in `Req.toCmd` but you can
imagine a more complex type holding all kind of information (e.g. cache,
auth, etc ) .
Also, I've kept the type of the Req simple (only saved the rest of the URL
based on the user and the request) but one could use it to store all the
info needed when you will turn the Req into a Cmd.






On Tue, May 31, 2016 at 7:29 PM, James Wilson  wrote:

> In Elm, each component basically has its own internal state (which is
> actually all just a slice of one global model). In my app, I also want
> global state that is independant of any components; for example a
> clientside cache of various API responses (asset details - there could be
> many thousands, user authentication status).
>
> I want any component to be able to call methods that make use of this
> global state. For example, a method to obtain details for items in the
> current view might first look at the global state to see if these items are
> cached. If they arent, the call would provide a Cmd to be issued that gets
> the items (and puts them in the cache), while simultaneously updating the
> state to indicate that they are being loaded (so that the same request
> again from another component doesnt trigger another call to the backend).
> If they are cached, they can be easily returned from there. A first shot at
> a signature might look something like:
>
> getItem : GlobalState -> ID -> Tag -> (GlobalState, Cmd msg)
>
>
>
> However we could partially apply functions that exist on some globalState
> instantiation to hdie the initial state being passed in and end up with:
>
> state.items.getItem : ID -> Tag -> (GlobalState, Cmd msg)
>
>
>
> The downside of this approach is that I have to thread this state through
> multiple calls that might make use of it, and thread it back up explicitly
> through the update functions to get it back to the top. At the top we'd
> then have something like (excuse any mistakes!):
>
> update msg model = case msg of
>SubMsg m ->
>  let (newSubModel, subCmds, newGlobalState) = SubComponent.update m
> model.subModel
>  in ({ model | state = newGlobalState, subModel = newSubModel}, Sub.map
> SubMsg subCmds)
>...
>
>
> An alternative approach is to hold this global state in an effect manager,
> and so in the app you'd end up using the Cmd/Sub mechanism to ask for
> things from the state and internally initiate API requests to update the
> state as necessary. We'd end up with an API more like:
>
> getItem : ID -> Tag -> Cmd msg
>
>
> or
>
> state.items.getItem : ID -> Tag -> Cmd msg
>
>
> where the returned Cmd would either lead to an item being sent to the
> component immediately via a cache (where Tag is a Msg type the component
> knows about) or after it was obtained via some backend. This would make all
> retrieving of state async but seems to simplify the interface (perhaps at
> the cost of more complexity in implementing the effect manager).
>
> Which approach do people think is best for working with global state
> (neither is an option if you have a better way!)? Do you get away with not
> needing this kind of thing (and if so, how)? I'd love to hear back,
> especially from those that have had experience building larger apps in Elm!
>
> --
> 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.


[elm-discuss] Re: Managing global state in Elm

2016-05-31 Thread Simon
This is an interesting question and important for larger apps. 

In the instance I am working on I plan to use a cache, and have implemented 
the idea in one of the components so far. I have the relevant top level 
component monitor for events in sub-components triggering messages that 
require the cache to be supplemented, handling the downloading, and then 
routing the result to the cache. I pass the cache down through my view 
functions alongside the relevant section of the overall model, and the view 
function shows a holding statement for as long as the cache cannot provide 
content.

 Simon

On Tuesday, 31 May 2016 18:29:44 UTC+2, James Wilson wrote:
>
> In Elm, each component basically has its own internal state (which is 
> actually all just a slice of one global model). In my app, I also want 
> global state that is independant of any components; for example a 
> clientside cache of various API responses (asset details - there could be 
> many thousands, user authentication status).
>
> I want any component to be able to call methods that make use of this 
> global state. For example, a method to obtain details for items in the 
> current view might first look at the global state to see if these items are 
> cached. If they arent, the call would provide a Cmd to be issued that gets 
> the items (and puts them in the cache), while simultaneously updating the 
> state to indicate that they are being loaded (so that the same request 
> again from another component doesnt trigger another call to the backend). 
> If they are cached, they can be easily returned from there. A first shot at 
> a signature might look something like:
>
> getItem : GlobalState -> ID -> Tag -> (GlobalState, Cmd msg)
>
>
>
> However we could partially apply functions that exist on some globalState 
> instantiation to hdie the initial state being passed in and end up with:
>
> state.items.getItem : ID -> Tag -> (GlobalState, Cmd msg)
>
>
>
> The downside of this approach is that I have to thread this state through 
> multiple calls that might make use of it, and thread it back up explicitly 
> through the update functions to get it back to the top. At the top we'd 
> then have something like (excuse any mistakes!):
>
> update msg model = case msg of
>SubMsg m ->
>  let (newSubModel, subCmds, newGlobalState) = SubComponent.update m 
> model.subModel
>  in ({ model | state = newGlobalState, subModel = newSubModel}, Sub.map 
> SubMsg subCmds)
>...
>
>
> An alternative approach is to hold this global state in an effect manager, 
> and so in the app you'd end up using the Cmd/Sub mechanism to ask for 
> things from the state and internally initiate API requests to update the 
> state as necessary. We'd end up with an API more like:
>
> getItem : ID -> Tag -> Cmd msg
>
>
> or
>
> state.items.getItem : ID -> Tag -> Cmd msg
>
>
> where the returned Cmd would either lead to an item being sent to the 
> component immediately via a cache (where Tag is a Msg type the component 
> knows about) or after it was obtained via some backend. This would make all 
> retrieving of state async but seems to simplify the interface (perhaps at 
> the cost of more complexity in implementing the effect manager).
>
> Which approach do people think is best for working with global state 
> (neither is an option if you have a better way!)? Do you get away with not 
> needing this kind of thing (and if so, how)? I'd love to hear back, 
> especially from those that have had experience building larger apps in Elm!
>

-- 
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] Is it correct way to get DOM to function?

2016-05-31 Thread Gage Peterson
I've just tried running your code file and it seems to work. Were you trying to 
accomplish something specific? 

-- 
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] Exporting Elm Type Defs

2016-05-31 Thread Zachary Kessin
Is there an easy way to parse out elm types and export them to some form of
AST?

I know that NoRedInk did it here... http://noredink.github.io/json-to-elm/
but having a way to define a type in elm then somehow convert that to
erlang code would be really helpful.

Zach

-- 
Zach Kessin
Twitter: @zkessin 
Skype: zachkessin
ᐧ

-- 
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: FilterTable Widget - used to work with 2 Signal.Address

2016-05-31 Thread Patrick Detlefsen
Maybe passing a view context like Peter suggests would be something

https://groups.google.com/forum/#!searchin/elm-discuss/parent/elm-discuss/Db9c9JFKxvo/Jb__9OR2FwAJ

On Tuesday, May 31, 2016 at 6:36:23 PM UTC+2, Patrick Detlefsen wrote:
>
> Hey all,
>
> for work i wrote a filter table component which you can give a definition 
> of your columns and pass in some data and it internally handles the 
> filtering and sorting based on which filters the user sets.
> It looks similar to this angular ui-grid example:
>
>
> 
>
> Writing something into the search fields or clicking on one of the table 
> headers triggers an Action/Msg which gets routed to the table and updates 
> the table state. Clicking into one of the cells triggers an Action/Msg 
> which gets routed to the parent component. This was possible because I 
> could Signal.forwardTo messages to one or the other and I could pass the 
> parent components address into the table so the Table could send messages 
> to the parent. I built it so that a default version only needs a List of 
> Column Definitions to render but all the view functions like view, row, 
> cell can be switched out if need be which I use a lot.
>
> Now we don't have Signals anymore and cannot send messages. I have spent 
> all day on different approaches to get this Component migrated to Elm 0.17 
> and I am stuck.
>
> Here is the working 0.16 version and the current state of the 0.17 
> version. I know the multiple calls to Html.App.map in the view functions 
> are wrong.
> https://gist.github.com/patrickdet/194bc8747fefe3ab83896f31f4c1e624
>
>
> Has anyone in the community upgraded any Signal code that relied on 2 
> Signals for parent/child component communication? Any help would be highly 
> appreciated. I want to open source this component once it works because I 
> find it very useful. It's only ~200 lines of code but it is so much nicer 
> than angular ui-grid (Our customers say that). 
>
>
>
>

-- 
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] FilterTable Widget - used to work with 2 Signal.Address

2016-05-31 Thread Patrick Detlefsen
Hey all,

for work i wrote a filter table component which you can give a definition 
of your columns and pass in some data and it internally handles the 
filtering and sorting based on which filters the user sets.
It looks similar to this angular ui-grid example:



Writing something into the search fields or clicking on one of the table 
headers triggers an Action/Msg which gets routed to the table and updates 
the table state. Clicking into one of the cells triggers an Action/Msg 
which gets routed to the parent component. This was possible because I 
could Signal.forwardTo messages to one or the other and I could pass the 
parent components address into the table so the Table could send messages 
to the parent. I built it so that a default version only needs a List of 
Column Definitions to render but all the view functions like view, row, 
cell can be switched out if need be which I use a lot.

Now we don't have Signals anymore and cannot send messages. I have spent 
all day on different approaches to get this Component migrated to Elm 0.17 
and I am stuck.

Here is the working 0.16 version and the current state of the 0.17 version. 
I know the multiple calls to Html.App.map in the view functions are wrong.
https://gist.github.com/patrickdet/194bc8747fefe3ab83896f31f4c1e624


Has anyone in the community upgraded any Signal code that relied on 2 
Signals for parent/child component communication? Any help would be highly 
appreciated. I want to open source this component once it works because I 
find it very useful. It's only ~200 lines of code but it is so much nicer 
than angular ui-grid (Our customers say that). 



-- 
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] Managing global state in Elm

2016-05-31 Thread James Wilson
In Elm, each component basically has its own internal state (which is 
actually all just a slice of one global model). In my app, I also want 
global state that is independant of any components; for example a 
clientside cache of various API responses (asset details - there could be 
many thousands, user authentication status).

I want any component to be able to call methods that make use of this 
global state. For example, a method to obtain details for items in the 
current view might first look at the global state to see if these items are 
cached. If they arent, the call would provide a Cmd to be issued that gets 
the items (and puts them in the cache), while simultaneously updating the 
state to indicate that they are being loaded (so that the same request 
again from another component doesnt trigger another call to the backend). 
If they are cached, they can be easily returned from there. A first shot at 
a signature might look something like:

getItem : GlobalState -> ID -> Tag -> (GlobalState, Cmd msg)



However we could partially apply functions that exist on some globalState 
instantiation to hdie the initial state being passed in and end up with:

state.items.getItem : ID -> Tag -> (GlobalState, Cmd msg)



The downside of this approach is that I have to thread this state through 
multiple calls that might make use of it, and thread it back up explicitly 
through the update functions to get it back to the top. At the top we'd 
then have something like (excuse any mistakes!):

update msg model = case msg of
   SubMsg m ->
 let (newSubModel, subCmds, newGlobalState) = SubComponent.update m 
model.subModel
 in ({ model | state = newGlobalState, subModel = newSubModel}, Sub.map 
SubMsg subCmds)
   ...


An alternative approach is to hold this global state in an effect manager, 
and so in the app you'd end up using the Cmd/Sub mechanism to ask for 
things from the state and internally initiate API requests to update the 
state as necessary. We'd end up with an API more like:

getItem : ID -> Tag -> Cmd msg


or

state.items.getItem : ID -> Tag -> Cmd msg


where the returned Cmd would either lead to an item being sent to the 
component immediately via a cache (where Tag is a Msg type the component 
knows about) or after it was obtained via some backend. This would make all 
retrieving of state async but seems to simplify the interface (perhaps at 
the cost of more complexity in implementing the effect manager).

Which approach do people think is best for working with global state 
(neither is an option if you have a better way!)? Do you get away with not 
needing this kind of thing (and if so, how)? I'd love to hear back, 
especially from those that have had experience building larger apps in Elm!

-- 
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: State of CSS in Elm

2016-05-31 Thread VeryThorough
I use external styles written in Sass.  In my next project, I plan to try 
using rtfeldman/elm-css, though again as a generator for an external 
stylesheet.  Pseudo selectors are a perfect example of why external CSS is 
more powerful (and generally more performant) than inline styles.  (At 
least until the Houdini project 

 is 
adopted...)


On Tuesday, May 31, 2016 at 2:26:37 AM UTC-7, Peter Damoc wrote:
>
> How do you handle styling in your Elm programs? 
>
> Do you use one of the following libraries?
>
> rtfeldman/elm-css
>
> seanhess/elm-style
>
> massung/elm-css
>
> Or do you do something completely different (manual style inlining, 
> classes and external css) ? 
>
> I tried using Sean's library but I quickly ran into pseudo-selectors 
> trouble wanting to implement a simple hover effect. 
>
> Somehow, keeping a set of hover states for some simple nav-link seams such 
> an overkill. 
>
> How do you handle such scenarios? 
>
>
>
> -- 
> 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] trying to draw a diagram about elm-architecture

2016-05-31 Thread Frederick Yankowski
I made a go at a similar diagram last week, emphasizing the "update loop" 
in particular.

http://fredcy.github.io/updateloop.html

I like yours for its details about how Msg values relate to Sub, Cmd, and 
Html values

-- 
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: Dynamically load SVG files

2016-05-31 Thread Josh Adams
You could generate the svg in elm and just base64 encode it and update it like 
a normal thing in your view, no?

-- 
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: State of CSS in Elm

2016-05-31 Thread David Legard
I use pure elm-html - the style is placed as an Attribute in the view 
function

. . . 
p [navstyle] [text (String.join " " m.opens) ]
. . .

while the Style itself is defined elsewhere (I put all of them in a file 
called Styles.elm)

navstyle = style [("position","absolute")
 ,("left", "0px")
 ,("width","10cm")
 ,("backgroundColor","Beige")
 ,("fontFamily","Calibri,serif")
 ,("cursor","pointer")
 ]

I have used this to build in Elm quite a nice collapsing/expanding TreeMenu 
navigation menu, which is something that CSS does rather well.

-- 
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: Google Map inside elm

2016-05-31 Thread Simon
I don't see that as being difficult, but you will need to delay the google 
maps javascript running until Elm has refreshed the dom with the maps 
container.


On Tuesday, 31 May 2016 09:54:37 UTC+2, Zachary Kessin wrote:
>
>
> Hi All
>
> I am building an application in Elm that requires some maping tools. As 
> such I would like to use Google maps to visualize the map for my users. I 
> had looked at the elm-google-maps repo, but it seems to be doing things by 
> not doing a fullscreen elm app and putting the google map outside of the 
> main elm rendering area. Is there a way to still have elm be fullscreen and 
> show a map inside it?
>
>
> https://github.com/simonh1000/elm-google-maps/blob/quickDirty/index.html
> -- 
> Zach Kessin
> Twitter: @zkessin 
> Skype: zachkessin
> ᐧ
>

-- 
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] trying to draw a diagram about elm-architecture

2016-05-31 Thread 诺铁
updated, thanks.
I use a green block for "init",  because I think it's not in the loop, it's
a special one.

On Tue, May 31, 2016 at 6:07 PM, Ian Mackenzie 
wrote:

> I like it! A couple comments:
>
>- You'll probably want to change 'Sub MSG' and 'HTML MSG' to 'Sub Msg'
>and 'Html Msg' to be consistent with the usual type names
>- You'll likely want an 'init' in there too - perhaps another yellow
>block above 'model', with arrows to 'model' and 'Cmd Msg'?
>
>
> On Tuesday, 31 May 2016 16:23:52 UTC+10, 大魔头 wrote:
>>
>> oh yes, I've corrected it, thanks!
>>
>> On Tue, May 31, 2016 at 1:09 PM, Janis Voigtländer <
>> janis.voi...@gmail.com> wrote:
>>
>>> Looks very accurate to me. Instead of state and State, probably use
>>> model and Model, since that’s the terms used officially.
>>> ​
>>>
>>> 2016-05-31 5:14 GMT+02:00 诺铁 :
>>>
 hi,

 I've tried out examples in http://guide.elm-lang.org/  , now I want to
 prepare myself to share what I've learnt to my team mates.

 since there isn't an official diagram about the elm-architecure(maybe
 there is?), so I draw my own.
 https://raw.githubusercontent.com/notyy/learn_elm/master/elm_arch.png

 review is very much welcome. I hope my diagram won't be miss leading
 others.

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

-- 
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: State of CSS in Elm

2016-05-31 Thread Simon
I use external scss style sheets and gulp-sass: it's known technology and I 
don't believe Elm uses the sort of component level name spacing for styles 
that I've seen in Angular 2 (not sure of the technical name) that rewards 
putting styles in with code.


On Tuesday, 31 May 2016 11:26:37 UTC+2, Peter Damoc wrote:
>
> How do you handle styling in your Elm programs? 
>
> Do you use one of the following libraries?
>
> rtfeldman/elm-css
>
> seanhess/elm-style
>
> massung/elm-css
>
> Or do you do something completely different (manual style inlining, 
> classes and external css) ? 
>
> I tried using Sean's library but I quickly ran into pseudo-selectors 
> trouble wanting to implement a simple hover effect. 
>
> Somehow, keeping a set of hover states for some simple nav-link seams such 
> an overkill. 
>
> How do you handle such scenarios? 
>
>
>
> -- 
> 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] trying to draw a diagram about elm-architecture

2016-05-31 Thread Ian Mackenzie
I like it! A couple comments:

   - You'll probably want to change 'Sub MSG' and 'HTML MSG' to 'Sub Msg' 
   and 'Html Msg' to be consistent with the usual type names
   - You'll likely want an 'init' in there too - perhaps another yellow 
   block above 'model', with arrows to 'model' and 'Cmd Msg'? 


On Tuesday, 31 May 2016 16:23:52 UTC+10, 大魔头 wrote:
>
> oh yes, I've corrected it, thanks!
>
> On Tue, May 31, 2016 at 1:09 PM, Janis Voigtländer  > wrote:
>
>> Looks very accurate to me. Instead of state and State, probably use model 
>> and Model, since that’s the terms used officially.
>> ​
>>
>> 2016-05-31 5:14 GMT+02:00 诺铁 >:
>>
>>> hi,
>>>
>>> I've tried out examples in http://guide.elm-lang.org/  , now I want to 
>>> prepare myself to share what I've learnt to my team mates.  
>>>
>>> since there isn't an official diagram about the elm-architecure(maybe 
>>> there is?), so I draw my own.
>>> https://raw.githubusercontent.com/notyy/learn_elm/master/elm_arch.png
>>>
>>> review is very much welcome. I hope my diagram won't be miss leading 
>>> others.
>>>
>>> -- 
>>> 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.


[elm-discuss] State of CSS in Elm

2016-05-31 Thread Peter Damoc
How do you handle styling in your Elm programs?

Do you use one of the following libraries?

rtfeldman/elm-css

seanhess/elm-style

massung/elm-css

Or do you do something completely different (manual style inlining, classes
and external css) ?

I tried using Sean's library but I quickly ran into pseudo-selectors
trouble wanting to implement a simple hover effect.

Somehow, keeping a set of hover states for some simple nav-link seams such
an overkill.

How do you handle such scenarios?



-- 
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] Re: how to stop subscription?

2016-05-31 Thread jonathan de montalembert
I believe that every functions that receive a model are reevaluated when 
the model changes.

On Friday, 27 May 2016 07:36:09 UTC+1, 大魔头 wrote:
>
> I add a "shouldStop: Bool" flag to the model. and check it in subscription 
> definition:
>
> subscriptions : Model -> Sub Msg
>> subscriptions model =
>>   if model.shouldStop then
>> Sub.none
>>   else
>> Time.every second Tick
>
>
> It works!  but this confuse me. 
> doesn't this mean,whenever model is changed, the subscription is 
> reevaluated?
>
> On Fri, May 27, 2016 at 2:11 PM, Gage Peterson  > wrote:
>
>> I'm not sure it's possible at this point. One way would be to simply 
>> ignore them based on some state in the model. Like a boolean called 
>> "trackTime" that would only react to the time if it was true. 
>>
>>
>> On Thursday, May 26, 2016 at 8:53:08 PM UTC-6, 大魔头 wrote:
>>>
>>> hi,
>>>
>>> in the guide http://guide.elm-lang.org/architecture/effects/time.html
>>> there is an exercise:
>>>
>>> Exercises:
>>>
>>>- Add a button to pause the clock, turning the Time subscription off.
>>>
>>> but I search the api doc, and didn't find out how to do this? any hints?
>>>
>> -- 
>> 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: Dynamically load SVG files

2016-05-31 Thread Håkon Rossebø
I want to be able to manipulate the svg and respond to events. I don't 
think that is possible using an img tag.


mandag 30. mai 2016 22.26.36 UTC+2 skrev Zinggi følgende:
>
> Couldn't you just use an img tag with the path/to.svg in the src attribute?
>
>
> On Monday, 30 May 2016 15:34:07 UTC+2, Håkon Rossebø wrote:
>>
>> I'm trying out some SVG maps from here:
>>
>> https://www.amcharts.com/svg-maps/?map=usa
>>
>> Seems to be too much to embed inline. What would be the best way of 
>> loading SVG files dynamically?
>>
>>
>>
>>
>>

-- 
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: Dynamically load SVG files

2016-05-31 Thread Håkon Rossebø
Thanks, I'll try that. 

mandag 30. mai 2016 17.22.09 UTC+2 skrev Max Goldstein følgende:
>
> Make an HTTP request in init, and have a Msg where they get added to the 
> model. If you work through some tutorials (links conspicuously absent!) on 
> the Elm Architecture, this should become pretty clear.
>

-- 
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] Google Map inside elm

2016-05-31 Thread Zachary Kessin
Hi All

I am building an application in Elm that requires some maping tools. As
such I would like to use Google maps to visualize the map for my users. I
had looked at the elm-google-maps repo, but it seems to be doing things by
not doing a fullscreen elm app and putting the google map outside of the
main elm rendering area. Is there a way to still have elm be fullscreen and
show a map inside it?


https://github.com/simonh1000/elm-google-maps/blob/quickDirty/index.html
-- 
Zach Kessin
Twitter: @zkessin 
Skype: zachkessin
ᐧ

-- 
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] Download elm

2016-05-31 Thread Nikhil Dhar

>
> hey,,thanks will try this 
>
thanks again 

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