Skip to content

Template Haskell does associated types poorly (printing & quoting)

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.
  2. The pretty-printer here omits the type on the default definition for F. (The word family is optional there, but isn't actually wrong.)
Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information