The caching behind Elm's Html.Lazy

I think this is possible and probably even variants like “Equality for N levels then Reference check”.
But the problem is likely going to be the API surface, because we’re multiplying number of arguments × equality method (and maybe even more if we decide to give different cache options for every argument).

One downside of multiplying different methods is the intuitiveness, in the sense “which option should I go for? Do I need reference or equality check? Is deep equality going to be too slow? How do I figure that out?”. With only one option there’s no choice. And then it’s up to you to figure out how to make it work for the current lazy approach. Not ideal but at least somewhat simpler.

I think a reasonable solution to combine and fast equality checks and deep equality checks is to take a record like in the lazyShallow proposal, but instead of one, we’d take 2: one for the fast equality check and one for the deep equality check. That would be pretty flexible in practice.

The second argument would actually not even have to be a record I think?), though I think that that would technically allow == between different types (if there’s an unbound parameter like view : { some : record } -> unbound -> Html msg), so we’d need to make sure that’s not a problem in practice.

1 Like