[GHC] #13032: Redundant forcing of Given dictionaries
GHC
ghc-devs at haskell.org
Wed Jan 4 09:02:37 UTC 2017
#13032: Redundant forcing of Given dictionaries
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Let's leave aside the deferred-type-error case for now.
Other than that, I claim that '''every evidence variable should be non-
bottom''', and so
* Can be evaluated strictly, and/or
* Its evaluation can be discarded if its payload is not required
This is true even of recursively-defined dictionaries; see `Note
[Recursive superclasses]` in `TcInstDcls`. (A recursively-defined
dictionary may be infinite, so you can't evaluate it hyper-strictly, but
it should not be bottom.)
But dictionaries still ''can'' be defined recursively (unlike say unboxed
values).
Now, I believe all this is true of the programs generated by source
Haskell, but nothing in Core checks this invariant; and in Core you could
certainly declare a bottom dictionary `(let d = d in ...)`. I don't know
how to make it a statically-checkable invariant of Core, but I expect that
it'd be possible to make a decent conservative approximation that was
enough to capture the programs generated from source Haskell.
There's even an old flag `-fdicts-strict` that I would like to get back
to, which flirted with using call-by-value for evidence variables; c.f.
#2436
That leaves deferred type errors. But let's not allow the tail to wag the
dog.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13032#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list