Opened 4 years ago

Closed 4 years ago

#10811 closed bug (fixed)

Template Haskell does associated types poorly (printing & quoting)

Reported by: goldfire Owned by: goldfire
Priority: normal Milestone: 8.0.1
Component: Template Haskell Version: 7.10.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: th/T10811
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


When I say

{-# LANGUAGE TemplateHaskell, TypeFamilies #-}
{-# OPTIONS_GHC -ddump-splices -dsuppress-uniques #-}

module Bug where

$([d| class C a where
        type F a
        type F a = a |])

I get

    [d| class C a where
          type family F a
          F a = a |]

Bug.hs:6:7: Warning:
    Cannot desugar this Template Haskell declaration:
        class C a where
          type family F a
          F a = a

There are two problems here:

  1. This really should work.
  1. The pretty-printer here omits the type on the default definition for F. (The word family is optional there, but isn't actually wrong.)

Change History (4)

comment:1 Changed 4 years ago by thoughtpolice


Milestone renamed

comment:2 Changed 4 years ago by Richard Eisenberg <eir@…>

In 79b8e89/ghc:

Print associated types a bit better.

This is part of #10811. It removes the "family" keyword from
associated type family declarations, and it adds the "type"
keyword to associated type family defaults.

comment:3 Changed 4 years ago by Richard Eisenberg <eir@…>

In 1292c17e/ghc:

Allow TH quoting of assoc type defaults.

This fixes #10811.

comment:4 Changed 4 years ago by goldfire

Resolution: fixed
Status: newclosed
Test Case: th/T10811
Note: See TracTickets for help on using tickets.