Actually, Html is a very special case. Rendering the same Html multiple
times will give the same result and not cause any visible side effects
(even though it is it DOM manipulations underneath).

This is similar to how the browser distinguishes between GET and POST
requests. It allows the browser (and proxies on the network) to cache GET
responses and know they won't mess up any transactions.

Elm does turn Html into DOM manipulations, but first is has to make a diff
with the last rendered Html. This is what makes Elm's rendering so fast and
efficient. If all commands were treated equally, abstracting away these
optimizations would not be possible.

On Wed, Aug 10, 2016 at 4:04 PM, Charlie Koster <[email protected]> wrote:

> I don't fully understand your explanation but that is in part due to my
> ignorance of the underlying implementation of both Cmd and Html.
>
> Let's see if we can discuss at a more conceptual level. Here is a snippet
> from the Elm examples page:
>
> getRandomGif : String -> Cmd Msg
> getRandomGif topic =
>   let
>     url =
>       "https://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=";
> ++ topic
>   in
>     Task.perform FetchFail FetchSucceed (Http.get decodeGifUrl url)
>
> To me, if the Cmd Msg that is returned from getRandomGif can perform and
> Http request and send one message on failure and send a different message
> on success (I don't know if "send' is the right verb), then I'm not
> understanding why something similar couldn't be done for the DOM.
>
> Performing an HTTP request is a side effect. Manipulating the DOM is also
> a side effect. In both cases, side effects are happening and in both cases
> one message may get "fired" because of some outside interaction either from
> the user or from the server.
>
> I hope that helps clarify why it's hard for me to see DOM manipulation
> side effects as a special case.
>
> --
> 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.
>

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