Skip to content

-ddump-splices omits namespace specifiers in fixity declarations

If you run this program with GHC 9.10.1:

{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where

$([d| infixl 4 data ###
      (###) :: a -> a -> a
      x ### y = x

      infixl 4 type ###
      type (###) :: a -> a -> a
      type x ### y = x
    |])

You'll get this output:

$ ghc-9.10.1 Bug.hs -dsuppress-uniques -ddump-splices
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o ) [Source file changed]
Bug.hs:(6,2)-(13,7): Splicing declarations
    [d| infixl 4 ###
        infixl 4 ###
        
        (###) :: a -> a -> a
        x ### y = x
        
        type (###) :: a -> a -> a
        
        type x ### y = x |]
  ======>
    infixl 4 ###
    (###) :: a -> a -> a
    (###) x y = x
    infixl 4 ###
    type (###) :: a -> a -> a
    type (###) x y = x

Note that the -ddump-splices output omits the data and type namespaces altogether when pretty-printing the fixity declarations. This is wrong, since trying to copy-paste this code back into a file will make GHC produce a parse error:

$ ghc-9.10.1 Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o ) [Source file changed]
Bug.hs:17:10: error: [GHC-50419]
    Multiple fixity declarations for ‘###’
    also at  Bug.hs:20:1-12
   |
17 | infixl 4 ###
   |          ^^^

I will investigate.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information