Almost compatible with Html.Lazy
Ideally we can do
HtmlData.Lazy.lazy viewPrime 200000But https://juliu.is/performant-elm-html-lazy/
Html.Lazy needs to associate the cached value with a precise function, but specifying an anonymous function forces the runtime to recreate that function every time the view is invoked.
So to use HtmlData.Lazy, we have to declare a composed version of the function that returns `Html.Html msg`, outside of the view function
viewPrime_elmhtml =
viewPrime >> HtmlData.Extra.toElmHtmlThen pass it in as 2nd argument
HtmlData.Lazy.lazy viewPrime viewPrime_elmhtml 200000The result is that our function signature here isn't 100% identical to Html.Lazy, but it does work in the correctly.
String, e.g. through toTextHtml, there is no lazy effect; the first argument function is run each timeHtml.Html msg, i.e. through toElmHtml, we hand off the 2nd argument to Html.LazySee the prime numbers section on https://html-data.netlify.app