Split out inferConstraintsDataConArgs from inferConstraints
authorRyan Scott <ryan.gl.scott@gmail.com>
Sat, 12 Aug 2017 19:46:22 +0000 (15:46 -0400)
committerRyan Scott <ryan.gl.scott@gmail.com>
Sat, 12 Aug 2017 19:46:23 +0000 (15:46 -0400)
commita4f347c23ed926c24d178fec54c27d94f1fae0e4
tree0c8297b1f17ca1704f7253655abe520e31190895
parent14457cf6a50f708eecece8f286f08687791d51f7
Split out inferConstraintsDataConArgs from inferConstraints

Summary:
Addresses point (1) of https://phabricator.haskell.org/D3337#107865.

Before, `inferConstraints` awkwardly combined all of the logic needed to handle
stock, newtype, and anyclass deriving. Really, though, the stock/newtype logic
is quite different from the anyclass logic, so this splits off
`inferConstraintsDataConArgs` (so named because it infers constraints by
inspecting the types of the arguments to data constructors) from
`inferConstraints` to handle the stock/newtype-specific bits.

Aside from making the code somewhat clearer, this allows us to factor out
superclass constraint inference, which is done regardless of deriving strategy.

Test Plan: If it builds, ship it

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3827
compiler/typecheck/TcDerivInfer.hs