reify associated types when reifying typeclasses(#10891)
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Sat, 26 Sep 2015 19:07:51 +0000 (21:07 +0200)
committerBen Gamari <ben@smart-cactus.org>
Sat, 26 Sep 2015 19:08:16 +0000 (21:08 +0200)
commitb4d43b4e9f4f4fba068ab1e132113c4cd305dfe3
treebf7d7684e201ff22b1f906b72c31c2862e1073ca
parent988b2baa9745bd7871d179d11d4ca653041a1aa9
reify associated types when reifying typeclasses(#10891)

As reported in Trac #10891, Template Haskell's `reify` was not
generating Decls for associated types. This patch fixes that.

Note that even though `reifyTyCon` function used in this patch returns
some type instances, I'm ignoring that.

Here's an example of how associated types are encoded with this patch:

(Simplified representation)

    class C a where
      type F a :: *

    -->

    OpenTypeFamilyD "F" ["a"]

With default type instances:

    class C a where
      type F a :: *
      type F a = a

    -->

    OpenTypeFamilyD "F" ["a"]
    TySynInstD "F" (TySynEqn [VarT "a"] "a")

Test Plan:
This patch was already reviewed and even merged. The patch is later
reverted because apparently it broke the build some time between the
validation of this patch and merge. Creating this new ticket to fix the
validation.

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1277

GHC Trac Issues: #10891
compiler/typecheck/TcSplice.hs
testsuite/tests/th/T10891.hs [new file with mode: 0644]
testsuite/tests/th/T10891.stderr [new file with mode: 0644]
testsuite/tests/th/TH_reifyDecl1.stderr
testsuite/tests/th/all.T