'Caching' of results of default instance definitions
Clinton Mead
clintonmead at gmail.com
Wed Nov 23 01:28:46 UTC 2022
Hi All
My apologies if this is the wrong place to post questions about GHC
internals from a non-GHC dev, I thought about using GHC Users but it seems
quiet on that mailing list and I think my question relates closely to how
GHC implements things, so I suspect only a dev could answer anyway.
I have posted the following StackOverflow question:
https://stackoverflow.com/questions/74540639/when-are-the-results-of-default-methods-in-instances-cached
I won't repeat the full contents here, but basically my question is that if
I have a class with a "method" which has a default definition, and that
default definition has no arguments on the LHS, will a separate "instance"
of that default definition be created for each instance of that class that
inherits that default definition? The important consequence of that being
that the default definition is only computed once per type.
Or is the default definition treated as a definition generalised over a
typeclass, and hence having a hidden typeclass variable and therefore
treated as a function, so it needs to be recomputed every time it's
referenced?
Any feedback or references will be appreciated.
Thanks,
Clinton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20221123/4decb889/attachment.html>
More information about the ghc-devs
mailing list