
Daniel Wagner wrote:
On 2013-07-18 10:46, harry wrote:
Why not let all types carry the dictionary automatically, or at least every time that it's used, if that would incur a memory/performance penalty? GHC tells me which context to add when it's missing, so it clearly knows.
I'm not sure the claim in your second sentence is true. For example,
foo :: a -> a -> Bool foo = (==)
bar :: a -> a -> Bool bar = foo
GHC (rightly) complains about foo, but makes no complaint about bar. That is, if a thing only works in the presence of a constraint, you need to have that constraint visible in the type, every time, or else downstream dependencies can reasonably make wrong assumptions.
It does complain about bar after adding the context to foo, so the proposal still seems to hold. In any case, would there actually be a performance penalty in adding it everywhere?