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

2016-05-17 Thread Matthew Griffith

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.


[elm-discuss] 0.17 alternative to Task.sleep

2016-05-17 Thread Richard Osafo
Hi,
What is the equivalence of Task.sleep in Elm 0.17?


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] How to map multi-level nesting components in 0.17

2016-05-17 Thread Nick H
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+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] Howto filter on Sub

2016-05-17 Thread Janis Voigtländer
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
 mapped Sub).
 >> A potential problem I see with this is when there is more than one
 >> update-function. Several components in a TEA setting, somehow
 combined.
 >> Couldn’t the new suggestion mean that one has to duplicate the
 if-then-else
 >> logic in several update-functions?
 >
 > Not in my understanding.
 > In a TEA setting, the top most component could do all the processing
 needed
 > and pass to the children only the relevant information.
 > This top level component could also use something like Lazy in the
 view to
 > optimize for "fake" updates.
 >
 > Basically, all the logic from around the subscriptions would end up
 in the
 > too most component.
 >
 >
 >
 >
 > --
 > 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...@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 

Re: [elm-discuss] Howto filter on Sub

2016-05-17 Thread 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 
>>> mapped Sub). 
>>> >> A potential problem I see with this is when there is more than one 
>>> >> update-function. Several components in a TEA setting, somehow 
>>> combined. 
>>> >> Couldn’t the new suggestion mean that one has to duplicate the 
>>> if-then-else 
>>> >> logic in several update-functions? 
>>> > 
>>> > Not in my understanding. 
>>> > In a TEA setting, the top most component could do all the processing 
>>> needed 
>>> > and pass to the children only the relevant information. 
>>> > This top level component could also use something like Lazy in the 
>>> view to 
>>> > optimize for "fake" updates. 
>>> > 
>>> > Basically, all the logic from around the subscriptions would end up in 
>>> the 
>>> > too most component. 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > -- 
>>> > 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...@googlegroups.com. 
>>> > For more options, visit https://groups.google.com/d/optout. 
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to elm-discuss...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

Re: [elm-discuss] Re: Is Elm for us? Non-developers building small applets

2016-05-17 Thread Salomon Turgman Cohen
Thank you all for the comments.

John,

Can you point out what are the currently existing charting/graphing
features in elm? I am going to implement a simple simulation without any
graphics (just displaying numbers and controls perhaps) first. It seems
that when I need to start with graphics elm/svg should be enough?

Erkal,
That looks great! I will try it out as well.

Joshua,
I learned about the update the hard way, I was reading 0.16 docs when the
update happened and everything changed. It was quite shocking (my first
experience with a young and developing language). But I think I know what
to expect and the downside of adopting something still in development.

-s-

Salomon Turgman Cohen
Assistant Professor
Chemical Engineering
Kettering University
(810)249-4045

On Mon, May 16, 2016 at 9:34 AM, Joshua Mendoza 
wrote:

> Since the Elm architecture needs to have a consistent model all the time
> you can think of the variables and preconditions of an experiment as part
> of that model and everything you need to do is to provide a view (HTML
> code) that reflects this state (I was looking at your Compressed Gas Spray
> example, all buttons and controls can be modeled that way very well).
> Consequently, every control change needs to be reflected in an update
> function that changes one piece of this model (variables a preconditions
> corpus) and the wiring (commanding actions, effects, consequences that
> change the model) needs to be done with these concepts:
>
> http://guide.elm-lang.org/architecture/user_input/forms.html
> http://guide.elm-lang.org/architecture/effects/time.html
>
> My personal recommendation if you're to follow the Elm path, is to wait a
> little bit since there has been an important upgrade in the core Language
> and many of us are struggling to keep up with the changes (I mean,
> everything got easier but previous work and libraries have been rendered
> useless because of API changes).
>
>
>
> On Sunday, May 15, 2016 at 8:09:49 AM UTC-5, Salomon Turgman Cohen wrote:
>>
>> Dear Elm community,
>> I am interested in building little educational demos like those shown in
>> this website http://www.learncheme.com/simulations The ones in that
>> website require player software that is almost 800 MB,and I feel we can do
>> better. It seems like Elm is a good tool to approach this, but I'm
>> wondering if it is overkill. Maybe there is a simpler approach I can
>> follow? What are the advantages of using Elm for something small like this
>> over the alternative (a combo of JS Libraries)?
>>
>> Thanks for your advice.
>>
>> -s-
>>
>> --
> 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/QYnfIXTjahY/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] How to render at a lower fps in 0.17?

2016-05-17 Thread Peter Damoc
Oh well, you can always use an accumulator like `timeSinceLastFrame` and
check it against some timePerFrame that you want.
If the time is greater than timePerFrame, reset to
(timeSinceLastFrame-timePerFrame) and update the module state. If not, just
add the delta to timeSinceLastFrame.

You won't get the precision of a specific FPS but you should get a
consistent behavior.




On Tue, May 17, 2016 at 3:37 PM, Wil C  wrote:

> Good questions. Maybe I should state the problem first.
>
> I'm writing a simple game, which makes me think that using
> AnimationFrame.diff is the right way to go, since it lines up with the
> browser's rendering. I want to spend less time rendering, and use that time
> for other things, like calculating next enemy movements. Since I think my
> game would still be fun at 30fps, I'd want to run it at half speed.
>
> Wil
>
>
> On Monday, May 16, 2016 at 11:01:46 PM UTC-7, Max Goldstein wrote:
>>
>> You can use Time.every to get deltas if you store the old one in the
>> model. The best use, other than the actual time, is things you want to
>> happen periodically but the exact millisecond doesn't matter. If you're
>> doing animation, I'll echo Peter: what's wrong with animating on the
>> browser's exact frames?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



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

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


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

2016-05-17 Thread Wil C
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2016-05-17 Thread Daniel Kwiecinski
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Problem with Subscriptions in 0.17

2016-05-17 Thread Zachary Kessin
The final part of moving my code base over to 0.17...

I have a port/subscription which is used to authenticate from an OAuth btn
and it is getting the wrong type.

In main i have this   *subscriptions = Instagram.subscriptions*

and in the Instagram module I have this code

*port instagramAuth  : ( Maybe String -> msg) -> Sub msg*

*subscriptions model =*
*  instagramAuth SetInstagramOAuth*

And I am getting this error


197|App.programWithFlags
198|>{
199|>  init  = init
200|>, update= update
201|>, view  = view
202|>, subscriptions = Instagram.subscriptions
203|>}

Function `programWithFlags` is expecting the argument to be:

{ ..., subscriptions : Model -> Sub Msg }

But it is:

{ ..., subscriptions : Model -> Sub Instagram.Msg }

Detected errors in 1 module.

I think I need to do some kind of Map but I am not 100% sure what it should
look like and everything I have tried has failed
Zach
-- 
Zach Kessin
Twitter: @zkessin 
Skype: zachkessin
ᐧ

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


[elm-discuss] Json decoding an event target

2016-05-17 Thread Simon
I'm trying to get the text of the selected `option` in a `select` dom 
element.

temp1 is the event object from a change in the select and you can see what 
values it exhibits in devtools 



`selectedOptions` is an array of 1 item



So I expected  `Json.at ["target", "selectedOptions"] <| Json.tuple1 
identity ("text" := Json.string)` to work, but it does not.

Any advice?

Simon

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


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

2016-05-17 Thread Luis Fei
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Mouse-Behaviour with Element and Collage

2016-05-17 Thread MJ
Hi,

i'm working on a simple 2D Level-Editor.
Is there a way to disable unwanted mouse-Behaviour, 
like highlighting with double-click (canvas turns blue), 
or dragging forms,  when using a Collage-Element? 

-- 
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-17 Thread 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] Decode fails on empty string

2016-05-17 Thread Janis Voigtländer
Add this as a comment on the GitHub issue, then?
​

2016-05-17 10:54 GMT+02:00 Fedor Nezhivoi :

> Empty string isn't valid JSON. Try open Chrome DevTools and write
> JSON.parse("").
>
> 2016-05-17 14:51 GMT+06:00 Janis Voigtländer  >:
>
>> See https://github.com/elm-lang/core/issues/585. Considered a bug.
>> ​
>>
>> 2016-05-17 10:45 GMT+02:00 Richard Osafo :
>>
>>> Hi,
>>> I was decoding an http response (body can be blank) and realized that
>>> Decode fails on empty string. Gives the error "Given an invalid JSON:
>>> Syntax error". Is this by design or a bug?
>>>
>>>
>>> import Html exposing (text)
>>> import Json.Decode as Decode exposing (..)
>>>
>>>
>>> main =
>>>   text <| toString test
>>>
>>>
>>> test =
>>>   [ succeed "cool"
>>>   , fail "oh"
>>>   , null "what?"
>>>   ]
>>>   |> List.map (flip decodeString "")
>>>
>>>
>>> If it is by design, what is the recommended way of decoding string that
>>> can be blank.
>>>
>>> For now, I'm using
>>>
>>> let
>>>   x' =
>>> if x == "" then "\"\"" else x
>>> in
>>>   case decodeString decoder x' of
>>> ...
>>>
>>>
>>>
>>> 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.
>>>
>>
>> --
>> 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.
>>
>
>
>
> --
> Best regards,
> Fedor Nezhivoi.
>
> --
> 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] Decode fails on empty string

2016-05-17 Thread Fedor Nezhivoi
Empty string isn't valid JSON. Try open Chrome DevTools and write
JSON.parse("").

2016-05-17 14:51 GMT+06:00 Janis Voigtländer :

> See https://github.com/elm-lang/core/issues/585. Considered a bug.
> ​
>
> 2016-05-17 10:45 GMT+02:00 Richard Osafo :
>
>> Hi,
>> I was decoding an http response (body can be blank) and realized that
>> Decode fails on empty string. Gives the error "Given an invalid JSON:
>> Syntax error". Is this by design or a bug?
>>
>>
>> import Html exposing (text)
>> import Json.Decode as Decode exposing (..)
>>
>>
>> main =
>>   text <| toString test
>>
>>
>> test =
>>   [ succeed "cool"
>>   , fail "oh"
>>   , null "what?"
>>   ]
>>   |> List.map (flip decodeString "")
>>
>>
>> If it is by design, what is the recommended way of decoding string that
>> can be blank.
>>
>> For now, I'm using
>>
>> let
>>   x' =
>> if x == "" then "\"\"" else x
>> in
>>   case decodeString decoder x' of
>> ...
>>
>>
>>
>> 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.
>>
>
> --
> 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.
>



-- 
Best regards,
Fedor Nezhivoi.

-- 
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] Decode fails on empty string

2016-05-17 Thread Janis Voigtländer
See https://github.com/elm-lang/core/issues/585. Considered a bug.
​

2016-05-17 10:45 GMT+02:00 Richard Osafo :

> Hi,
> I was decoding an http response (body can be blank) and realized that
> Decode fails on empty string. Gives the error "Given an invalid JSON:
> Syntax error". Is this by design or a bug?
>
>
> import Html exposing (text)
> import Json.Decode as Decode exposing (..)
>
>
> main =
>   text <| toString test
>
>
> test =
>   [ succeed "cool"
>   , fail "oh"
>   , null "what?"
>   ]
>   |> List.map (flip decodeString "")
>
>
> If it is by design, what is the recommended way of decoding string that
> can be blank.
>
> For now, I'm using
>
> let
>   x' =
> if x == "" then "\"\"" else x
> in
>   case decodeString decoder x' of
> ...
>
>
>
> 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.
>

-- 
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] How to render at a lower fps in 0.17?

2016-05-17 Thread Max Goldstein
You can use Time.every to get deltas if you store the old one in the model. The 
best use, other than the actual time, is things you want to happen periodically 
but the exact millisecond doesn't matter. If you're doing animation, I'll echo 
Peter: what's wrong with animating on the browser's exact frames?

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