reify associated types when reifying typeclasses
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Wed, 23 Sep 2015 18:19:58 +0000 (13:19 -0500)
committerAustin Seipp <austin@well-typed.com>
Wed, 23 Sep 2015 18:20:52 +0000 (13:20 -0500)
commit5c115236fe795aa01f0c10106f1b1c959486a739
tree36314780a6af4b8906dab5921a621533d37b0bad
parent453cdbfcea6962d0a2b5f532b5cdf53d5f82143d
reify associated types when reifying typeclasses

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")

Reviewed By: goldfire

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

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