Slight refactor of stock deriving internals
authorRyan Scott <ryan.gl.scott@gmail.com>
Tue, 20 Feb 2018 17:50:34 +0000 (12:50 -0500)
committerRyan Scott <ryan.gl.scott@gmail.com>
Tue, 20 Feb 2018 17:50:34 +0000 (12:50 -0500)
commitf4336593a390e6317ac2852d8defb54bfa633d3e
treee4d4bb150dbc00fd7e2a924f51c2fe19048a600f
parentf511bb58129f0446d9e74b10b22a127803f7eaf1
Slight refactor of stock deriving internals

Summary:
Before, the `hasStockDeriving` function, which determines
how derived bindings should be generated for stock classes, was
awkwardly separated from the `checkSideConditions` function, which
checks invariants of the same classes that `hasStockDeriving` does.
As a result, there was a fair deal of hoopla needed to actually use
`hasStockDeriving`.

But this hoopla really isn't required—we should be using
`hasStockDeriving` from within `checkSideConditions`, since they're
looking up information about the same classes! By doing this, we can
eliminate some kludgy code in the form of `mk_eqn_stock'`, which had
an unreachable `pprPanic` that was stinking up the place.

Reviewers: bgamari, dfeuer

Reviewed By: bgamari

Subscribers: dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #13154

Differential Revision: https://phabricator.haskell.org/D4370
compiler/typecheck/TcDeriv.hs
compiler/typecheck/TcDerivUtils.hs