How important is this optimization to you? And do you really need it to work for the most general case?
Making your code more complicated, in the hopes of exploiting an undocumented behavior of the compiler, is something you ought to avoid unless you are certain that it is necessary. If all you care about is whether Dict.remove actually removed something, you could compare the size of the Dict before to the size of the Dict after. On Wed, May 18, 2016 at 11:37 AM, surfncode <jdupay...@gmail.com> wrote: > > I hadn't thought of that, that's true indeed. > > Here are some other example using dictEquals. Do you think the d1==d2 > short-circuit would still work in those cases? > > dictEquals : Dict comparable b -> Dict comparable b -> Bool > dictEquals d1 d2 = > d1 == d2 || Dict.toList d1 == Dict.toList d2 > > -- Example 1 > a = Dict.fromList [(0,"Alice"),(1,"Bob")] > a' =Dict.insert 2 "Anna" a; > a'' = Dict.remove 3 a'; -- a'' should be unchanged compared to a' > isSame = dictEquals a' a''-- will this call fall back to evaluating > Dict.toList > d1 == Dict.toList d2 ? > > -- Example 2 > a = Dict.fromList [(0,"Alice"),(1,"Bob")] > a' =Dict.insert 3 "Anna" a; > a'' = Dict.remove 4 a'; -- a'' should be unchanged compared to a' > isSame = dictEquals a' a'' -- will this call fall back to evaluating > Dict.toList > d1 == Dict.toList d2 ? > > > > > > > -- > 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.