[elm-discuss] Re: Help resolving : domNode.replaceData is not a function

2016-05-18 Thread debois
Hi Richard, 

I experienced similar thing, and in my case, it seems to have to do with 
nested use of `Html.App.map`: https://github.com/elm-lang/html/issues/16.

Cheers,

Søren

On Saturday, May 14, 2016 at 9:24:06 PM UTC+2, Richard Osafo wrote:
>
> Hi Martin,
> After much trial and error, I got it to work by embedding my view in 
> another div. Still not sure what the problem was though but at least I can 
> go on.
>
> This fails
>
> let
>   viewFn =
> \ctx m -> component.view ctx m -- or just component.view
>
>
> This works
>
> let
>   viewFn =
> \ctx m -> div [] [ component.view ctx m ]
>
>
> regards,
> Richard.
>

-- 
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] Applying Html.App.map twice leads to "TypeError: domNode.replaceData is not a function"

2016-05-18 Thread debois
https://github.com/elm-lang/html/issues/16

On Sunday, May 15, 2016 at 3:40:19 PM UTC+2, Janis Voigtländer wrote:
>
> That’s great. But *please* report the bug as an issue on GitHub 
> nevertheless!
> ​
>
> 2016-05-15 15:23 GMT+02:00 Martin Troxler 
> >:
>
>> By using your workaround I could fix my program.
>>
>> Thanks,
>> Martin
>>
>> -- 
>> 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] Re: How to implement wrapping components in elm

2016-05-18 Thread debois
As I understand it, you want to write a function which takes a list of TEA 
components, then wires up and renders those. As Peter pointed out, this can 
be done when your "components" are really just view functions. If they are 
actual TEA components, each with (view, update, Model, Message, 
Subscription), there's a problem in that you'll need, someplace, a type 
that can host "Model" for any such component. I don't think Elm has such a 
type. 

I wrote a library for treating TEA-components uniformly (
https://github.com/debois/elm-parts); elm-mdl uses that. It gets most of 
the way, but in the end, to use it, you have to make a record that contains 
every type of Model you are treating. Elm-mdl does it like so: 
https://github.com/debois/elm-mdl/blob/master/src/Material.elm#L178-L190.

I wrote a blog post about how this is achieved: 
https://medium.com/@debois/elm-components-3d9c00c6c612#.x5mtskkmg. (It's 
phrased in 0.16 terms, though.)

 

On Wednesday, May 18, 2016 at 6:38:45 PM UTC+2, Daniel Kwiecinski wrote:
>
> Hi Peter,
>
>Just skimmed on the gist, but can already tell this is great help. Many 
> thanks for your work.
>
> Cheers,
> Dan
>
> On Wednesday, 18 May 2016 15:20:38 UTC+1, Peter Damoc wrote:
>>
>> This gist (previously posted)
>> https://gist.github.com/pdamoc/aef6306a9001de109aeece37e5627d06
>> is a kind of minimalist example. It shows how to join together 2 
>> different widgets (RandomGif and Counter). 
>> The process for extending the list with new widgets is mechanical, just 
>> add options to all the relevant types. 
>>
>>
>>
>>
>>
>> On Wed, May 18, 2016 at 4:59 PM, Daniel Kwiecinski > > wrote:
>>
>>> Sounds very promising. Could you please provide minimalist example?   
>>>
>>> On Wednesday, 18 May 2016 13:47:16 UTC+1, Peter Damoc wrote:

 You just use regular Elm Architecture and compose the model of the 
 autocomplete into the proper place, same with update and view. 

 To speak in React terms, what you had above are components that have 
 only props. These can be implemented with simple functions in Elm. 

 If a component needs state and rest calls, it needs to follow the Elm 
 Architecture. Please note that the component can be fully encapsulated in 
 a 
 module. The kind of boilerplate needed for state management is very small 
 and very predictable. You can even extract it into some kind of Widget 
 abstraction and have all the Widgets be updated by a single line of code. 
 :) 






 On Wed, May 18, 2016 at 3:16 PM, Daniel Kwiecinski <
 daniel.k...@gmail.com> wrote:

> This is fine. Big thanks for your effort.
> But, how about instead of components being simple functions we have 
> components as {init, update, view, subscription} so they encapsulate 
> their 
> logic. 
> Think in having a component similar to google places autocomplete. 
> From it's parent we still want to pass a configuration to it and react to 
> the commands coming from the autocomplete (such as place changed) but we 
> do 
> not want or need to interfere with the autocomplete component internal 
> state, rest calls etc?
>
> On Wednesday, 18 May 2016 13:08:21 UTC+1, Peter Damoc wrote:
>>
>> Oh, that's much easier:
>>
>> import Html exposing (..) 
>> import Html.Attributes exposing (class) 
>>
>> helloComponent name = 
>>   p [] [text ("Hello, " ++ name ++ "!")]
>>   
>> sayHello = 
>>   helloComponent "world" 
>>
>>
>> listHello names = 
>>   div [] (List.map helloComponent names) 
>>
>>
>> -- GENERIC WRAPPING COMPONENT
>>
>> wrapComponents components = 
>>   div [class "components-wrapped-in-pages-so-we-can-swipe-them"]
>>   (List.map (\c -> div [class "page"] [c]) components)
>>
>>
>> names = ["Jim", "Bill", "Joe"]
>>
>>
>> main = 
>>   wrapComponents 
>> [ sayHello
>> , helloComponent "Sandra"
>> , listHello names
>> ]
>>
>> There is no Signal anymore in Elm and if you use The Elm 
>> Architecture, all you get is regular values. 
>>
>>
>>
>>
>> On Wed, May 18, 2016 at 1:15 PM, Daniel Kwiecinski <
>> daniel.k...@gmail.com> wrote:
>>
>>> Here is a sketch of how it would look like in reagent (ClojureScript)
>>>
>>>
>>> ; -- SOME CONCRETE COMPONENTS
>>>
>>> ; a component taking a String as a model
>>> (defn hello-component [name]
>>>   [:p "Hello, " name "!"])
>>>
>>> ; a stateless component using another component
>>> (defn say-hello []
>>>   [hello-component "world"])
>>>
>>> ; a component taking a ratom (it's a signal in elm speak) as a model
>>> (defn reactive-hello-component [name]
>>>   [:p "Hello, " @name "!"])
>>>
>>> ; a component taking list of Strings as a model
>>> (defn list-he

Re: [elm-discuss] How to map multi-level nesting components in 0.17

2016-05-18 Thread Luis Fei
Thanks,Nick,sorry for the later reply

I tried to apply the changes to Tab.view, still have the problem, this time 
the compiler complained inferring definition has this type: `(Msg -> a) -> 
Model -> List (Html Msg) -> Html Msg`, and I'm confused how to use this new 
added TabMsg parameter inside Tab.view

On Wednesday, May 18, 2016 at 12:36:35 AM UTC+8, Nick H wrote:
>
> Right now, I am guessing your Tab.view has this signature:
>
> Tab.view : Tab.Model -> List (Html Tab.Msg) -> Html Tab.Msg
>
> Try changing it to follow this signature:
>
> Tab.view : (Tab.Msg -> a) -> Tab.Model -> List (Html a) -> Html a
>
> And your Main.view will then look like this:
>
> view model =
>   Tab.view TabMsg model.tabModel
> [ App.map LogsMsg <| LogList.view model.logModel ]
>
>
> The other solution that comes to mind would be to nest the LogList.Model 
> within Tab.Model and nest LogList.Msg within Tab.Msg, but I am guessing you 
> want the Tab component to be more generic than that.
>
> On Tue, May 17, 2016 at 3:26 AM, Luis Fei  > wrote:
>
>> Hi, I was trying to upgrade from 0.16 to 0.17, and meet this problem
>>
>> I have  a Main.view which contains a Tab.view, and Tab.view contains a 
>> LogList.view, so i change the Signal.forwardTo part like this:
>>
>> -- This is Main module
>>
>> type alias Model =
>> { tabModel : Tab.Model
>> , logsModel : LogList.Model
>> }
>>
>> type Msg
>> = TabMsg Tab.Msg
>> | LogMsg LogList.Msg
>>
>> view : Model -> Html Msg
>> view model =
>> App.map TabMsg
>> <| Tab.view model.tabModel
>> [ App.map LogsMsg <| LogList.view model.logModel ]
>> 
>>
>> And the compiler complained as the Tab.view is expecting `List (Html 
>> Tab.Msg)` but it is `List (Html Msg)`, I understand why the compiler 
>> complain like this, the problem is I don't know how to do these kind of 
>>  multi-level nesting.
>>
>> thanks.
>>
>> BTW, I read 
>> https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/2-counter-list.elm,
>>  
>> but it's single child to parent communication.
>>
>> -- 
>> 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] What is the Type Signature of the 'Program' type

2016-05-18 Thread Tylor Steinberger
Thanks everyone for their input, I'm not purposefully ignoring anyone, just 
haven't had enough time to revisit any of my experiments here. I'd love to 
at some point collaborate with someone who might be more familiar with 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.


Re: [elm-discuss] JSON Decode question

2016-05-18 Thread Mario Sangiorgio
Actually you need width, height and radius to be numbers not strings.
Otherwise you'll get parsing errors.
{ "tag": "rectangle", "width": 2, "height": 3}
{ "tag": "circle", "radius": 2}

On Wed, May 18, 2016 at 10:36 PM Mario Sangiorgio 
wrote:

> No, the json explicitly has a tag attribute to let your code know what is
> the shape type it encodes followed by the attributes for that shape.
>
> Something like:
> { "tag": "rectangle", "width": "2", "height": "3"}
> { "tag": "circle", "radius": "2"}
>
> Note that there is no nesting.
>
> Mario
>
> On Wed, May 18, 2016 at 10:29 PM Eelco Hoekema  wrote:
>
>> Hi,
>>
>> I'm a bit stuck in decoding some json. In
>> http://package.elm-lang.org/packages/elm-lang/core/4.0.0/Json-Decode#andThen
>> there is an example of decoding a tagged union for a shape.
>>
>> type Shape
>> = Rectangle Float Float
>> | Circle Float
>> shape : Decoder Shapeshape =
>>   ("tag" := string) `andThen` shapeInfo
>> shapeInfo : String -> Decoder ShapeshapeInfo tag =
>>   case tag of
>> "rectangle" ->
>> object2 Rectangle
>>   ("width" := float)
>>   ("height" := float)
>>
>> "circle" ->
>> object1 Circle
>>   ("radius" := float)
>>
>> _ ->
>> fail (tag ++ " is not a recognized tag for shapes")
>>
>>
>> How would the corresponding JSON look like? Should that be
>>
>> {"rectangle" : {"width" : "2", "height": "3"}}
>>
>>
>>
>> eelco
>>
>> --
>> 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] JSON Decode question

2016-05-18 Thread Mario Sangiorgio
No, the json explicitly has a tag attribute to let your code know what is
the shape type it encodes followed by the attributes for that shape.

Something like:
{ "tag": "rectangle", "width": "2", "height": "3"}
{ "tag": "circle", "radius": "2"}

Note that there is no nesting.

Mario

On Wed, May 18, 2016 at 10:29 PM Eelco Hoekema  wrote:

> Hi,
>
> I'm a bit stuck in decoding some json. In
> http://package.elm-lang.org/packages/elm-lang/core/4.0.0/Json-Decode#andThen
> there is an example of decoding a tagged union for a shape.
>
> type Shape
> = Rectangle Float Float
> | Circle Float
> shape : Decoder Shapeshape =
>   ("tag" := string) `andThen` shapeInfo
> shapeInfo : String -> Decoder ShapeshapeInfo tag =
>   case tag of
> "rectangle" ->
> object2 Rectangle
>   ("width" := float)
>   ("height" := float)
>
> "circle" ->
> object1 Circle
>   ("radius" := float)
>
> _ ->
> fail (tag ++ " is not a recognized tag for shapes")
>
>
> How would the corresponding JSON look like? Should that be
>
> {"rectangle" : {"width" : "2", "height": "3"}}
>
>
>
> eelco
>
> --
> 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] JSON Decode question

2016-05-18 Thread Eelco Hoekema
Hi,

I'm a bit stuck in decoding some json. 
In http://package.elm-lang.org/packages/elm-lang/core/4.0.0/Json-Decode#andThen 
there is an example of decoding a tagged union for a shape. 

type Shape
= Rectangle Float Float
| Circle Float
shape : Decoder Shapeshape =
  ("tag" := string) `andThen` shapeInfo
shapeInfo : String -> Decoder ShapeshapeInfo tag =
  case tag of
"rectangle" ->
object2 Rectangle
  ("width" := float)
  ("height" := float)

"circle" ->
object1 Circle
  ("radius" := float)

_ ->
fail (tag ++ " is not a recognized tag for shapes")


How would the corresponding JSON look like? Should that be 

{"rectangle" : {"width" : "2", "height": "3"}}



eelco

-- 
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 do I render a child component in 0.17 (like CounterList)?

2016-05-18 Thread Mark Hamburg
Or more succinctly, the issue to be dealt with in the counter with remove 
button case is that the view needs to be able to "send" more messages not that 
the counter update function needs to handle more messages.

Mark

> On May 18, 2016, at 1:40 PM, Mark Hamburg  wrote:
> 
> I'm hoping that's not how it is expected to work because it means that a view 
> layout decision — we need to put the remove button in with the counter 
> display and buttons — now spreads to the messages and update function. I much 
> prefer the solution that someone else posted where viewWithRemove takes a 
> context that provides a mapping for the counter messages and a message to 
> send on remove. That reflects the fact that it's the view change that forces 
> the programmer to say "okay, I can build that view but you need to give me 
> more context to do so successfully."
> 
> Mark
> 
>> On May 17, 2016, at 10:54 PM, Peter Damoc  wrote:
>> 
>> It works like you can see in the second link you've quoted. :) 
>> 
>> 
>> 
>> 
>> On Wed, May 18, 2016 at 8:40 AM, Homan Chou  wrote:
 Hi Brian,
 The Elm Architecture Tutorial has a "nesting" example:
 https://github.com/evancz/elm-architecture-tutorial/tree/master/nesting
 
 If you worked with the previous elm-architecture-tutorial (the one with 8 
 examples) I have a port of that tutorial that you can consult to see how 
 some of those concepts translate to 0.17:
 https://github.com/pdamoc/elm-architecture-tutorial/tree/master/examples/4
>>> 
>>> The new updated nesting tutorials don't include the modified "fancier" list 
>>> of counters example where the delete button is in the child Counter 
>>> component.  In the 0.16 example a "context" was passed in from the parent 
>>> with some signal forwarding magic.  In a world where there are no signals 
>>> in Elm now, how does this work?
>>> -- 
>>> 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.

-- 
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 do I render a child component in 0.17 (like CounterList)?

2016-05-18 Thread Mark Hamburg
I'm hoping that's not how it is expected to work because it means that a view 
layout decision — we need to put the remove button in with the counter display 
and buttons — now spreads to the messages and update function. I much prefer 
the solution that someone else posted where viewWithRemove takes a context that 
provides a mapping for the counter messages and a message to send on remove. 
That reflects the fact that it's the view change that forces the programmer to 
say "okay, I can build that view but you need to give me more context to do so 
successfully."

Mark

> On May 17, 2016, at 10:54 PM, Peter Damoc  wrote:
> 
> It works like you can see in the second link you've quoted. :) 
> 
> 
> 
> 
> On Wed, May 18, 2016 at 8:40 AM, Homan Chou  wrote:
>>> Hi Brian,
>>> The Elm Architecture Tutorial has a "nesting" example:
>>> https://github.com/evancz/elm-architecture-tutorial/tree/master/nesting
>>> 
>>> If you worked with the previous elm-architecture-tutorial (the one with 8 
>>> examples) I have a port of that tutorial that you can consult to see how 
>>> some of those concepts translate to 0.17:
>>> https://github.com/pdamoc/elm-architecture-tutorial/tree/master/examples/4
>> 
>> The new updated nesting tutorials don't include the modified "fancier" list 
>> of counters example where the delete button is in the child Counter 
>> component.  In the 0.16 example a "context" was passed in from the parent 
>> with some signal forwarding magic.  In a world where there are no signals in 
>> Elm now, how does this work?
>> -- 
>> 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.

-- 
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 do I render a child component in 0.17 (like CounterList)?

2016-05-18 Thread Homan Chou
Interesting... it's like it's own module.  I feel like there are a lot of
little things like this that aren't covered in any of the getting started
guides.

On Wed, May 18, 2016 at 1:05 PM, Peter Damoc  wrote:

> It means that it exports both the type Dispatch and the tag Remove. It's
> explicit with what it exports.
> It should have been "Dispatch(..)" because in cases like this you might
> want to expose all the Dispatch Tags.
>
>
> On Wed, May 18, 2016 at 10:55 PM, Homan Chou  wrote:
>
>> Ah... thanks.  I read that wrong and thought you were linking the old
>> repo.
>>
>> What does "Dispatch(Remove)" mean in the Counter exposing part?
>>
>> On Tue, May 17, 2016 at 10:54 PM, Peter Damoc  wrote:
>>
>>> It works like you can see in the second link you've quoted. :)
>>>
>>>
>>>
>>>
>>> On Wed, May 18, 2016 at 8:40 AM, Homan Chou  wrote:
>>>
 Hi Brian,
> The Elm Architecture Tutorial has a "nesting" example:
> https://github.com/evancz/elm-architecture-tutorial/tree/master/nesting
> 
>
> If you worked with the previous elm-architecture-tutorial (the one
> with 8 examples) I have a port of that tutorial that you can consult to 
> see
> how some of those concepts translate to 0.17:
>
> https://github.com/pdamoc/elm-architecture-tutorial/tree/master/examples/4


 The new updated nesting tutorials don't include the modified "fancier"
 list of counters example where the delete button is in the child Counter
 component.  In the 0.16 example a "context" was passed in from the parent
 with some signal forwarding magic.  In a world where there are no signals
 in Elm now, how does this work?

 --
 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 a topic in the
>>> Google Groups "Elm Discuss" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/elm-discuss/GZidxLFlLtQ/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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.
>>
>
>
>
> --
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/GZidxLFlLtQ/unsubscribe.
> To unsubscribe from this group and all its topics, 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: onClick only firing 50% of the time

2016-05-18 Thread Russell Dunphy
Ah, now I feel daft! Thank you, Yosuke. Still learning to mentally parse 
all the nested lists :-D

On Wednesday, May 18, 2016 at 6:46:58 PM UTC+1, Yosuke Torii wrote:
>
> Hi Russell,
>
> It's because `onClick` is attached to the icon, not the button. Maybe the 
> area of icon is about 50% of its parent button ;)
>
> button [ class "btn btn-default" ]
>[ i [ class "fa fa-trash-o"
>, onClick address (Remove id) ] []]
>
>
> 2016年5月18日水曜日 5時00分48秒 UTC+9 Russell Dunphy:
>>
>> Hi, brand new to learning Elm, so no doubt I'm doing something stupid...
>>
>> Would anyone be kind enough to point out where I might be going wrong in 
>> this toy project? https://github.com/rsslldnphy/pairwheel
>>
>> The interesting code is in 
>> https://github.com/rsslldnphy/pairwheel/blob/master/frontend/PairWheel.elm. 
>> I'm trying to create a list of inputs with attached buttons that can save 
>> the inputs' contents or remove them from the list. Similar to the 
>> "counters" example that used to be in the elm architecture tutorial, i 
>> think, but I can't find it any more.
>>
>> The problem I'm currently running into is that the "remove" button 
>> sometimes works, but about 50% of the time it doesn't, and I can't see any 
>> pattern as to when it does and doesn't work. The "save" button doesn't seem 
>> to work at all.
>>
>> Like I say I'm sure I'm missing something obvious. Any general 
>> suggestions / recommendations are also very welcome.
>>
>> Thanks,
>>
>> Russell
>>
>

-- 
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 do I render a child component in 0.17 (like CounterList)?

2016-05-18 Thread Peter Damoc
It means that it exports both the type Dispatch and the tag Remove. It's
explicit with what it exports.
It should have been "Dispatch(..)" because in cases like this you might
want to expose all the Dispatch Tags.


On Wed, May 18, 2016 at 10:55 PM, Homan Chou  wrote:

> Ah... thanks.  I read that wrong and thought you were linking the old repo.
>
> What does "Dispatch(Remove)" mean in the Counter exposing part?
>
> On Tue, May 17, 2016 at 10:54 PM, Peter Damoc  wrote:
>
>> It works like you can see in the second link you've quoted. :)
>>
>>
>>
>>
>> On Wed, May 18, 2016 at 8:40 AM, Homan Chou  wrote:
>>
>>> Hi Brian,
 The Elm Architecture Tutorial has a "nesting" example:
 https://github.com/evancz/elm-architecture-tutorial/tree/master/nesting
 

 If you worked with the previous elm-architecture-tutorial (the one with
 8 examples) I have a port of that tutorial that you can consult to see how
 some of those concepts translate to 0.17:

 https://github.com/pdamoc/elm-architecture-tutorial/tree/master/examples/4
>>>
>>>
>>> The new updated nesting tutorials don't include the modified "fancier"
>>> list of counters example where the delete button is in the child Counter
>>> component.  In the 0.16 example a "context" was passed in from the parent
>>> with some signal forwarding magic.  In a world where there are no signals
>>> in Elm now, how does this work?
>>>
>>> --
>>> 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 a topic in the
>> Google Groups "Elm Discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/elm-discuss/GZidxLFlLtQ/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.
>



-- 
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 do I render a child component in 0.17 (like CounterList)?

2016-05-18 Thread Homan Chou
Ah... thanks.  I read that wrong and thought you were linking the old repo.

What does "Dispatch(Remove)" mean in the Counter exposing part?

On Tue, May 17, 2016 at 10:54 PM, Peter Damoc  wrote:

> It works like you can see in the second link you've quoted. :)
>
>
>
>
> On Wed, May 18, 2016 at 8:40 AM, Homan Chou  wrote:
>
>> Hi Brian,
>>> The Elm Architecture Tutorial has a "nesting" example:
>>> https://github.com/evancz/elm-architecture-tutorial/tree/master/nesting
>>> 
>>>
>>> If you worked with the previous elm-architecture-tutorial (the one with
>>> 8 examples) I have a port of that tutorial that you can consult to see how
>>> some of those concepts translate to 0.17:
>>>
>>> https://github.com/pdamoc/elm-architecture-tutorial/tree/master/examples/4
>>
>>
>> The new updated nesting tutorials don't include the modified "fancier"
>> list of counters example where the delete button is in the child Counter
>> component.  In the 0.16 example a "context" was passed in from the parent
>> with some signal forwarding magic.  In a world where there are no signals
>> in Elm now, how does this work?
>>
>> --
>> 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 a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/GZidxLFlLtQ/unsubscribe.
> To unsubscribe from this group and all its topics, 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] Re: Knowing if Dict has changed

2016-05-18 Thread surfncode

To be honest I don't even know yet if I will need it. I have to run some 
performance tests first. I'm just trying to see what are my options in case 
using only records + list proves too slow. 

I have recently watched some videos about clojure/clojurescript where the 
advocate their support of persistent data structures and it seems pretty 
good. Since Array,Dict and Set in elm seem to support structural sharing 
too, I was wondering is the same kind of simple identity tests for 
detecting changes than in clojure were supported too.

My use case is that I will have a list of records where records can be 
appended, inserted, removed and updated as well. In most of case, I will 
need to lookup a record by id (each of my records will have a unique id). I 
was wondering what would be the best way to store it and Dict appeared as a 
good candidate. 

However as I will probably have quite of few computations derived from that 
list so I tried to imagine a way to avoid recomputing them when this list 
of records hasn't changed (with a memoize function for example). Of course 
this will only be interesting if I can do a quick equality check between 
the old version of my Dict and the new one hence my original question.

I actually very new to elm so I don't know what are the common practices 
for speed optimization. 

-- 
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: Knowing if Dict has changed

2016-05-18 Thread Nick H
How important is this optimization to you? And do you really need it to
work for the most general case?

Making your code more complicated, in the hopes of exploiting an
undocumented behavior of the compiler, is something you ought to avoid
unless you are certain that it is necessary.

If all you care about is whether Dict.remove actually removed something,
you could compare the size of the Dict before to the size of the Dict after.

On Wed, May 18, 2016 at 11:37 AM, surfncode  wrote:

>
> I hadn't thought of that, that's true indeed.
>
> Here are some other example using dictEquals. Do you think the d1==d2
> short-circuit would still work in those cases?
>
> dictEquals : Dict comparable b -> Dict comparable b -> Bool
> dictEquals d1 d2 =
>   d1 == d2 || Dict.toList d1 == Dict.toList d2
>
> -- Example 1
> a = Dict.fromList [(0,"Alice"),(1,"Bob")]
> a' =Dict.insert 2 "Anna" a;
> a'' = Dict.remove 3 a'; -- a'' should be unchanged compared to a'
> isSame = dictEquals a' a''-- will this call fall back to evaluating 
> Dict.toList
> d1 == Dict.toList d2 ?
>
> -- Example 2
> a = Dict.fromList [(0,"Alice"),(1,"Bob")]
> a' =Dict.insert 3 "Anna" a;
> a'' = Dict.remove 4 a'; -- a'' should be unchanged compared to a'
> isSame = dictEquals a' a'' -- will this call fall back to evaluating 
> Dict.toList
> d1 == Dict.toList d2 ?
>
>
>
>
>
>
> --
> 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: Would appreciate some code review and comments on extracting a component

2016-05-18 Thread Yosuke Torii
Hi Joaquín,

If you expect the component to do HTTP request internally and return the 
result, I think it is (Model, Cmd msg, Whatever) pettern, which Evan is 
going to explain here 
.

Using this pattern, I recently implemented a similar thing too (It's a 
SearchBox 
). 
This component has an input for query and triggers submit event as Msg. 
This Msg comes back to the `update` function, and if the query is valid, 
then HTTP request occurs through Cmd. After the result comes back, it then 
goes out of the component as an Event.

(Its Model has `results` field in it, but I think this is not necessary. 
Throwing the result with Event would also be good way.)

I'm not sure this is really following the official way, but I hope this 
helps.


2016年5月17日火曜日 18時07分31秒 UTC+9 Joaquín Oltra:
>
> I've changed my previous attempt so that instead of App knowing about and 
> acting on the Msg types from the child SearchForm component, now I'm making 
> the SearchForm return an event as suggested in the docs (making the update 
> function return extra info for parent).
>
> I'm liking it better than the thing I did before: 
> https://github.com/joakin/gimme-gif/commit/d5ed1ef0296bb87f84b12eec0ad8ef95f1630008
>
> This way the parent routes all child msgs to the child, and after update 
> sees if there is anything of interest for him:
>
> update msg model =
>   case Debug.log "MSG: " msg of
> SearchForm sfmsg ->
>   let
> (sfmodel, event) = SearchForm.update sfmsg model.search
>   in
> ( { model | search = sfmodel }
> , case event of
> Just SearchForm.Search ->
>   getRandomGif model.search
> Nothing ->
>   Cmd.none
> )
>
>
> Is this any better?
>
> On Monday, May 16, 2016 at 9:59:05 PM UTC+2, Joaquín Oltra wrote:
>>
>> Hi, I'm trying to learn how to properly extract components that have a 
>> model and update functions to standalone components, but I'm not sure if 
>> I'm doing a good job.
>>
>> The guide I've found incomplete on nesting, the todomvc example is just 
>> one file, and I can't find good info around. I'd really appreciate some 
>> code review.
>>
>> It is the gif app, I'm trying to extract the search form, which has 
>> internal state (the query in the input), but also has a message that the 
>> parent is interested in (submit on the form) in order to trigger the gif 
>> fetching.
>>
>>
>> https://github.com/joakin/gimme-gif/commit/a6bf98da1f7f018a29456930a1886c9fa908bde3
>>
>> Even if the SearchForm doesn't return Cmds, I'm trying to properly merge 
>> them with the ones on the parent to get the idea. Would this be how you'd 
>> do it?
>>
>> Thanks a lot, my brain hurts from learning, it is nice :)
>>
>

-- 
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: Knowing if Dict has changed

2016-05-18 Thread surfncode

I hadn't thought of that, that's true indeed.

Here are some other example using dictEquals. Do you think the d1==d2 
short-circuit would still work in those cases?

dictEquals : Dict comparable b -> Dict comparable b -> Bool
dictEquals d1 d2 =
  d1 == d2 || Dict.toList d1 == Dict.toList d2

-- Example 1
a = Dict.fromList [(0,"Alice"),(1,"Bob")]
a' =Dict.insert 2 "Anna" a;
a'' = Dict.remove 3 a'; -- a'' should be unchanged compared to a'
isSame = dictEquals a' a''-- will this call fall back to evaluating Dict.toList 
d1 == Dict.toList d2 ?

-- Example 2
a = Dict.fromList [(0,"Alice"),(1,"Bob")]
a' =Dict.insert 3 "Anna" a;
a'' = Dict.remove 4 a'; -- a'' should be unchanged compared to a'
isSame = dictEquals a' a'' -- will this call fall back to evaluating 
Dict.toList 
d1 == Dict.toList d2 ?




 

-- 
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] Mouse position doesn't work in Internet Explorer (I have IE 11) in Elm 0.17

2016-05-18 Thread vjorjo
Hi all,

I upgraded a project of mine, to version 0.17 and I noticed that my app 
became unresponsive in IE 11.
The culprit is the elm-lang/mouse package which seems not working with IE.

Even the example in the official site is not working in IE:
http://elm-lang.org/examples/drag

Thanks,
George

-- 
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: onClick only firing 50% of the time

2016-05-18 Thread Yosuke Torii
Hi Russell,

It's because `onClick` is attached to the icon, not the button. Maybe the 
area of icon is about 50% of its parent button ;)

button [ class "btn btn-default" ]
   [ i [ class "fa fa-trash-o"
   , onClick address (Remove id) ] []]


2016年5月18日水曜日 5時00分48秒 UTC+9 Russell Dunphy:
>
> Hi, brand new to learning Elm, so no doubt I'm doing something stupid...
>
> Would anyone be kind enough to point out where I might be going wrong in 
> this toy project? https://github.com/rsslldnphy/pairwheel
>
> The interesting code is in 
> https://github.com/rsslldnphy/pairwheel/blob/master/frontend/PairWheel.elm. 
> I'm trying to create a list of inputs with attached buttons that can save 
> the inputs' contents or remove them from the list. Similar to the 
> "counters" example that used to be in the elm architecture tutorial, i 
> think, but I can't find it any more.
>
> The problem I'm currently running into is that the "remove" button 
> sometimes works, but about 50% of the time it doesn't, and I can't see any 
> pattern as to when it does and doesn't work. The "save" button doesn't seem 
> to work at all.
>
> Like I say I'm sure I'm missing something obvious. Any general suggestions 
> / recommendations are also very welcome.
>
> Thanks,
>
> Russell
>

-- 
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 implement wrapping components in elm

2016-05-18 Thread Daniel Kwiecinski
Hi Peter,

   Just skimmed on the gist, but can already tell this is great help. Many 
thanks for your work.

Cheers,
Dan

On Wednesday, 18 May 2016 15:20:38 UTC+1, Peter Damoc wrote:
>
> This gist (previously posted)
> https://gist.github.com/pdamoc/aef6306a9001de109aeece37e5627d06
> is a kind of minimalist example. It shows how to join together 2 different 
> widgets (RandomGif and Counter). 
> The process for extending the list with new widgets is mechanical, just 
> add options to all the relevant types. 
>
>
>
>
>
> On Wed, May 18, 2016 at 4:59 PM, Daniel Kwiecinski  > wrote:
>
>> Sounds very promising. Could you please provide minimalist example?   
>>
>> On Wednesday, 18 May 2016 13:47:16 UTC+1, Peter Damoc wrote:
>>>
>>> You just use regular Elm Architecture and compose the model of the 
>>> autocomplete into the proper place, same with update and view. 
>>>
>>> To speak in React terms, what you had above are components that have 
>>> only props. These can be implemented with simple functions in Elm. 
>>>
>>> If a component needs state and rest calls, it needs to follow the Elm 
>>> Architecture. Please note that the component can be fully encapsulated in a 
>>> module. The kind of boilerplate needed for state management is very small 
>>> and very predictable. You can even extract it into some kind of Widget 
>>> abstraction and have all the Widgets be updated by a single line of code. 
>>> :) 
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wed, May 18, 2016 at 3:16 PM, Daniel Kwiecinski <
>>> daniel.k...@gmail.com> wrote:
>>>
 This is fine. Big thanks for your effort.
 But, how about instead of components being simple functions we have 
 components as {init, update, view, subscription} so they encapsulate their 
 logic. 
 Think in having a component similar to google places autocomplete. From 
 it's parent we still want to pass a configuration to it and react to the 
 commands coming from the autocomplete (such as place changed) but we do 
 not 
 want or need to interfere with the autocomplete component internal state, 
 rest calls etc?

 On Wednesday, 18 May 2016 13:08:21 UTC+1, Peter Damoc wrote:
>
> Oh, that's much easier:
>
> import Html exposing (..) 
> import Html.Attributes exposing (class) 
>
> helloComponent name = 
>   p [] [text ("Hello, " ++ name ++ "!")]
>   
> sayHello = 
>   helloComponent "world" 
>
>
> listHello names = 
>   div [] (List.map helloComponent names) 
>
>
> -- GENERIC WRAPPING COMPONENT
>
> wrapComponents components = 
>   div [class "components-wrapped-in-pages-so-we-can-swipe-them"]
>   (List.map (\c -> div [class "page"] [c]) components)
>
>
> names = ["Jim", "Bill", "Joe"]
>
>
> main = 
>   wrapComponents 
> [ sayHello
> , helloComponent "Sandra"
> , listHello names
> ]
>
> There is no Signal anymore in Elm and if you use The Elm Architecture, 
> all you get is regular values. 
>
>
>
>
> On Wed, May 18, 2016 at 1:15 PM, Daniel Kwiecinski <
> daniel.k...@gmail.com> wrote:
>
>> Here is a sketch of how it would look like in reagent (ClojureScript)
>>
>>
>> ; -- SOME CONCRETE COMPONENTS
>>
>> ; a component taking a String as a model
>> (defn hello-component [name]
>>   [:p "Hello, " name "!"])
>>
>> ; a stateless component using another component
>> (defn say-hello []
>>   [hello-component "world"])
>>
>> ; a component taking a ratom (it's a signal in elm speak) as a model
>> (defn reactive-hello-component [name]
>>   [:p "Hello, " @name "!"])
>>
>> ; a component taking list of Strings as a model
>> (defn list-hellos [names]
>>   (for [n names]
>>[hello-component (str "hello " n)]))
>>
>> ; -- GENERIC WRAPPING COMPONENT
>>
>>
>> ; a wrapping components. take list of components as a parameter and 
>> wraps them in pages
>> (defn wrap-components [components]
>>   (fn []
>>   [:div {:class 
>> "components-wrapped-in-pages-so-we-can-swipe-them"}
>>(for [c components]
>> [:div {:class "page"} c])]))
>>
>>
>> ; -- MAIN VIEW GLUING ALL TOGETHER
>>
>>
>> (defn main-view []
>>   (let [reactive-name (ratom "initial-name")
>> input-state (ratom "")]
>>[:div {:class "some-boilerplate"}
>>
>> ; the two lines below are not following re-frame pattern. 
>> There are there just to express I have the state which changes.  
>> [:input {:onchange (fn [value] (!reset input-state value))}] 
>> ; react to inout changes and pass the value to model (in re-frame 
>> instead of directly updating the model we would send a signal (as in 
>> elm) and have subscription re

[elm-discuss] Re: Looking for people experienced with elm-html's "key" function

2016-05-18 Thread debois
I was using virtualdom key for two things, both of which I cannot do in 
0.17.

1. Instructing virtual-dom whether or not to reset scrolling-state of an 
element. Try it out here: https://debois.github.io/elm-mdl/: Scroll to the 
bottom, then switch tab. Because virtual-dom is re-using the div containing 
the main contents, it does not reset scrolling state, and so when you 
switch tab, you retain scrolling state. In 0.16, I could specify different 
keys for the old and new tabs, which would make virtual-dom clear 
scrolling-state on change. I can't find a way to do this in 0.17.

2. Controlling CSS transitions in dynamically generated list of elements. 
See @Richard's post above. Here is an example from the elm-mdl demo.

Proper behaviour: https://debois.github.io/elm-mdl/. On the "snackbar" tab, 
click the "Snackbar" button a few times, then click "Undo".

 

0.17 behaviour: https://debois.github.io/elm-mdl/broken-css.html. Try the 
same thing. Note boxes accidentally resizing. What happens is that 
virtualdom re-appropriates a div of width 0 for an element that wants to be 
width 200px; CSS transitions kick in. 

  


Cheers,

Søren
 

 




-- 
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: Knowing if Dict has changed

2016-05-18 Thread Janis Voigtländer
In principle it’s correct. The type needs to be a bit different (comparable
instead of a). Moreover, it will still not work reliably if you call it
with something where the b type is itself a type that does not have
reliable ==. For example, if you call that dictEquals on a Dict Int (Set
Int), you can still be told that the things are unequal when actually they
are semantically equal.
​

2016-05-18 17:51 GMT+02:00 surfncode :

> Thanks. That would be great. Can other experts confirm it works ?
>
> Le mercredi 18 mai 2016 17:11:56 UTC+2, Max Goldstein a écrit :
>>
>> Sorry, posted too soon.
>>
>> dictEquals : Dict a b -> Dict a b -> Bool
>> dictEquals d1 d2 =
>>   d1 == d2 || Dict.toList d1 == Dict.toList d2
>>
>> This will short-circuit when the object references are the same and
>> otherwise do the work necessary to always give the correct answer. (I think
>> - please tell me if I'm wrong.)
>>
> --
> 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: Knowing if Dict has changed

2016-05-18 Thread surfncode
Thanks. That would be great. Can other experts confirm it works ?

Le mercredi 18 mai 2016 17:11:56 UTC+2, Max Goldstein a écrit :
>
> Sorry, posted too soon.
>
> dictEquals : Dict a b -> Dict a b -> Bool
> dictEquals d1 d2 =
>   d1 == d2 || Dict.toList d1 == Dict.toList d2
>
> This will short-circuit when the object references are the same and 
> otherwise do the work necessary to always give the correct answer. (I think 
> - please tell me if I'm wrong.)
>

-- 
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: Knowing if Dict has changed

2016-05-18 Thread Max Goldstein
Sorry, posted too soon.

dictEquals : Dict a b -> Dict a b -> Bool
dictEquals d1 d2 =
  d1 == d2 || Dict.toList d1 == Dict.toList d2

This will short-circuit when the object references are the same and 
otherwise do the work necessary to always give the correct answer. (I think 
- please tell me if I'm wrong.)

-- 
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: Knowing if Dict has changed

2016-05-18 Thread Max Goldstein
Dict equality is unreliable, but in the sense that it say two dicts are 
unequal when semantically they are. Also, equality on lists is reliable 
(and Dict.fromList is always in sorted order) so equating the results of 
Dict.fromList should be okay.

So...

dictEquals : Dict a b -> Dict a b -> Bool
dictEquals d1 d2 =

-- 
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] [ANN] Elm Style Animation v 1.0.0 - Now with SVG animations

2016-05-18 Thread Max Goldstein
Sweet!

There's now elm-community/easing-functions that you can use with this 
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.


Re: [elm-discuss] [ANN] Elm Style Animation v 1.0.0 - Now with SVG animations

2016-05-18 Thread Joaquín Oltra
Awesome library and examples. 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] Howto filter on Sub

2016-05-18 Thread Steve Schafer
By "deep down," I mean that I'm looking to see if there's anywhere that the 
model is being passed down to some deeper level where that could be 
bypassed, thus avoiding reconstruction of the model and thereby preserving 
reference equality.


On Tuesday, May 17, 2016 at 12:43:36 PM UTC-4, Janis Voigtländer wrote:
>
> If you are even thinking about "deep down", you are not considering 
> reference equality. Because reference equality, which lazy uses, simply 
> compares that the two objects/records are at the same memory address. A 
> question of "deep down" cannot arise. 
>
> Am 17.05.2016 um 17:56 schrieb Steve Schafer  >:
>
> Yes, I'm aware of that. The model should be equal, but there may be 
> something buried deep down that's causing a problem. I think it may have to 
> do with something that effectively looks like this:
>
> y = { x | a = x.a }
>
> While Elm thinks that x == y, JavaScript does not. I've tried to expunge 
> all of these, but there may be something lurking somewhere. And Elm doesn't 
> make it easy to figure out where such things may exist.
>
>
> On Tuesday, May 17, 2016 at 10:59:01 AM UTC-4, Janis Voigtländer wrote:
>>
>> You are aware that the functions from Html.Lazy use reference equality? 
>> So two models are only considered equal if they are the same JS object (at 
>> the the same pointer address). The zipper data structures I know don’t give 
>> that degree of equality after moving down and up again.
>> ​
>>
>> 2016-05-17 15:43 GMT+02:00 Steve Schafer :
>>
>>> No, I have a couple of ports that handle things like monitoring text 
>>> selection in input fields, but that's about it. I think what's happening is 
>>> that the differ is getting confused because of my use of a zipper data 
>>> structure; when I traverse down the structure and then back up, it *should 
>>> *be able to tell that the structure is unchanged, but it seems not to 
>>> be able to do that. I need to investigate further to determine exactly 
>>> what's going on.
>>>
>>>
>>> On Friday, May 13, 2016 at 11:16:56 AM UTC-4, Janis Voigtländer wrote:

 Was your 0.16 code using Signal.forwardTo inside the view function? If 
 so, there’s a good chance that 0.17 will please you with much better 
 Html.lazy behavior.
 ​

 2016-05-13 16:19 GMT+02:00 Steve Schafer :

> I *am* using Lazy, and in my specific 0.16 application (I haven't had 
> a chance to update it to 0.17 yet), I haven't found the rendering 
> optimizations to be all that smart. My view is a handful of Bootstrap 
> accordion-style sections, with the inactive ones empty and the active one 
> displaying a fairly large HTML table, typically twenty rows by twenty 
> columns (think spreadsheet). A no-op update with *zero *changes to 
> the model incurs about 200 ms of JavaScript processing time, essentially 
> all of it in the virtual DOM diffing and rendering process, according to 
> Chrome. There's no way that I can afford redundant updates that cost that 
> much.
>
> You keep saying that the model needs to stop listening to 
> subscriptions if it doesn't want to handle them, but there's no practical 
> way to make that work for some of the scenarios that have been mentioned 
> here. For example, say that your app wants to handle onKeyDown for just 
> the 
> up- and down-arrow keys, and ignore all other keys. How does one make 
> that 
> work, short of dropping out to JavaScript to create a custom event stream?
>
>
> On Thursday, May 12, 2016 at 11:21:46 AM UTC-4, Noah Hall wrote:
>>
>> > The problem is that update is not an ordinary function, as it has 
>> side effects (rendering the view). If the view is complex, those side 
>> effects can be computationally expensive, so you still need some way to 
>> minimize redundant invocations of update. And it seems like the only 
>> practical way to do that would be to somehow prevent no-op events from 
>> ever 
>> reaching update. An alternative would be some sort of "escape clause" 
>> for 
>> update to be able to say, "I didn't change the model at all, so don't 
>> update the view." 
>>
>> If you care a lot about this performance, then you should be using 
>> either Html.Lazy or elm-lang/lazy. By default the renderer is already 
>> very fast and very clever - this is how virtual-doms work, by 
>> generating diffs and checking if they actually need to re-render or 
>> not. If you want to not trigger things, then you need to use the 
>> model 
>> to stop listening to that subscription. 
>>
>> On Thu, May 12, 2016 at 5:03 PM, Peter Damoc  
>> wrote: 
>> > On Thu, May 12, 2016 at 5:54 PM, Janis Voigtländer 
>> >  wrote: 
>> >> 
>> >> So, the suggestion is that that solution should be different, 
>> moving the 
>> >> if-then-else into the update-function (and not having NoOp on a 
>> mapp

Re: [elm-discuss] Re: How to implement wrapping components in elm

2016-05-18 Thread Peter Damoc
This gist (previously posted)
https://gist.github.com/pdamoc/aef6306a9001de109aeece37e5627d06
is a kind of minimalist example. It shows how to join together 2 different
widgets (RandomGif and Counter).
The process for extending the list with new widgets is mechanical, just add
options to all the relevant types.





On Wed, May 18, 2016 at 4:59 PM, Daniel Kwiecinski <
daniel.kwiecin...@gmail.com> wrote:

> Sounds very promising. Could you please provide minimalist example?
>
> On Wednesday, 18 May 2016 13:47:16 UTC+1, Peter Damoc wrote:
>>
>> You just use regular Elm Architecture and compose the model of the
>> autocomplete into the proper place, same with update and view.
>>
>> To speak in React terms, what you had above are components that have only
>> props. These can be implemented with simple functions in Elm.
>>
>> If a component needs state and rest calls, it needs to follow the Elm
>> Architecture. Please note that the component can be fully encapsulated in a
>> module. The kind of boilerplate needed for state management is very small
>> and very predictable. You can even extract it into some kind of Widget
>> abstraction and have all the Widgets be updated by a single line of code.
>> :)
>>
>>
>>
>>
>>
>>
>> On Wed, May 18, 2016 at 3:16 PM, Daniel Kwiecinski > > wrote:
>>
>>> This is fine. Big thanks for your effort.
>>> But, how about instead of components being simple functions we have
>>> components as {init, update, view, subscription} so they encapsulate their
>>> logic.
>>> Think in having a component similar to google places autocomplete. From
>>> it's parent we still want to pass a configuration to it and react to the
>>> commands coming from the autocomplete (such as place changed) but we do not
>>> want or need to interfere with the autocomplete component internal state,
>>> rest calls etc?
>>>
>>> On Wednesday, 18 May 2016 13:08:21 UTC+1, Peter Damoc wrote:

 Oh, that's much easier:

 import Html exposing (..)
 import Html.Attributes exposing (class)

 helloComponent name =
   p [] [text ("Hello, " ++ name ++ "!")]

 sayHello =
   helloComponent "world"


 listHello names =
   div [] (List.map helloComponent names)


 -- GENERIC WRAPPING COMPONENT

 wrapComponents components =
   div [class "components-wrapped-in-pages-so-we-can-swipe-them"]
   (List.map (\c -> div [class "page"] [c]) components)


 names = ["Jim", "Bill", "Joe"]


 main =
   wrapComponents
 [ sayHello
 , helloComponent "Sandra"
 , listHello names
 ]

 There is no Signal anymore in Elm and if you use The Elm Architecture,
 all you get is regular values.




 On Wed, May 18, 2016 at 1:15 PM, Daniel Kwiecinski <
 daniel.k...@gmail.com> wrote:

> Here is a sketch of how it would look like in reagent (ClojureScript)
>
>
> ; -- SOME CONCRETE COMPONENTS
>
> ; a component taking a String as a model
> (defn hello-component [name]
>   [:p "Hello, " name "!"])
>
> ; a stateless component using another component
> (defn say-hello []
>   [hello-component "world"])
>
> ; a component taking a ratom (it's a signal in elm speak) as a model
> (defn reactive-hello-component [name]
>   [:p "Hello, " @name "!"])
>
> ; a component taking list of Strings as a model
> (defn list-hellos [names]
>   (for [n names]
>[hello-component (str "hello " n)]))
>
> ; -- GENERIC WRAPPING COMPONENT
>
>
> ; a wrapping components. take list of components as a parameter and wraps 
> them in pages
> (defn wrap-components [components]
>   (fn []
>   [:div {:class 
> "components-wrapped-in-pages-so-we-can-swipe-them"}
>(for [c components]
> [:div {:class "page"} c])]))
>
>
> ; -- MAIN VIEW GLUING ALL TOGETHER
>
>
> (defn main-view []
>   (let [reactive-name (ratom "initial-name")
> input-state (ratom "")]
>[:div {:class "some-boilerplate"}
>
> ; the two lines below are not following re-frame pattern. 
> There are there just to express I have the state which changes.
> [:input {:onchange (fn [value] (!reset input-state value))}] 
> ; react to inout changes and pass the value to model (in re-frame instead 
> of directly updating the model we would send a signal (as in elm) and 
> have subscription react to the signal but for simplicity I ommit the 
> patern)
> [:button {:onclick #(!reset reactive-name @input-state)}] ; 
> copy the states on button click
>
> [:span {:class 
> "here-come-generic-swipe-able-pages-wrapping-any-components"}
>
>  ; here is the usage of the wrapping container
>

Re: [elm-discuss] [ANN] Elm Style Animation v 1.0.0 - Now with SVG animations

2016-05-18 Thread Peter Damoc
This is awesome!

I've updated the Dash docset to honor your release.
I can now report that there are some 106 packages that have already made
the transition to 0.17 :)


On Wed, May 18, 2016 at 12:21 AM, Matthew Griffith 
wrote:

>
> Hi All,
>
> I just released a fairly large update I've been working on.
>
> https://github.com/mdgriffith/elm-style-animation
>
> First off, elm-html-animation has been renamed* elm-style-animation*
> because it now covers SVG animations as well as html styles.
>
> This is for elm 0.17.  If you use this library and think you're going to
> be on 0.16 for a while, let me know and I'll see what I can do to provide a
> temporary 0.16 version.
>
> So what's new?
>
>- The syntax for specifying animations now is cleaner and more
>powerful.  You can use standard elm machinery like List.map and
>List.indexedMap to do things like stagger animations or animate a list of
>things.  This is much better than before.
>- Native support for Elm's Color type.
>- SVG attributes can now be animated!
>- You can morph polygons into each other
>.
>- You can morph batman logos into each other.
> Cause
>this is what you really wanted to do with elm.
>- The flowermenu
> from
>before is now even cleaner
>
>
>
>
>
>
>
>
>
> --
> 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] Re: How to implement wrapping components in elm

2016-05-18 Thread Daniel Kwiecinski
Sounds very promising. Could you please provide minimalist example?   

On Wednesday, 18 May 2016 13:47:16 UTC+1, Peter Damoc wrote:
>
> You just use regular Elm Architecture and compose the model of the 
> autocomplete into the proper place, same with update and view. 
>
> To speak in React terms, what you had above are components that have only 
> props. These can be implemented with simple functions in Elm. 
>
> If a component needs state and rest calls, it needs to follow the Elm 
> Architecture. Please note that the component can be fully encapsulated in a 
> module. The kind of boilerplate needed for state management is very small 
> and very predictable. You can even extract it into some kind of Widget 
> abstraction and have all the Widgets be updated by a single line of code. 
> :) 
>
>
>
>
>
>
> On Wed, May 18, 2016 at 3:16 PM, Daniel Kwiecinski  > wrote:
>
>> This is fine. Big thanks for your effort.
>> But, how about instead of components being simple functions we have 
>> components as {init, update, view, subscription} so they encapsulate their 
>> logic. 
>> Think in having a component similar to google places autocomplete. From 
>> it's parent we still want to pass a configuration to it and react to the 
>> commands coming from the autocomplete (such as place changed) but we do not 
>> want or need to interfere with the autocomplete component internal state, 
>> rest calls etc?
>>
>> On Wednesday, 18 May 2016 13:08:21 UTC+1, Peter Damoc wrote:
>>>
>>> Oh, that's much easier:
>>>
>>> import Html exposing (..) 
>>> import Html.Attributes exposing (class) 
>>>
>>> helloComponent name = 
>>>   p [] [text ("Hello, " ++ name ++ "!")]
>>>   
>>> sayHello = 
>>>   helloComponent "world" 
>>>
>>>
>>> listHello names = 
>>>   div [] (List.map helloComponent names) 
>>>
>>>
>>> -- GENERIC WRAPPING COMPONENT
>>>
>>> wrapComponents components = 
>>>   div [class "components-wrapped-in-pages-so-we-can-swipe-them"]
>>>   (List.map (\c -> div [class "page"] [c]) components)
>>>
>>>
>>> names = ["Jim", "Bill", "Joe"]
>>>
>>>
>>> main = 
>>>   wrapComponents 
>>> [ sayHello
>>> , helloComponent "Sandra"
>>> , listHello names
>>> ]
>>>
>>> There is no Signal anymore in Elm and if you use The Elm Architecture, 
>>> all you get is regular values. 
>>>
>>>
>>>
>>>
>>> On Wed, May 18, 2016 at 1:15 PM, Daniel Kwiecinski <
>>> daniel.k...@gmail.com> wrote:
>>>
 Here is a sketch of how it would look like in reagent (ClojureScript)


 ; -- SOME CONCRETE COMPONENTS

 ; a component taking a String as a model
 (defn hello-component [name]
   [:p "Hello, " name "!"])

 ; a stateless component using another component
 (defn say-hello []
   [hello-component "world"])

 ; a component taking a ratom (it's a signal in elm speak) as a model
 (defn reactive-hello-component [name]
   [:p "Hello, " @name "!"])

 ; a component taking list of Strings as a model
 (defn list-hellos [names]
   (for [n names]
[hello-component (str "hello " n)]))

 ; -- GENERIC WRAPPING COMPONENT


 ; a wrapping components. take list of components as a parameter and wraps 
 them in pages
 (defn wrap-components [components]
   (fn []
   [:div {:class "components-wrapped-in-pages-so-we-can-swipe-them"}
(for [c components]
 [:div {:class "page"} c])]))


 ; -- MAIN VIEW GLUING ALL TOGETHER


 (defn main-view []
   (let [reactive-name (ratom "initial-name")
 input-state (ratom "")]
[:div {:class "some-boilerplate"}

 ; the two lines below are not following re-frame pattern. 
 There are there just to express I have the state which changes.  
 [:input {:onchange (fn [value] (!reset input-state value))}] ; 
 react to inout changes and pass the value to model (in re-frame instead of 
 directly updating the model we would send a signal (as in elm) and have 
 subscription react to the signal but for simplicity I ommit the patern)
 [:button {:onclick #(!reset reactive-name @input-state)}] ; 
 copy the states on button click

 [:span {:class 
 "here-come-generic-swipe-able-pages-wrapping-any-components"}

  ; here is the usage of the wrapping container
  (wrap-components [
say-hello ; stateless component
#(hello-component "some-fancy-name") ; 
 #(...) is lambda in clojure, here we close over some static state
#(reactive-hello-component reactive-name) ; 
 #(...) here we close over some reactive state, so the component re-renders 
 when the model (state) changes
#(list-hellos ["a" "b" "c"]) ; component 
 takin

[elm-discuss] Re: Updating a game using Forms and Elements for input to Elm 0.17

2016-05-18 Thread Tobias Hermann
Btw, it is not just this game, that worries me. In our company we 
internally use a tool written in Elm. I can not post its source code. But 
It has buttons, input fields etc., and they all are embedded in a quite 
deep structure of Elements (flow down, flow right, etc.). Since I have to 
extend this tool quite regularly, I of course want to update it to Elm 0.17 
too. Right now I have no idea how to do this without rewriting the view 
parts entirely.

Here is a minimal example showing my problem:
The following was possible in Elm 0.16:
source: http://daiw.de/share/elm/html_to_element_problem_0.17/Main.elm
online version: 
http://daiw.de/share/elm/html_to_element_problem_0.17/index.html
How can I convert this to 0.17?


On Tuesday, May 17, 2016 at 10:04:28 PM UTC+2, Tobias Hermann wrote:
>
> Hi,
>
> here I have this game "pick and gloat" (source 
> , online version 
> ) I would like to update from Elm 
> 0.16 to Elm 0.17. It uses Forms and Elements to position stuff that can be 
> tapped/clicked. It does not even use the removed Touch package, but 
> Html.Events.on 
> "touchstart" etc. instead. Nevertheless I find the task extremely 
> difficult, because everything was based on the fact that Html could be 
> converted to Element 
> ,
>  
> which no longer is possible 
> 
> .
>
> How would you approach such a problem? I can hardly believe that 
> positioning everything manually low-level style with divs and css can be 
> the way to go.
> Could one abstract this away to get the old functionality back?
> Any help would be appreciated. I am quite desperate. :D
>
> Tobias
>

-- 
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: elm-hot-loader: 0.17 Hot-reloading

2016-05-18 Thread John Orford
that's what I was hoping for(!)

On Wed, 18 May 2016 at 15:22 Magnus Rundberget  wrote:

> This is awesome, tx !
>
> Would it work with websockets too ? (I guess I should just try...)
>
>
> @John
> Allows you to hot-load (browser automatically updated) changes to elm,
> html and css, WITHOUT loosing model state. A bit like elm-reactor used to
> be back in the days (but that only worked for elm code, and it didn't work
> with ports).
>
> cheers
>
> Magnus
>
>
>
> On Wednesday, 18 May 2016 10:05:30 UTC+2, Flux Xu wrote:
>>
>> Hi,
>>
>> I just published elm-hot-loader 0.3.0 to supports hot-reloading with Elm
>> 0.17
>> Swap port and EmptyAction are gone. No modification of your code is
>> needed, it just works.
>>
>> Project repository: https://github.com/fluxxu/elm-hot-loader
>> Example project: https://github.com/fluxxu/elm-hot-loader-starter
>>
>> Hope you will find it useful!
>>
> --
> 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: elm-hot-loader: 0.17 Hot-reloading

2016-05-18 Thread Magnus Rundberget
This is awesome, tx !

Would it work with websockets too ? (I guess I should just try...)


@John
Allows you to hot-load (browser automatically updated) changes to elm, html 
and css, WITHOUT loosing model state. A bit like elm-reactor used to be 
back in the days (but that only worked for elm code, and it didn't work 
with ports).

cheers
Magnus


On Wednesday, 18 May 2016 10:05:30 UTC+2, Flux Xu wrote:
>
> Hi,
>
> I just published elm-hot-loader 0.3.0 to supports hot-reloading with Elm 
> 0.17
> Swap port and EmptyAction are gone. No modification of your code is 
> needed, it just works.
>
> Project repository: https://github.com/fluxxu/elm-hot-loader
> Example project: https://github.com/fluxxu/elm-hot-loader-starter
>
> Hope you will find it useful!
>

-- 
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 implement wrapping components in elm

2016-05-18 Thread Peter Damoc
You just use regular Elm Architecture and compose the model of the
autocomplete into the proper place, same with update and view.

To speak in React terms, what you had above are components that have only
props. These can be implemented with simple functions in Elm.

If a component needs state and rest calls, it needs to follow the Elm
Architecture. Please note that the component can be fully encapsulated in a
module. The kind of boilerplate needed for state management is very small
and very predictable. You can even extract it into some kind of Widget
abstraction and have all the Widgets be updated by a single line of code.
:)






On Wed, May 18, 2016 at 3:16 PM, Daniel Kwiecinski <
daniel.kwiecin...@gmail.com> wrote:

> This is fine. Big thanks for your effort.
> But, how about instead of components being simple functions we have
> components as {init, update, view, subscription} so they encapsulate their
> logic.
> Think in having a component similar to google places autocomplete. From
> it's parent we still want to pass a configuration to it and react to the
> commands coming from the autocomplete (such as place changed) but we do not
> want or need to interfere with the autocomplete component internal state,
> rest calls etc?
>
> On Wednesday, 18 May 2016 13:08:21 UTC+1, Peter Damoc wrote:
>>
>> Oh, that's much easier:
>>
>> import Html exposing (..)
>> import Html.Attributes exposing (class)
>>
>> helloComponent name =
>>   p [] [text ("Hello, " ++ name ++ "!")]
>>
>> sayHello =
>>   helloComponent "world"
>>
>>
>> listHello names =
>>   div [] (List.map helloComponent names)
>>
>>
>> -- GENERIC WRAPPING COMPONENT
>>
>> wrapComponents components =
>>   div [class "components-wrapped-in-pages-so-we-can-swipe-them"]
>>   (List.map (\c -> div [class "page"] [c]) components)
>>
>>
>> names = ["Jim", "Bill", "Joe"]
>>
>>
>> main =
>>   wrapComponents
>> [ sayHello
>> , helloComponent "Sandra"
>> , listHello names
>> ]
>>
>> There is no Signal anymore in Elm and if you use The Elm Architecture,
>> all you get is regular values.
>>
>>
>>
>>
>> On Wed, May 18, 2016 at 1:15 PM, Daniel Kwiecinski > > wrote:
>>
>>> Here is a sketch of how it would look like in reagent (ClojureScript)
>>>
>>>
>>> ; -- SOME CONCRETE COMPONENTS
>>>
>>> ; a component taking a String as a model
>>> (defn hello-component [name]
>>>   [:p "Hello, " name "!"])
>>>
>>> ; a stateless component using another component
>>> (defn say-hello []
>>>   [hello-component "world"])
>>>
>>> ; a component taking a ratom (it's a signal in elm speak) as a model
>>> (defn reactive-hello-component [name]
>>>   [:p "Hello, " @name "!"])
>>>
>>> ; a component taking list of Strings as a model
>>> (defn list-hellos [names]
>>>   (for [n names]
>>>[hello-component (str "hello " n)]))
>>>
>>> ; -- GENERIC WRAPPING COMPONENT
>>>
>>>
>>> ; a wrapping components. take list of components as a parameter and wraps 
>>> them in pages
>>> (defn wrap-components [components]
>>>   (fn []
>>>   [:div {:class "components-wrapped-in-pages-so-we-can-swipe-them"}
>>>(for [c components]
>>> [:div {:class "page"} c])]))
>>>
>>>
>>> ; -- MAIN VIEW GLUING ALL TOGETHER
>>>
>>>
>>> (defn main-view []
>>>   (let [reactive-name (ratom "initial-name")
>>> input-state (ratom "")]
>>>[:div {:class "some-boilerplate"}
>>>
>>> ; the two lines below are not following re-frame pattern. There 
>>> are there just to express I have the state which changes.
>>> [:input {:onchange (fn [value] (!reset input-state value))}] ; 
>>> react to inout changes and pass the value to model (in re-frame instead of 
>>> directly updating the model we would send a signal (as in elm) and have 
>>> subscription react to the signal but for simplicity I ommit the patern)
>>> [:button {:onclick #(!reset reactive-name @input-state)}] ; 
>>> copy the states on button click
>>>
>>> [:span {:class 
>>> "here-come-generic-swipe-able-pages-wrapping-any-components"}
>>>
>>>  ; here is the usage of the wrapping container
>>>  (wrap-components [
>>>say-hello ; stateless component
>>>#(hello-component "some-fancy-name") ; 
>>> #(...) is lambda in clojure, here we close over some static state
>>>#(reactive-hello-component reactive-name) ; 
>>> #(...) here we close over some reactive state, so the component re-renders 
>>> when the model (state) changes
>>>#(list-hellos ["a" "b" "c"]) ; component 
>>> taking list as a state (model)
>>>])]]))
>>>
>>> ; -- MOUNT VIEW TO DOM
>>>
>>> ; bind the main-view to DOM and start observing deltas to render if needed
>>> (defn ^:export run []
>>>   (r/render [main-view] (js/document.body)))
>>>
>>>
>>>
>>>
>>> On Wednesday, 18 May 2016 08:42:4

Re: [elm-discuss] Re: How to implement wrapping components in elm

2016-05-18 Thread Daniel Kwiecinski
This is fine. Big thanks for your effort.
But, how about instead of components being simple functions we have 
components as {init, update, view, subscription} so they encapsulate their 
logic. 
Think in having a component similar to google places autocomplete. From 
it's parent we still want to pass a configuration to it and react to the 
commands coming from the autocomplete (such as place changed) but we do not 
want or need to interfere with the autocomplete component internal state, 
rest calls etc?

On Wednesday, 18 May 2016 13:08:21 UTC+1, Peter Damoc wrote:
>
> Oh, that's much easier:
>
> import Html exposing (..) 
> import Html.Attributes exposing (class) 
>
> helloComponent name = 
>   p [] [text ("Hello, " ++ name ++ "!")]
>   
> sayHello = 
>   helloComponent "world" 
>
>
> listHello names = 
>   div [] (List.map helloComponent names) 
>
>
> -- GENERIC WRAPPING COMPONENT
>
> wrapComponents components = 
>   div [class "components-wrapped-in-pages-so-we-can-swipe-them"]
>   (List.map (\c -> div [class "page"] [c]) components)
>
>
> names = ["Jim", "Bill", "Joe"]
>
>
> main = 
>   wrapComponents 
> [ sayHello
> , helloComponent "Sandra"
> , listHello names
> ]
>
> There is no Signal anymore in Elm and if you use The Elm Architecture, all 
> you get is regular values. 
>
>
>
>
> On Wed, May 18, 2016 at 1:15 PM, Daniel Kwiecinski  > wrote:
>
>> Here is a sketch of how it would look like in reagent (ClojureScript)
>>
>>
>> ; -- SOME CONCRETE COMPONENTS
>>
>> ; a component taking a String as a model
>> (defn hello-component [name]
>>   [:p "Hello, " name "!"])
>>
>> ; a stateless component using another component
>> (defn say-hello []
>>   [hello-component "world"])
>>
>> ; a component taking a ratom (it's a signal in elm speak) as a model
>> (defn reactive-hello-component [name]
>>   [:p "Hello, " @name "!"])
>>
>> ; a component taking list of Strings as a model
>> (defn list-hellos [names]
>>   (for [n names]
>>[hello-component (str "hello " n)]))
>>
>> ; -- GENERIC WRAPPING COMPONENT
>>
>>
>> ; a wrapping components. take list of components as a parameter and wraps 
>> them in pages
>> (defn wrap-components [components]
>>   (fn []
>>   [:div {:class "components-wrapped-in-pages-so-we-can-swipe-them"}
>>(for [c components]
>> [:div {:class "page"} c])]))
>>
>>
>> ; -- MAIN VIEW GLUING ALL TOGETHER
>>
>>
>> (defn main-view []
>>   (let [reactive-name (ratom "initial-name")
>> input-state (ratom "")]
>>[:div {:class "some-boilerplate"}
>>
>> ; the two lines below are not following re-frame pattern. There 
>> are there just to express I have the state which changes.  
>> [:input {:onchange (fn [value] (!reset input-state value))}] ; 
>> react to inout changes and pass the value to model (in re-frame instead of 
>> directly updating the model we would send a signal (as in elm) and have 
>> subscription react to the signal but for simplicity I ommit the patern)
>> [:button {:onclick #(!reset reactive-name @input-state)}] ; copy 
>> the states on button click
>>
>> [:span {:class 
>> "here-come-generic-swipe-able-pages-wrapping-any-components"}
>>
>>  ; here is the usage of the wrapping container
>>  (wrap-components [
>>say-hello ; stateless component
>>#(hello-component "some-fancy-name") ; #(...) 
>> is lambda in clojure, here we close over some static state
>>#(reactive-hello-component reactive-name) ; 
>> #(...) here we close over some reactive state, so the component re-renders 
>> when the model (state) changes
>>#(list-hellos ["a" "b" "c"]) ; component 
>> taking list as a state (model)
>>])]]))
>>
>> ; -- MOUNT VIEW TO DOM
>>
>> ; bind the main-view to DOM and start observing deltas to render if needed
>> (defn ^:export run []
>>   (r/render [main-view] (js/document.body)))
>>
>>
>>
>>
>> On Wednesday, 18 May 2016 08:42:45 UTC+1, Peter Damoc wrote:
>>>
>>> Can you mock some code that would show how would you like to use this? 
>>> Imagine that it is already implemented in some library and write against 
>>> that imaginary library. 
>>>
>>>
>>>
>>>
>>> On Tue, May 17, 2016 at 5:36 PM, Daniel Kwiecinski <
>>> daniel.k...@gmail.com> wrote:
>>>
 The problem is that the generic container component (Let's call it C) 
 do not know about it potential children (let's call them X, Y, Z) . There 
 is top level component (Let's call it T) which has a knowledge about all 
 of 
 them (it is the app). The C is in self contained package, you can consider 
 it to implement material design list view. How Can I implement C so T can 
 use T with X, Y, Z ?

 On Tuesday, 17 May 2016 15:09:36 UTC+1, Peter Damoc wrote:
>
> Hi Daniel,

Re: [elm-discuss] Re: How to implement wrapping components in elm

2016-05-18 Thread Peter Damoc
Oh, that's much easier:

import Html exposing (..)
import Html.Attributes exposing (class)

helloComponent name =
  p [] [text ("Hello, " ++ name ++ "!")]

sayHello =
  helloComponent "world"


listHello names =
  div [] (List.map helloComponent names)


-- GENERIC WRAPPING COMPONENT

wrapComponents components =
  div [class "components-wrapped-in-pages-so-we-can-swipe-them"]
  (List.map (\c -> div [class "page"] [c]) components)


names = ["Jim", "Bill", "Joe"]


main =
  wrapComponents
[ sayHello
, helloComponent "Sandra"
, listHello names
]

There is no Signal anymore in Elm and if you use The Elm Architecture, all
you get is regular values.




On Wed, May 18, 2016 at 1:15 PM, Daniel Kwiecinski <
daniel.kwiecin...@gmail.com> wrote:

> Here is a sketch of how it would look like in reagent (ClojureScript)
>
>
> ; -- SOME CONCRETE COMPONENTS
>
> ; a component taking a String as a model
> (defn hello-component [name]
>   [:p "Hello, " name "!"])
>
> ; a stateless component using another component
> (defn say-hello []
>   [hello-component "world"])
>
> ; a component taking a ratom (it's a signal in elm speak) as a model
> (defn reactive-hello-component [name]
>   [:p "Hello, " @name "!"])
>
> ; a component taking list of Strings as a model
> (defn list-hellos [names]
>   (for [n names]
>[hello-component (str "hello " n)]))
>
> ; -- GENERIC WRAPPING COMPONENT
>
>
> ; a wrapping components. take list of components as a parameter and wraps 
> them in pages
> (defn wrap-components [components]
>   (fn []
>   [:div {:class "components-wrapped-in-pages-so-we-can-swipe-them"}
>(for [c components]
> [:div {:class "page"} c])]))
>
>
> ; -- MAIN VIEW GLUING ALL TOGETHER
>
>
> (defn main-view []
>   (let [reactive-name (ratom "initial-name")
> input-state (ratom "")]
>[:div {:class "some-boilerplate"}
>
> ; the two lines below are not following re-frame pattern. There 
> are there just to express I have the state which changes.
> [:input {:onchange (fn [value] (!reset input-state value))}] ; 
> react to inout changes and pass the value to model (in re-frame instead of 
> directly updating the model we would send a signal (as in elm) and have 
> subscription react to the signal but for simplicity I ommit the patern)
> [:button {:onclick #(!reset reactive-name @input-state)}] ; copy 
> the states on button click
>
> [:span {:class 
> "here-come-generic-swipe-able-pages-wrapping-any-components"}
>
>  ; here is the usage of the wrapping container
>  (wrap-components [
>say-hello ; stateless component
>#(hello-component "some-fancy-name") ; #(...) 
> is lambda in clojure, here we close over some static state
>#(reactive-hello-component reactive-name) ; 
> #(...) here we close over some reactive state, so the component re-renders 
> when the model (state) changes
>#(list-hellos ["a" "b" "c"]) ; component 
> taking list as a state (model)
>])]]))
>
> ; -- MOUNT VIEW TO DOM
>
> ; bind the main-view to DOM and start observing deltas to render if needed
> (defn ^:export run []
>   (r/render [main-view] (js/document.body)))
>
>
>
>
> On Wednesday, 18 May 2016 08:42:45 UTC+1, Peter Damoc wrote:
>>
>> Can you mock some code that would show how would you like to use this?
>> Imagine that it is already implemented in some library and write against
>> that imaginary library.
>>
>>
>>
>>
>> On Tue, May 17, 2016 at 5:36 PM, Daniel Kwiecinski > > wrote:
>>
>>> The problem is that the generic container component (Let's call it C) do
>>> not know about it potential children (let's call them X, Y, Z) . There is
>>> top level component (Let's call it T) which has a knowledge about all of
>>> them (it is the app). The C is in self contained package, you can consider
>>> it to implement material design list view. How Can I implement C so T can
>>> use T with X, Y, Z ?
>>>
>>> On Tuesday, 17 May 2016 15:09:36 UTC+1, Peter Damoc wrote:

 Hi Daniel,

 If you have a limited number of components you can unify them into one
 kind of a component.

 Here is a self contained example that unifies Counter and RandomGif and
 then uses them in a single list.
 https://gist.github.com/pdamoc/aef6306a9001de109aeece37e5627d06




 On Tue, May 17, 2016 at 3:47 PM, Daniel Kwiecinski <
 daniel.k...@gmail.com> wrote:

> So let me expand my scenario a little bit. Lets assume that the
> CounterList component is very feature heavy. It makes lots of work to
> layout its children, manages drag to sort or whatever fancy stuff you can
> imagine. Now in my app I have many instances of usage of CounterList and I
> want to apply the complex behaviou

Re: [elm-discuss] Re: How to implement wrapping components in elm

2016-05-18 Thread Yosuke Torii
Oh, it looks just nesting views (I'm not familiar with ClojureScript
though). If so, the solution is much simpler. Like this:

```
container : List (Html msg) -> Html msg
container children =
  div
[  style [ ("padding", "20px") ] ]
children
```

full version


Isn't it working for you? I often use this pattern for popup.


2016-05-18 19:15 GMT+09:00 Daniel Kwiecinski :

> Here is a sketch of how it would look like in reagent (ClojureScript)
>
>
> ; -- SOME CONCRETE COMPONENTS
>
> ; a component taking a String as a model
> (defn hello-component [name]
>   [:p "Hello, " name "!"])
>
> ; a stateless component using another component
> (defn say-hello []
>   [hello-component "world"])
>
> ; a component taking a ratom (it's a signal in elm speak) as a model
> (defn reactive-hello-component [name]
>   [:p "Hello, " @name "!"])
>
> ; a component taking list of Strings as a model
> (defn list-hellos [names]
>   (for [n names]
>[hello-component (str "hello " n)]))
>
> ; -- GENERIC WRAPPING COMPONENT
>
>
> ; a wrapping components. take list of components as a parameter and wraps 
> them in pages
> (defn wrap-components [components]
>   (fn []
>   [:div {:class "components-wrapped-in-pages-so-we-can-swipe-them"}
>(for [c components]
> [:div {:class "page"} c])]))
>
>
> ; -- MAIN VIEW GLUING ALL TOGETHER
>
>
> (defn main-view []
>   (let [reactive-name (ratom "initial-name")
> input-state (ratom "")]
>[:div {:class "some-boilerplate"}
>
> ; the two lines below are not following re-frame pattern. There 
> are there just to express I have the state which changes.
> [:input {:onchange (fn [value] (!reset input-state value))}] ; 
> react to inout changes and pass the value to model (in re-frame instead of 
> directly updating the model we would send a signal (as in elm) and have 
> subscription react to the signal but for simplicity I ommit the patern)
> [:button {:onclick #(!reset reactive-name @input-state)}] ; copy 
> the states on button click
>
> [:span {:class 
> "here-come-generic-swipe-able-pages-wrapping-any-components"}
>
>  ; here is the usage of the wrapping container
>  (wrap-components [
>say-hello ; stateless component
>#(hello-component "some-fancy-name") ; #(...) 
> is lambda in clojure, here we close over some static state
>#(reactive-hello-component reactive-name) ; 
> #(...) here we close over some reactive state, so the component re-renders 
> when the model (state) changes
>#(list-hellos ["a" "b" "c"]) ; component 
> taking list as a state (model)
>])]]))
>
> ; -- MOUNT VIEW TO DOM
>
> ; bind the main-view to DOM and start observing deltas to render if needed
> (defn ^:export run []
>   (r/render [main-view] (js/document.body)))
>
>
>
>
> On Wednesday, 18 May 2016 08:42:45 UTC+1, Peter Damoc wrote:
>>
>> Can you mock some code that would show how would you like to use this?
>> Imagine that it is already implemented in some library and write against
>> that imaginary library.
>>
>>
>>
>>
>> On Tue, May 17, 2016 at 5:36 PM, Daniel Kwiecinski > > wrote:
>>
>>> The problem is that the generic container component (Let's call it C) do
>>> not know about it potential children (let's call them X, Y, Z) . There is
>>> top level component (Let's call it T) which has a knowledge about all of
>>> them (it is the app). The C is in self contained package, you can consider
>>> it to implement material design list view. How Can I implement C so T can
>>> use T with X, Y, Z ?
>>>
>>> On Tuesday, 17 May 2016 15:09:36 UTC+1, Peter Damoc wrote:

 Hi Daniel,

 If you have a limited number of components you can unify them into one
 kind of a component.

 Here is a self contained example that unifies Counter and RandomGif and
 then uses them in a single list.
 https://gist.github.com/pdamoc/aef6306a9001de109aeece37e5627d06




 On Tue, May 17, 2016 at 3:47 PM, Daniel Kwiecinski <
 daniel.k...@gmail.com> wrote:

> So let me expand my scenario a little bit. Lets assume that the
> CounterList component is very feature heavy. It makes lots of work to
> layout its children, manages drag to sort or whatever fancy stuff you can
> imagine. Now in my app I have many instances of usage of CounterList and I
> want to apply the complex behaviour not only to counters but also to gif
> and to mixed counters with gifs and many many other possible 
> configurations
> (think in hundreds). I don't really want to implement dedicated
> CounterList, GifList, 2GifsWith3CountersList and other few hundreds
> SomethingBlaBlaList.
> Is it possi

Re: [elm-discuss] Re: How to implement wrapping components in elm

2016-05-18 Thread Daniel Kwiecinski
Here is a sketch of how it would look like in reagent (ClojureScript)


; -- SOME CONCRETE COMPONENTS

; a component taking a String as a model
(defn hello-component [name]
  [:p "Hello, " name "!"])

; a stateless component using another component
(defn say-hello []
  [hello-component "world"])

; a component taking a ratom (it's a signal in elm speak) as a model
(defn reactive-hello-component [name]
  [:p "Hello, " @name "!"])

; a component taking list of Strings as a model
(defn list-hellos [names]
  (for [n names]
   [hello-component (str "hello " n)]))

; -- GENERIC WRAPPING COMPONENT


; a wrapping components. take list of components as a parameter and wraps them 
in pages
(defn wrap-components [components]
  (fn []
  [:div {:class "components-wrapped-in-pages-so-we-can-swipe-them"}
   (for [c components]
[:div {:class "page"} c])]))


; -- MAIN VIEW GLUING ALL TOGETHER


(defn main-view []
  (let [reactive-name (ratom "initial-name")
input-state (ratom "")]
   [:div {:class "some-boilerplate"}

; the two lines below are not following re-frame pattern. There are 
there just to express I have the state which changes.  
[:input {:onchange (fn [value] (!reset input-state value))}] ; 
react to inout changes and pass the value to model (in re-frame instead of 
directly updating the model we would send a signal (as in elm) and have 
subscription react to the signal but for simplicity I ommit the patern)
[:button {:onclick #(!reset reactive-name @input-state)}] ; copy 
the states on button click

[:span {:class 
"here-come-generic-swipe-able-pages-wrapping-any-components"}

 ; here is the usage of the wrapping container
 (wrap-components [
   say-hello ; stateless component
   #(hello-component "some-fancy-name") ; #(...) is 
lambda in clojure, here we close over some static state
   #(reactive-hello-component reactive-name) ; 
#(...) here we close over some reactive state, so the component re-renders when 
the model (state) changes
   #(list-hellos ["a" "b" "c"]) ; component taking 
list as a state (model)
   ])]]))

; -- MOUNT VIEW TO DOM

; bind the main-view to DOM and start observing deltas to render if needed
(defn ^:export run []
  (r/render [main-view] (js/document.body)))




On Wednesday, 18 May 2016 08:42:45 UTC+1, Peter Damoc wrote:
>
> Can you mock some code that would show how would you like to use this? 
> Imagine that it is already implemented in some library and write against 
> that imaginary library. 
>
>
>
>
> On Tue, May 17, 2016 at 5:36 PM, Daniel Kwiecinski  > wrote:
>
>> The problem is that the generic container component (Let's call it C) do 
>> not know about it potential children (let's call them X, Y, Z) . There is 
>> top level component (Let's call it T) which has a knowledge about all of 
>> them (it is the app). The C is in self contained package, you can consider 
>> it to implement material design list view. How Can I implement C so T can 
>> use T with X, Y, Z ?
>>
>> On Tuesday, 17 May 2016 15:09:36 UTC+1, Peter Damoc wrote:
>>>
>>> Hi Daniel, 
>>>
>>> If you have a limited number of components you can unify them into one 
>>> kind of a component. 
>>>
>>> Here is a self contained example that unifies Counter and RandomGif and 
>>> then uses them in a single list. 
>>> https://gist.github.com/pdamoc/aef6306a9001de109aeece37e5627d06
>>>
>>>
>>>
>>>
>>> On Tue, May 17, 2016 at 3:47 PM, Daniel Kwiecinski <
>>> daniel.k...@gmail.com> wrote:
>>>
 So let me expand my scenario a little bit. Lets assume that the 
 CounterList component is very feature heavy. It makes lots of work to 
 layout its children, manages drag to sort or whatever fancy stuff you can 
 imagine. Now in my app I have many instances of usage of CounterList and I 
 want to apply the complex behaviour not only to counters but also to gif 
 and to mixed counters with gifs and many many other possible 
 configurations 
 (think in hundreds). I don't really want to implement dedicated 
 CounterList, GifList, 2GifsWith3CountersList and other few hundreds 
 SomethingBlaBlaList.
 Is it possible in elm at all? If yes how so?

 P.S. It is not imaginary question. I try to port existing application 
 implemented in Re-Frame (ClojureScript framework) in which this scenario 
 is 
 trivial.


 On Tuesday, 17 May 2016 13:33:27 UTC+1, Wil C wrote:
>
> Daniel,
>
> I think normally, you don't. I think the constraint here is that you 
> need to explicitly set the types of each of the sub-components for every 
> component that you make for a page. In the example that you give, you'd 
> actually need to create 4 types of components: T

[elm-discuss] Knowing if Dict has changed

2016-05-18 Thread surfncode
Hello everyone,

Is there a way to know quickly if a dict has changed ? I know I could 
iterate over all key value pairs but is there a way to do it faster. I 
understand from reading the docs than the equality operator is unreliable 
when used on Dict but am I correct to assume that if I have to a Dict a and 
that I produce a dict a' by calling one of the Dict function, a and a' 
 should be the same object if the function called did not change a ?

Example: 
a = Dict.fromList [(0,"Alice"),(1,"Bob")]
a' =Dict.remove 3 a
-- key 3 doesn't exist so a' should be unchanged compare to a

It just would seem silly to have to perform a deep comparison between a and 
a' if there is a way to know they have the same object reference internally.

If there is a way to do that, can it work with Array and Set also ?
 

-- 
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: Pong example in Elm 0.17

2016-05-18 Thread Wil C
The mario example in 0.17

https://gist.github.com/pdamoc/6f7aa2d3774e5af58ebeba369637c228

On Thursday, May 12, 2016 at 12:59:13 AM UTC-7, Sean Seefried wrote:
>
> Hi all,
>
> I just started using Elm about 2 weeks ago. I had a lot of fun playing 
> with the Pong example and even started making my own game in Elm. I'm a 
> long time Haskell programmer and since Elm is very Haskell-like I've found 
> it very easy to use.
>
> Then Elm 0.17 came out and suddenly Signals are gone. "No problem", I 
> thought, "I'll just look at how Pong is implemented now and update my game".
>
> But then I discovered that the Pong example is now gone. So I decided to 
> look through the new libraries to see how graphics were done now ... and 
> discovered that I couldn't find how to do HTML Canvas-style graphics 
> anymore.
>
> So, my two questions are:
>
> 1. Is the Pong example being rewritten in Elm?
> 2. How do I do HTML canvas-style graphics now? 
>
> Cheers,
>
> Sean
>
> p.s. Please don't take the tone of this post the wrong way. I'm very happy 
> to keep up with Elm as it evolves. I just want to know how to reimplement 
> my game as quickly as possible! :-) 
>

-- 
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-hot-loader: 0.17 Hot-reloading

2016-05-18 Thread John Orford
Could you give a use case? It's not 100% clear to me what this does.

On Wed, 18 May 2016 at 10:05 Flux Xu  wrote:

> Hi,
>
> I just published elm-hot-loader 0.3.0 to supports hot-reloading with Elm
> 0.17
> Swap port and EmptyAction are gone. No modification of your code is
> needed, it just works.
>
> Project repository: https://github.com/fluxxu/elm-hot-loader
> Example project: https://github.com/fluxxu/elm-hot-loader-starter
>
> Hope you will find it useful!
>
> --
> 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] elm-hot-loader: 0.17 Hot-reloading

2016-05-18 Thread Flux Xu
Hi,

I just published elm-hot-loader 0.3.0 to supports hot-reloading with Elm 
0.17
Swap port and EmptyAction are gone. No modification of your code is needed, 
it just works.

Project repository: https://github.com/fluxxu/elm-hot-loader
Example project: https://github.com/fluxxu/elm-hot-loader-starter

Hope you will find it useful!

-- 
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 implement wrapping components in elm

2016-05-18 Thread Peter Damoc
Can you mock some code that would show how would you like to use this?
Imagine that it is already implemented in some library and write against
that imaginary library.




On Tue, May 17, 2016 at 5:36 PM, Daniel Kwiecinski <
daniel.kwiecin...@gmail.com> wrote:

> The problem is that the generic container component (Let's call it C) do
> not know about it potential children (let's call them X, Y, Z) . There is
> top level component (Let's call it T) which has a knowledge about all of
> them (it is the app). The C is in self contained package, you can consider
> it to implement material design list view. How Can I implement C so T can
> use T with X, Y, Z ?
>
> On Tuesday, 17 May 2016 15:09:36 UTC+1, Peter Damoc wrote:
>>
>> Hi Daniel,
>>
>> If you have a limited number of components you can unify them into one
>> kind of a component.
>>
>> Here is a self contained example that unifies Counter and RandomGif and
>> then uses them in a single list.
>> https://gist.github.com/pdamoc/aef6306a9001de109aeece37e5627d06
>>
>>
>>
>>
>> On Tue, May 17, 2016 at 3:47 PM, Daniel Kwiecinski > > wrote:
>>
>>> So let me expand my scenario a little bit. Lets assume that the
>>> CounterList component is very feature heavy. It makes lots of work to
>>> layout its children, manages drag to sort or whatever fancy stuff you can
>>> imagine. Now in my app I have many instances of usage of CounterList and I
>>> want to apply the complex behaviour not only to counters but also to gif
>>> and to mixed counters with gifs and many many other possible configurations
>>> (think in hundreds). I don't really want to implement dedicated
>>> CounterList, GifList, 2GifsWith3CountersList and other few hundreds
>>> SomethingBlaBlaList.
>>> Is it possible in elm at all? If yes how so?
>>>
>>> P.S. It is not imaginary question. I try to port existing application
>>> implemented in Re-Frame (ClojureScript framework) in which this scenario is
>>> trivial.
>>>
>>>
>>> On Tuesday, 17 May 2016 13:33:27 UTC+1, Wil C wrote:

 Daniel,

 I think normally, you don't. I think the constraint here is that you
 need to explicitly set the types of each of the sub-components for every
 component that you make for a page. In the example that you give, you'd
 actually need to create 4 types of components: TopLevel, Counter,
 CounterList, and Gif.

 TopLevel component would include CounterList and Gif. And then
 CounterList would contain Counters. It is CounterList's job to dynamically
 keep track of the number of Counters. That way, you don't need a generic
 component to contain an unknown number of things with unknown types. And
 then if those components need to talk to each other (Like once you add 5 or
 more counters, you see a funny cat gif), I believe you can send messages
 through Cmds (in 0.17) or Effects (in <0.17).

 With the hierarchical thinking of laying out components, I found that 
 Thinking
 in React 
 helps.

 If you find that you really need the flexibility of having different
 components in a container, it's doable. But it comes at a cost. Generally,
 if you're making a web app of some sort, it's not needed. I cover entity
 component systems recently in another thread, and it's for games.

 https://groups.google.com/forum/#!topic/elm-discuss/c9MhBzVPbr8

 Wil

 On Tuesday, May 17, 2016 at 5:13:56 AM UTC-7, Daniel Kwiecinski wrote:
>
> Hi Elmers,
>
>
> Here is my scenario. Say I have Main.elm which defines main view form
> my application. I also have bunch of other components (with their
> corresponding model  and message types) say Counter and Gif.
> (
> https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/Gif.elm
> )
> (
> https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/Counter.elm
> )
> Now I'd like to create new generic component which as a parameter
> (initial value of its model?) takes list of any type of component (say two
> counters, then one gif and another three counters) and wraps them into 
> some
> decorating html.
> The scenario serves as a illustration of the question, how do I
> implement components which can wrap lists of arbitrary component types.
>
> --
> Regards,
> Daniel
>
 --
>>> 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 Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop re