Skip to content

Template Haskell needlessly pretty-prints empty instance contexts

This code:

{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS -ddump-splices #-}
module Bug where

$([d| class Foo a
      instance Foo Int
    |])

Used to pretty-print like this on GHC 8.0.2:

Bug2.hs:(5,3)-(7,6): Splicing declarations
    [d| class Foo_a13B a_a13C
        
        instance Foo_a13B Int |]
  ======>
    class Foo_a3Jo a_a3Jp
    instance Foo_a3Jo Int

But on GHC HEAD, it prints a redundant instance context!

Bug2.hs:(5,3)-(7,6): Splicing declarations
    [d| class Foo_a1eh a_a1ei
        
        instance Foo_a1eh Int |]
  ======>
    class Foo_a4ly a_a4lz
    instance () => Foo_a4ly Int
Trac metadata
Trac field Value
Version 8.1
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