I had similar feelings; lazy uses a magical referential equality between 
things that afaik isn't exposed elsewhere; to me it would be more 
obvious/clear if it used the same sort of equality as everything else (==), 
which I'd hope would be able to short circuit the meat of the checking if 
referentially equal anyway.

Basically, I'd be interested to hear more about the decision to use 
referential equality with lazy too :)

On Tuesday, 13 September 2016 12:09:05 UTC+1, Yosuke Torii wrote:
>
> Hi,
>
> I have a question about Html.Lazy.
>
> Now I'm optimizing rendering using Html.Lazy but I feel it is difficult to 
> use. I found the arguments are not often *referentially* equal and the 
> view functions are unfortunately called. There are some problems around 
> this.
>
>
> 1. Sometimes new values are created every time.
>
> view model = lazy someView { data = model.data }
>
> 2. Views do not know how arguments are passed.
>
> view model = lazy grandchildView model
>
> 3. It is not easy to know if optimization succeeds or not.
>
> view model = Debug.log "Unfortunately called!" <| text (toString model)
>
>
> I made a demo to describe this problem.
>
> Source: https://github.com/jinjor/elm-issues/blob/master/src/HtmlLazy.elm
> Demo: https://jinjor.github.io/elm-issues/html-lazy.html
> (9 example views, but 4 ~ 9 are not optimized unfortunately)
>
> So my question is:
>
>    - Is it a bad idea to compare by *normal *equal? 
>    - Have anyone already solved this problem?
>
>
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to